version 1.63, 2006/06/15 16:44:00
|
version 1.70, 2008/11/20 10:44:24
|
Line 18 import string
|
Line 18 import string
|
import urllib |
import urllib |
import xml.dom.minidom |
import xml.dom.minidom |
|
|
ZOGIVERSION = "0.10.2b ROC 15.6.2006" |
ZOGIVERSION = "0.10.4b ROC 13.11.2006" |
|
|
def cropf(f): |
def cropf(f): |
"""returns a float with reduced precision""" |
"""returns a float with reduced precision""" |
Line 57 class zogiImage(SimpleItem):
|
Line 57 class zogiImage(SimpleItem):
|
"""einzelnes Image""" |
"""einzelnes Image""" |
meta_type="zogiImage" |
meta_type="zogiImage" |
|
|
manage_options=SimpleItem.manage_options+( |
manage_options=( |
{'label':'Main config','action':'changeZogiImageForm'}, |
{'label':'Main config','action':'changeZogiImageForm'}, |
) |
)+SimpleItem.manage_options |
|
|
|
|
def __init__(self,id,title,baseUrl,queryString,content_type='',precondition=''): |
def __init__(self,id,title,baseUrl,queryString,content_type='',precondition=''): |
Line 79 class zogiImage(SimpleItem):
|
Line 79 class zogiImage(SimpleItem):
|
# """getUrlData""" |
# """getUrlData""" |
# return urllib.urlopen(self.baseUrl+self.queryString) |
# return urllib.urlopen(self.baseUrl+self.queryString) |
|
|
def changeZogiImageForm(self): |
changeZogiImageForm = PageTemplateFile('zpt/changeZogiImageForm.zpt', globals()) |
"""Main configuration""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiImageForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
def changeZogiImage(self,title,baseUrl, queryString,RESPONSE=None): |
|
"""change it""" |
|
self.title=title |
|
self.baseUrl=baseUrl |
|
self.queryString=queryString |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def index_html(self, REQUEST, RESPONSE): |
def index_html(self, REQUEST, RESPONSE): |
"""service the request by redirecting to digilib server""" |
"""service the request by redirecting to digilib server""" |
RESPONSE.redirect(self.baseUrl+self.queryString) |
# use status 307 = moved temporarily |
|
RESPONSE.redirect(self.baseUrl+self.queryString, status=307) |
return '' |
return '' |
|
|
|
|
def rescale(self,width=None,height=None): |
def rescale(self,width=None,height=None): |
"""andere parameter im querystring""" |
"""andere parameter im querystring""" |
qs=cgi.parse_qs(self.queryString) |
qs=cgi.parse_qs(self.queryString) |
Line 110 class zogiImage(SimpleItem):
|
Line 100 class zogiImage(SimpleItem):
|
if height: |
if height: |
qs['dh']=height |
qs['dh']=height |
|
|
|
|
qsneu=urllib.urlencode(qs) |
qsneu=urllib.urlencode(qs) |
self.queryString=qsneu |
self.queryString=qsneu |
return "done" |
return "done" |
|
|
|
|
|
def setWithDigilibURL(self,digilibUrl): |
|
"""take all parameters from digilib URL string""" |
|
base = re.match('(.*?/Scaler\?)(.*)', digilibUrl) |
|
if base is not None: |
|
params = base.group(2).split('&') |
|
newparams = [] |
|
# filter out the parameters we want |
|
for p in params: |
|
(key, val) = p.split('=') |
|
if key in ['fn','pn','dw','dh','ww','wh','wx','wy','mo']: |
|
newparams.append(p) |
|
# set the new parameters |
|
if len(newparams) > 1: |
|
self.baseUrl = base.group(1) |
|
self.queryString = '&'.join(newparams) |
|
return True |
|
|
|
return False |
|
|
|
|
|
def changeZogiImage(self,title,baseUrl, queryString, digilibUrl=None, RESPONSE=None): |
|
"""change it""" |
|
self.title=title |
|
self.baseUrl=baseUrl |
|
self.queryString=queryString |
|
if digilibUrl is not None and len(digilibUrl) > 0: |
|
self.setWithDigilibURL(digilibUrl) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
def manage_addZogiImageForm(self): |
def manage_addZogiImageForm(self): |
"""Form for adding""" |
"""Form for adding""" |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiImage.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiImage.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
|
|
def manage_addZogiImage(self,id,title,baseUrl, queryString,RESPONSE=None): |
def manage_addZogiImage(self,id,title,baseUrl,queryString,digilibUrl=None,RESPONSE=None): |
"""add zogiimage""" |
"""add zogiimage""" |
newObj=zogiImage(id,title,baseUrl, queryString) |
newObj=zogiImage(id,title,baseUrl, queryString) |
self.Destination()._setObject(id,newObj) |
self.Destination()._setObject(id,newObj) |
|
if digilibUrl is not None and len(digilibUrl) > 0: |
|
newObj.setWithDigilibURL(digilibUrl) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 165 class zogiLib(Folder):
|
Line 189 class zogiLib(Folder):
|
main_metaData = PageTemplateFile('zpt/main_metadata', globals()) |
main_metaData = PageTemplateFile('zpt/main_metadata', globals()) |
#main_static = PageTemplateFile('zpt/main_static', globals()) |
#main_static = PageTemplateFile('zpt/main_static', globals()) |
options = PageTemplateFile('zpt/options', globals()) |
options = PageTemplateFile('zpt/options', globals()) |
changeForm = PageTemplateFile('zpt/changeForm', globals()) |
#changeForm = PageTemplateFile('zpt/changeForm', globals()) |
|
|
# display templates |
# display templates |
aux_divs = PageTemplateFile('zpt/aux_divs', globals()) |
aux_divs = PageTemplateFile('zpt/aux_divs', globals()) |
Line 334 class zogiLib(Folder):
|
Line 358 class zogiLib(Folder):
|
return {} |
return {} |
|
|
|
|
def zogilibPath(self, otherbase=None): |
def zogilibPathOLD(self, otherbase=None): |
"""returns an URL to the zogiLib instance""" |
"""returns an URL to the zogiLib instance""" |
url = self.REQUEST['URL1'] |
url = self.REQUEST['URL1'] |
# should end with "/" |
# should end with "/" |
Line 349 class zogiLib(Folder):
|
Line 373 class zogiLib(Folder):
|
url += '/' |
url += '/' |
return url |
return url |
|
|
|
def zogilibPath(self, otherbase=None): |
|
"""returns an URL to the zogiLib instance""" |
|
url = self.absolute_url() |
|
# should end with "/" |
|
if len(url) > 0 and url[-1] != '/': |
|
url += '/' |
|
if type(otherbase) is str: |
|
url += otherbase |
|
else: |
|
url += self.basePath |
|
# should still end with "/" |
|
if len(url) > 0 and url[-1] != '/': |
|
url += '/' |
|
return url |
def zogilibAction(self, action, otherbase=None): |
def zogilibAction(self, action, otherbase=None): |
"""returns a URL with zogilib path and action""" |
"""returns a URL with zogilib path and action""" |
url = self.zogilibPath(otherbase) |
url = self.zogilibPath(otherbase) |
Line 389 class zogiLib(Folder):
|
Line 427 class zogiLib(Folder):
|
return True |
return True |
|
|
|
|
def createScalerImg(self, requestString=None, bottom=0, side=0, width=500, height=500): |
def createScalerImg(self, requestString=None, bottom=0, side=0, width=500, height=500, options=None): |
"""generate Scaler IMG Tag""" |
"""generate Scaler IMG Tag""" |
self.checkQuery() |
self.checkQuery() |
bt = self.getBrowserType() |
bt = self.getBrowserType() |
Line 400 class zogiLib(Folder):
|
Line 438 class zogiLib(Folder):
|
if not requestString: |
if not requestString: |
requestString = self.getAllDLParams() |
requestString = self.getAllDLParams() |
url = self.getScalerUrl(requestString=requestString) |
url = self.getScalerUrl(requestString=requestString) |
|
# take insets from options if present |
|
if options is not None: |
|
side = options.get('side', side) |
|
bottom = options.get('bottom', bottom) |
# construct bottom and side insets |
# construct bottom and side insets |
b_par = "" |
b_par = "" |
s_par = "" |
s_par = "" |
Line 436 class zogiLib(Folder):
|
Line 478 class zogiLib(Folder):
|
# make shure to remove unused parameter |
# make shure to remove unused parameter |
del self.REQUEST.SESSION['scalerDiv'] |
del self.REQUEST.SESSION['scalerDiv'] |
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/zogilib_img_div')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/img_div')).__of__(self) |
return pt() |
return pt() |
|
|
def index_html(self): |
def index_html(self): |
Line 873 def manage_addZogiLibPageTemplate(self,
|
Line 915 def manage_addZogiLibPageTemplate(self,
|
id = 'main_%s'%layout |
id = 'main_%s'%layout |
self._setObject(id, zogiLibPageTemplate(id)) |
self._setObject(id, zogiLibPageTemplate(id)) |
ob = getattr(self, id) |
ob = getattr(self, id) |
ob.pt_edit(open(os.path.join(package_home(globals()),'zpt/main_%s.zpt'%layout)).read(),None) |
ob.pt_edit(open(os.path.join(package_home(globals()),'zpt/main_%s.zpt'%layout)).read(),'text/html') |
if title: |
if title: |
ob.pt_setTitle(title) |
ob.pt_setTitle(title) |
try: |
try: |