Diff for /ImageArchive/ImageArchive.py between versions 1.46 and 1.50

version 1.46, 2005/03/15 20:31:10 version 1.50, 2005/04/10 13:01:45
Line 193  class ImageDigilib(Folder,Persistent,Imp Line 193  class ImageDigilib(Folder,Persistent,Imp
     self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename="%s" """%filename)      self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename="%s" """%filename)
     self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")      self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")
         #print path          #print path
     imagefh=urllib.urlopen(path)      imagefh=urllib.urlopen(path,'rb')
                   
     self.REQUEST.RESPONSE.write(imagefh.read())      self.REQUEST.RESPONSE.write(imagefh.read())
     self.REQUEST.RESPONSE.close()      self.REQUEST.RESPONSE.close()
Line 802  class ImageCollection(Folder, Persistent Line 802  class ImageCollection(Folder, Persistent
   
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
           
       def importStructure(self,path):
           """import"""
           splitted=os.path.split(path)
           if os.path.isDir(path):
               manage_AddImageCollection(self,splitted[1],splitted[1],path,self.ImageViewerPath,self.defaultMetaString,RESPONSE=None)
               
               obj=getattr(self,splitted[1])
               obj.ImportFiles()
   
       def ImportStructure(self,RESPONSE=None):
           """Import the existing files of a folder"""
           files=os.listdir(self.ImageStoragePath)
           ret=""
           #print self.__dict__
   
   
           for file in files:
   
               if os.path.isdir(os.path.join(self.ImageStoragePath,file)):
                   manage_AddImageCollection(self,file,file,os.path.join(self.ImageStoragePath,file),self.ImageViewerPath,self.defaultMetaString)
               
                   obj=getattr(self,file)
                   obj.ImportStructure()
               else:
                   if not file[0]==".":
                       if self.__dict__.has_key(file):
   
                           ret=ret+"<br>"+file+" already exists!"
                       else:
                           ret=ret+"<br>"+file+" created!"
                           newObj=ImageDigilib(file,file)
                           #print newObj,file
                           #print newObj
                           try:
                               self._setObject(file,newObj)
                           except:
                               """nothing yet"""
           #print ret
           #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
           #print self.ImageStoragePath
   
           #scale thumb
       
           #self.scaleThumbs()
   
       #scale standard
   
       #self.scaleWorkingVersions()
       
       if RESPONSE:
           RESPONSE.redirect('manage_main')
       
     def ImportFiles(self,RESPONSE=None):      def ImportFiles(self,RESPONSE=None):
         """Import the existing files of a folder"""          """Import the existing files of a folder"""
         files=os.listdir(self.ImageStoragePath)          files=os.listdir(self.ImageStoragePath)
Line 856  class ImageCollection(Folder, Persistent Line 908  class ImageCollection(Folder, Persistent
   
     def show_selected_thumbs(self):      def show_selected_thumbs(self):
         #ids=[]          #ids=[]
                   try:
         return self.REQUEST.SESSION['filenames']          return self.REQUEST.SESSION['filenames']
       except:
        return None
     def show_thumbs(self):      def show_thumbs(self):
         ids=[]          ids=[]
         for entry in self.__dict__:          for entry in self.__dict__:
Line 956  class ImageCollection(Folder, Persistent Line 1009  class ImageCollection(Folder, Persistent
                         return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">previous sets</a>"                          return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">previous sets</a>"
             else:              else:
                 return ""                  return ""
       def showFolders(self):
           """show subfolders"""
           ret=""
           link=""" <a target="_top" href="%s">%s</a><br>"""
   
           if self.aq_parent.meta_type=="ImageCollection":
               ret+=link%(self.aq_parent.absolute_url(), "back ("+self.aq_parent.title+")")
               ret+="<br>"
               
           iCs=self.ZopeFind(self,obj_metatypes="ImageCollection")
           if not iCs:
               return ret
           else:
               
               link=""" <a target="_top" href="%s">%s</a><br>"""
               for iC in iCs:
                   ret+=link%(iC[1].absolute_url(),iC[0])
               ret+="<br>"
               return ret
     def showRuler(self,selected=None):      def showRuler(self,selected=None):
         """show ruler"""          """show ruler"""
         showall =self.REQUEST.SESSION.get('showall','no')          showall =self.REQUEST.SESSION.get('showall','no')
Line 965  class ImageCollection(Folder, Persistent Line 1036  class ImageCollection(Folder, Persistent
             return "<b>No entries</b>"              return "<b>No entries</b>"
                   
         if showall=='no':          if showall=='no':
           actualNr=0
             ids=self.show_thumbs()              ids=self.show_thumbs()
             colRows=self.getColTimesRow()              colRows=self.getColTimesRow()
             num=int(len(ids)/(colRows[0]*colRows[1]))              num=int(len(ids)/(colRows[0]*colRows[1]))
Line 972  class ImageCollection(Folder, Persistent Line 1044  class ImageCollection(Folder, Persistent
                 num+=1                  num+=1
             a=colRows[0]*colRows[1]              a=colRows[0]*colRows[1]
             #print num,num+1              #print num,num+1
           
             if num>1:              if num>1:
   
                 ret="<b>Show thumbnail group no:</b></br>"                  ret=""
                   if selected:
                   ret+="""<select onChange="parent.location.href='"""+self.REQUEST['URL1']+"""/selection?filename='+this.options[this.selectedIndex].value">"""
                   else:
               ret+="""<select onChange="parent.location.href='"""+self.REQUEST['URL1']+"""?filename='+this.options[this.selectedIndex].value">"""
                 for i in range(num):                  for i in range(num):
                     if (operator.mod(i,10)==0) and i>0:              try:
                         ret +="<br/>" #alle 10 linebreak einfuegen                nr=ids.index(self.REQUEST.SESSION['filename'])
               except:
                 nr=0
                     k=i*a                      k=i*a
               if (k <= nr) and (nr < i*(a+1)):
                  actualNr=i
                  ret+="""<option value="%s" selected>%i</option>"""%(ids[k],i)
               else:
                      ret+="""<option value="%s">%i</option>"""%(ids[k],i)
           ret+="</select>"    
           anf="<b>Show thumbnail group no:</b></br>"
           
           
           try:
                     if selected:                                      if selected:                
                         href=self.REQUEST['URL1']+"/selection?filename="+ids[k]                          href=self.REQUEST['URL1']+"/selection?filename="+ids[(actualNr-1)*a]
                     else:                      else:
                         href=self.REQUEST['URL1']+"?filename="+ids[int(k)]                          href=self.REQUEST['URL1']+"?filename="+ids[int((actualNr-1)*a)]
           
             anf+="""<a href="%s" target="_top">%s</a>&nbsp;&nbsp;"""%(href,"prev")
           except:
             pass
           ret=anf+ret
   
                     ret+="""<a href="%s" target="_top">%i</a>&nbsp;&nbsp;"""%(href,i)          try:
             
             if selected:                
                           href=self.REQUEST['URL1']+"/selection?filename="+ids[(actualNr+1)*a]
                     else:
                           href=self.REQUEST['URL1']+"?filename="+ids[int((actualNr+1)*a)]
           
             end="""<a href="%s" target="_top">%s</a>&nbsp;&nbsp;"""%(href,"next")
           except:
             end=""
           ret=ret+end
   
   
                   #for i in range(num):
                   #    
                   #        ret +="<br/>" #alle 10 linebreak einfuegen
                   #    k=i*a
                   #    if selected:                
                   #        href=self.REQUEST['URL1']+"/selection?filename="+ids[k]
                   #    else:
                   #        href=self.REQUEST['URL1']+"?filename="+ids[int(k)]
               #
                   #    ret+="""<a href="%s" target="_top">%i</a>&nbsp;&nbsp;"""%(href,i)
   
             else:              else:
                 ret=""                  ret=""
Line 997  class ImageCollection(Folder, Persistent Line 1113  class ImageCollection(Folder, Persistent
     def show_thumbs_selected_rows(self,numberOfColumns):      def show_thumbs_selected_rows(self,numberOfColumns):
         """Ausgabe anzahl"""          """Ausgabe anzahl"""
         ids=self.show_selected_thumbs()          ids=self.show_selected_thumbs()
   
           if not ids:
           return None
         self.REQUEST.SESSION['ids']=ids          self.REQUEST.SESSION['ids']=ids
         number=int(len(ids)/numberOfColumns)+1          number=int(len(ids)/numberOfColumns)+1
         self.REQUEST.SESSION['number']=range(number)          self.REQUEST.SESSION['number']=range(number)

Removed from v.1.46  
changed lines
  Added in v.1.50


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