--- zogiLib/zogiLib.py 2004/06/22 17:09:13 1.29 +++ zogiLib/zogiLib.py 2004/07/16 13:47:50 1.31 @@ -15,7 +15,12 @@ import urllib import types from Globals import package_home -ZOGIVERSION = "0.9.4 ROC:22.6.2004" +ZOGIVERSION = "0.9.5 ROC:25.6.2004" + +def cropf(f): + """returns a float with reduced precision""" + return float(int(f * 10000)/10000.0) + def sendFile(self, filename, type): """sends an object or a local file (in the product) as response""" @@ -57,49 +62,6 @@ def browserCheck(self): return bt -def manage_addZogiLibMainTemplateForm(self): - """Form for adding""" - #FIXME:??? - pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/AddOSAS_thumbTemplate.zpt')).__of__(self) - return pt() - - - - -def manage_addZogiLibMainTemplate(self, id,title=None, text=None, - REQUEST=None, submit=None): - "Add a Page Template with optional file content." - #FIXME:??? - id = str(id) - if REQUEST is None: - self._setObject(id, zogiLib_mainTemplate(id, text)) - ob = getattr(self, id) - - if title: - ob.pt_setTitle(title) - return ob - else: - file = REQUEST.form.get('file') - headers = getattr(file, 'headers', None) - if headers is None or not file.filename: - zpt = zogiLib_mainTemplate(id) - else: - zpt = zogiLib_mainTemplate(id, file, headers.get('content_type')) - - self._setObject(id, zpt) - ob = getattr(self, id) - - - try: - u = self.DestinationURL() - except AttributeError: - u = REQUEST['URL1'] - - if submit == " Add and Edit ": - u = "%s/%s" % (u, quote(id)) - REQUEST.RESPONSE.redirect(u+'/manage_main') - return '' - class zogiImage(Image): """einzelnes Image""" @@ -563,8 +525,13 @@ class zogiLib(Folder): if bt['staticHTML']: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow_static.zpt')).__of__(self) else: - pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow.zpt')).__of__(self) - return pt() + finds=self.ZopeFind(self,obj_ids=['viewingTools.zpt']) + if finds: + + return finds[0][1]() + else: + pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow.zpt')).__of__(self) + return pt() def mark1(self): """mark image""" @@ -756,6 +723,17 @@ class zogiLib(Folder): self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params) + def getDLTarget(self): + """returns dlTarget""" + self.checkQuery() + s = self.dlTarget +# s = 'dl' +# if self.getDLParam('fn'): +# s += "_" + self.getDLParam('fn') +# if self.getDLParam('pn'): +# s += "_" + self.getDLParam('pn') + return s + def setStaticHTML(self, static=True): """sets the preference to static HTML""" self.checkQuery() @@ -883,10 +861,10 @@ class zogiLib(Folder): wh2 = max(min(wh2, 1), 0) wx = max(min(wx, 1), 0) wy = max(min(wy, 1), 0) - self.setDLParam('ww', ww2) - self.setDLParam('wh', wh2) - self.setDLParam('wx', wx) - self.setDLParam('wy', wy) + self.setDLParam('ww', cropf(ww2)) + self.setDLParam('wh', cropf(wh2)) + self.setDLParam('wx', cropf(wx)) + self.setDLParam('wy', cropf(wy)) return self.display() def dl_ZoomIn(self): @@ -909,8 +887,8 @@ class zogiLib(Folder): wy += dy * 0.5 * wh wx = max(min(wx, 1), 0) wy = max(min(wy, 1), 0) - self.setDLParam('wx', wx) - self.setDLParam('wy', wy) + self.setDLParam('wx', cropf(wx)) + self.setDLParam('wy', cropf(wy)) return self.display() def dl_MoveLeft(self):