Diff for /zogiLib/zogiLib.py between versions 1.28 and 1.30

version 1.28, 2004/06/22 13:35:50 version 1.30, 2004/06/25 16:59:45
Line 15  import urllib Line 15  import urllib
 import types  import types
 from Globals import package_home  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):  def sendFile(self, filename, type):
     """sends an object or a local file (in the product) as response"""      """sends an object or a local file (in the product) as response"""
Line 57  def browserCheck(self): Line 62  def browserCheck(self):
   
     return bt      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):  class zogiImage(Image):
     """einzelnes Image"""      """einzelnes Image"""
Line 722  class zogiLib(Folder): Line 684  class zogiLib(Folder):
         # assemble query string          # assemble query string
         ret = ""          ret = ""
         for param in dlParams.keys():          for param in dlParams.keys():
             if dlParams[param] == None: continue              if dlParams[param] is None: continue
             val = str(dlParams[param])              val = str(dlParams[param])
             if val != "":              if val != "":
                 ret += param + "=" + val + "&"                  ret += param + "=" + val + "&"
Line 756  class zogiLib(Folder): Line 718  class zogiLib(Folder):
             self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)              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):      def setStaticHTML(self, static=True):
         """sets the preference to static HTML"""          """sets the preference to static HTML"""
         self.checkQuery()          self.checkQuery()
Line 883  class zogiLib(Folder): Line 856  class zogiLib(Folder):
         wh2 = max(min(wh2, 1), 0)          wh2 = max(min(wh2, 1), 0)
         wx = max(min(wx, 1), 0)          wx = max(min(wx, 1), 0)
         wy = max(min(wy, 1), 0)          wy = max(min(wy, 1), 0)
         self.setDLParam('ww', ww2)          self.setDLParam('ww', cropf(ww2))
         self.setDLParam('wh', wh2)          self.setDLParam('wh', cropf(wh2))
         self.setDLParam('wx', wx)          self.setDLParam('wx', cropf(wx))
         self.setDLParam('wy', wy)          self.setDLParam('wy', cropf(wy))
         return self.display()          return self.display()
                   
     def dl_ZoomIn(self):      def dl_ZoomIn(self):
Line 909  class zogiLib(Folder): Line 882  class zogiLib(Folder):
         wy += dy * 0.5 * wh          wy += dy * 0.5 * wh
         wx = max(min(wx, 1), 0)          wx = max(min(wx, 1), 0)
         wy = max(min(wy, 1), 0)          wy = max(min(wy, 1), 0)
         self.setDLParam('wx', wx)          self.setDLParam('wx', cropf(wx))
         self.setDLParam('wy', wy)          self.setDLParam('wy', cropf(wy))
         return self.display()          return self.display()
                   
     def dl_MoveLeft(self):      def dl_MoveLeft(self):
Line 1016  def manage_addZogiLib(self,id,title,digi Line 989  def manage_addZogiLib(self,id,title,digi
     self.Destination()._setObject(id,newObj)      self.Destination()._setObject(id,newObj)
     if RESPONSE is not None:      if RESPONSE is not None:
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
   
   
   class zogiLibPageTemplate(ZopePageTemplate):
       """pageTemplate Objekt"""
       meta_type="zogiLib_pageTemplate"
   
   
   ## def __init__(self, id, text=None, contentType=None):
   ##         self.id = str(id)
   ##         self.ZBindings_edit(self._default_bindings)
   ##         if text is None:
   ##             text = open(self._default_cont).read()
   ##         self.pt_edit(text, contentType)
   
   def manage_addZogiLibPageTemplateForm(self):
       """Form for adding"""
       pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibPageTemplateForm')).__of__(self)
       return pt()
   
   def manage_addZogiLibPageTemplate(self, id='zogiLibMainTemplate', title=None, layout=None, text=None,
                              REQUEST=None, submit=None):
       "Add a Page Template with optional file content."
   
       id = str(id)
       self._setObject(id, zogiLibPageTemplate(id))
       ob = getattr(self, id)
       if not layout: layout = "book"
       ob.pt_edit(open(os.path.join(package_home(globals()),'zpt/zogiLibMain_%s.zpt'%layout)).read(),None)
       if title:
           ob.pt_setTitle(title)
       try:
           u = self.DestinationURL()
       except AttributeError:
           u = REQUEST['URL1']
           
       u = "%s/%s" % (u, urllib.quote(id))
       REQUEST.RESPONSE.redirect(u+'/manage_main')
       return ''

Removed from v.1.28  
changed lines
  Added in v.1.30


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>