--- ImageArchive/ImageArchive.py 2006/05/22 21:09:53 1.92 +++ ImageArchive/ImageArchive.py 2009/01/06 16:13:51 1.107 @@ -1,3 +1,5 @@ +"""version 1 des Imageservers, wird ersetzt durch version2""" + genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config @@ -24,9 +26,21 @@ from threading import Thread import Queue import cgi import sys -import zLOG + import shutil +import logging + +#ersetzt logging +def logger(txt,method,txt2): + """logging""" + logging.info(txt+ txt2) + +def logTime(msg=""): + """log the time""" + logging.info("%s %s"%(msg,time.clock())) + + from AccessControl import ClassSecurityInfo, getSecurityManager try: @@ -49,11 +63,11 @@ except: manage_options=() - -tdir = "/mpiwg/temp/tmp/archivesImageServer/" +tdir="tmp" +#tdir = "/mpiwg/temp/tmp/archivesImageServer/" #tdir="/tmp/archivesImageServer/" -imageExtensions=['jpg','jpeg','tif','tiff','png'] +imageExtensions=['.jpg','.jpeg','.tif','.tiff','.png','.gif'] def splitPath(str): str2=str.replace("\\","/") @@ -80,16 +94,19 @@ class generateSet: """generateSetThread""" - def __init__(self,filenames,filenamesIds,ImageViewerPath,ids,url,local=None,version="working"): + def __init__(self,filenames,filenamesIds,ImageViewerPath,ImageStoragePath,destBasis,ids,url,local=None,version="working"): """init generateSet""" self.filenames=filenames self.filenamesIds=filenamesIds self.ImageViewerPath=ImageViewerPath + self.ImageStoragePath=ImageStoragePath + self.destBasis=destBasis self.ids=ids self.local=local self.url=url self.version=version self.done=None + self.response="" def __call__(self): @@ -115,26 +132,34 @@ class generateSet: for id in self.filenames: - if self.filenamesIds.has_key(id[0]): + if self.filenamesIds.has_key(id[0]) and self.filenamesIds[id[0]][0]: filename=self.filenamesIds[id[0]][0]+"_"+id[0] else: filename=id[0] self.response+=str("
Get File: %s
\n"%filename)
-
+ toggle=False
+
if self.local:
if self.version=="working":
-
- sourcePath="/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+os.path.splitext(id[0])[0]+".jpg"
- else:
- sourcePath="/mpiwg/online/"+self.ImageViewerPath+"/"+id[0]
+
+ sourcePath=self.destBasis+"/"+self.ImageViewerPath+"/"+os.path.splitext(id[0])[0]+".jpg"
+ if not os.path.exists(sourcePath):
+ self.response+=str("
%s doesn't exist I'll try the non scaled image
"%sourcePath) + toggle=True + if (self.version!="working") or toggle: + toggle=False + sourcePath=self.ImageStoragePath+"/"+id[0] + if not os.path.exists(sourcePath): + sourcePath=self.ImageStoragePath+"/"+os.path.splitext(id[0])[0]+".jpg" + targetPath=tmpPath+"/"+filename try: shutil.copyfile(sourcePath,targetPath) except: - self.response+=(str("Error in File: %s (possible missing)
\n"%filename))
+ self.response+=(str("
Error in File: %s (possible missing)
\n"%sourcePath))
else:
if self.version=="working":
requestString=self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&dh=2000&dw=2000"
@@ -283,9 +308,14 @@ class ImageDigilib(Folder,Persistent,Imp
manage_options = Folder.manage_options+(
{'label':'Add Metadata','action':'addMetaObjectForm'},
-
+ {'label':'View Info','action':'editImageDigilib'},
)
+ def editImageDigilib(self):
+ """edit image date"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editImageDigilib.zpt')).__of__(self)
+ return pt()
+
def getAccessRight(self):
@@ -296,7 +326,7 @@ class ImageDigilib(Folder,Persistent,Imp
def isAccessible(self):
"""gives true if obejct is accessible taking the rights of the user into account"""
-
+ logTime("isaccessible")
#TODO: implement rights, currently true if external and false if internal, and true if user has role authenticated
username=self.REQUEST['AUTHENTICATED_USER']
@@ -309,7 +339,7 @@ class ImageDigilib(Folder,Persistent,Imp
if self.getRightsQuery()=="":
#query empty then always true
- return True
+ return True
if 'Authenticated' in roles:
@@ -380,12 +410,14 @@ class ImageDigilib(Folder,Persistent,Imp
"""upload an Image from an Requast"""
#path_name=self.ImageStoragePath
fn = self.filename or splitPath(fileupload.filename)
+ fn = os.path.splitext(fn)[0]+os.path.splitext(fileupload.filename)[1] # Extensions des gespeicherten Files sollte gleich dem hochgeladenen File sein.
filename=path_name+"/"+fn
filedata=fileupload.read()
f=open(filename,"w")
f.write(filedata)
f.close()
self.filename = fn
+
try:
os.chmod(filename,0664)
except:
@@ -450,13 +482,13 @@ class ImageDigilib(Folder,Persistent,Imp
self.title=newname[0:]
self.filename=newname[0:]
#umbennen des files auf dem server
- oldpath=os.path.join(self.ImageStoragePath,oldname)
- newpath=os.path.join(self.ImageStoragePath,newname)
+ oldpath=os.path.join(self.getImageStoragePath(),oldname)
+ newpath=os.path.join(self.getImageStoragePath(),newname)
os.rename(oldpath,newpath)
#umbenennen des versionsfolders
- oldfolder=os.path.join(self.ImageStoragePath,"."+oldname+".dir")
- newfolder=os.path.join(self.ImageStoragePath,"."+newname+".dir")
+ oldfolder=os.path.join(self.getImageStoragePath(),"."+oldname+".dir")
+ newfolder=os.path.join(self.getImageStoragePath(),"."+newname+".dir")
if os.path.exists(oldfolder):
os.rename(oldfolder,newfolder)
else:
@@ -488,7 +520,7 @@ class ImageDigilib(Folder,Persistent,Imp
self.scaleWorkingVersions()
- self.scaleToJpg()
+ #self.scaleToJpg()
if RESPONSE:
RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
@@ -497,47 +529,49 @@ class ImageDigilib(Folder,Persistent,Imp
#create backup of the original file
- imagePath=os.path.join(self.ImageStoragePath,self.filename)
- path=os.path.join(self.ImageStoragePath,"."+self.getId()+".dir")
+ imagePath=os.path.join(self.getImageStoragePath(),self.filename)
+ path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")
if not os.path.exists(path):
os.mkdir(path,0775)
os.chmod(path,0775)
- newName=os.path.join(path,self.getId())
+ newName=os.path.join(path,self.getId()+str(time.time()))
if os.path.exists(newName):
- zLOG.LOG("ImageArchive:scaleToJpg", zLOG.INFO, "%s already exists"%newName)
+ logger("ImageArchive:scaleToJpg", logging.INFO, "%s already exists"%newName)
else:
try:
os.rename(imagePath,newName)
except:
- zLOG.LOG("ImageArchive:scaleToJpg", zLOG.ERROR, "%s "%newName)
+ logger("ImageArchive:scaleToJpg", logging.ERROR, "%s "%newName)
return False
ext= os.path.splitext(imagePath)[1].lower()
if ext.rstrip()==".jpg":
- shutil.copy(newName,imagePath)
- print "copy",imagePath
- return True
+ shutil.copy(newName,imagePath)
+ print "copy",imagePath
+ return True
+
+
- print "SCALED",imagePath
- dest="/Volumes/paviaExtern/docuserver/images/exhibitionImages/"
dir=self.getId()
- src=path
- self.scale(dest=dest,dir=dir,src=path,scaleBy=1,RESPONSE=RESPONSE)
+ src=path
+ self.scale(dest=self.getImageStoragePath(),dir=dir,src=path,scaleBy=1,RESPONSE=RESPONSE)
return True
def updateImage(self,_fileupload,_rename=None,RESPONSE=None):
"""lade neues Version des Bildes"""
#teste ob Dokumenten ordner schon vorhanden
- #imagePath=os.path.join(self.ImageStoragePath,self.getId())
+ #imagePath=os.path.join(self.getImageStoragePath(),self.getId())
+ logging.error("updateImage:"+self.filename)
identifyField="filename"
if _fileupload and _fileupload.filename!="":
- imagePath=os.path.join(self.ImageStoragePath,self.filename)
- path=os.path.join(self.ImageStoragePath,"."+self.getId()+".dir")
+ imagePath=os.path.join(self.getImageStoragePath(),self.filename)
+ idWithoutSuffix= os.path.splitext(self.getId())[0]
+ path=os.path.join(self.getImageStoragePath(),"."+self.getId()+".dir")
if not os.path.exists(path):
os.mkdir(path,0775)
@@ -553,18 +587,26 @@ class ImageDigilib(Folder,Persistent,Imp
#kopieren der bestehenden Version in den Versions ordner.
imageNewPath=os.path.join(path,"V%i_%s"%(versionNumber,self.filename))
try:
- #zLOG.LOG("ImageArchive:updateImage", zLOG.INFO, "rename: %s -> %s"%(imagePath,imageNewPath))
- os.rename(imagePath,imageNewPath)
+ #logger("ImageArchive:updateImage", logging.INFO, "rename: %s -> %s"%(imagePath,imageNewPath))
+ os.rename(imagePath,imageNewPath)
except:
- zLOG.LOG("ImageArchive:updateImage", zLOG.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))
+ logger("ImageArchive:updateImage ", logging.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath))
#lesen des upload files und schreiben
filedata=_fileupload.read()
- f=open(imagePath,"w") # if we wanted to have filename=id we should do it here!
+
+ #passe suffix an
+ oldNameBase=os.path.splitext(imagePath)[0]
+ uploadFileExt=os.path.splitext(_fileupload.filename)[1]
+
+ newImagePath=oldNameBase+uploadFileExt
+
+ f=open(newImagePath,"w") # if we wanted to have filename=id we should do it here!
+ logging.error("saving:"+newImagePath)
f.write(filedata)
f.close()
try:
- os.chmod(imagePath,0664)
+ os.chmod(newImagePath,0664)
except:
pass
#scale thumb
@@ -574,17 +616,23 @@ class ImageDigilib(Folder,Persistent,Imp
#scale standard
self.scaleWorkingVersions()
- self.scaleToJpg()
+ #self.scaleToJpg()
if _rename:
self.renameImage(_fileupload.filename)
+ else:
+ self.filename=os.path.splitext(self.filename)[0]+uploadFileExt # Aendere zumindest die Extensiion
- args=self.REQUEST.form
+ try: #todo: sollte nur aufgerufen werden, wenn eine Datenbank dahinter liegt.
+ args=self.REQUEST.form
- args['-identify']=identifyField+"="+args['_identifyField']
+ args['-identify']=identifyField+"="+args['_identifyField']
- self.ZSQLChange(args=args)
+ self.ZSQLChange(args=args)
+ except:
+ pass
+
if RESPONSE:
RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
@@ -617,7 +665,8 @@ class ImageDigilib(Folder,Persistent,Imp
- self.REQUEST.SESSION['string']=""% path
+ imageString=""% path
+ self.REQUEST.SESSION['string']=imageString
if url:
return ""% path
else:
@@ -627,7 +676,7 @@ class ImageDigilib(Folder,Persistent,Imp
return getattr(self,overview[0][0])()
else:
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbMD.zpt')).__of__(self)
- return pt()
+ return pt(imageString=imageString)
def image(self,dw=None,dh=None):
@@ -670,7 +719,7 @@ def manage_AddImageDigilib(self,id,fileu
newObj=ImageDigilib(id,fn,meta)
self._setObject(id,newObj)
- getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)
+ getattr(self,id).uploadImage(fileupload,self.getImageStoragePath())
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
@@ -694,7 +743,6 @@ class ImageCollection(OrderedFolder, Per
leiden_meta_fields=['image_id','date','country','place','people','description','photographer']
- scaledBasis="/mpiwg/temp/online/scaled"
defaultMetaString="http://fm-web.mpiwg-berlin.mpg.de:8050/FMRes/FMPJS?-db=Wissenschaftlerportraits.fp5&-layID=69&-token=25&-max=1&-format=formvwcss.htm&-mode=browse&images::filename=%s&-find" ## TEST FUER IMAGEDATENBANK WP
@@ -704,18 +752,38 @@ class ImageCollection(OrderedFolder, Per
imgcoll_thumbMD = PageTemplateFile('zpt/thumbMD', globals())
destBasis="/docuserver/scaled/"
+ scaledBasis=destBasis
srcBasis="/docuserver/images"
+ scaleomatStr="/docuserver/libs/scaleomat/scaleomat.pl"
+
+ #dest="/Volumes/paviaExtern/docuserver/images/exhibitionImages/"
+
+ def configScaleForm(self):
+ """configure the scaler form"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','configScale.zpt')).__of__(self)
+ return pt()
+
+ def configScale(self,scaleomatStr,RESPONSE=None):
+ """config the scaler"""
+ self.scaleomatStr=scaleomatStr
+
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
def scale(self,dest=None,dir=None,src=None,scaleTo=None,scaleBy=None,RESPONSE=None):
"""scaler"""
#scaleomatStr="ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ %s"
- scaleomatStr="/docuserver/libs/scaleomat/scaleomat.pl"
+ scaleomatStr=self.scaleomatStr
destBasis=self.destBasis
srcBasis=self.srcBasis
+
+
if src:
- srcStr=" -src=%s"%src
+ srcStr=" -src=%s"%src
else:
- srcStr=" -src=%s"%srcBasis
+ srcStr=" -src=%s"%srcBasis
scaleStr=scaleomatStr+srcStr
if dir:
@@ -727,14 +795,14 @@ class ImageCollection(OrderedFolder, Per
fileStr=" -dir=%s"%fileTmp
scaleStr=scaleStr+fileStr
else:
- zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no directory or filename given")
+ logger("ImageCollection:scale",logging.ERROR,"no directory or filename given")
return False
if dest is not None:
destStr=" -dest=%s"%os.path.join(destBasis,dest)
scaleStr=scaleStr+destStr
else:
- zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")
+ logger("ImageCollection:scale",logging.ERROR,"no destionation given")
return False
if scaleTo:
@@ -744,11 +812,12 @@ class ImageCollection(OrderedFolder, Per
scaleByStr=" -scaleby=%s"%scaleBy
scaleStr=scaleStr+scaleByStr
else:
- zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given")
+ logger("ImageCollection:scale",logging.ERROR,"no destionation given")
return False
#ret=scaleStr
+ logger("ImageCollection:scale",logging.INFO,scaleStr)
ret=os.popen2(scaleStr,1)[1].read()
if RESPONSE:
@@ -762,12 +831,12 @@ class ImageCollection(OrderedFolder, Per
name=os.path.splitext(name)[0]
for extension in imageExtensions:
- nameExt=name+"."+extension
+ nameExt=name+extension
if hasattr(self,nameExt):
return getattr(self,nameExt)
- nameExt=name+"_."+extension
+ nameExt=name+"_"+extension
if hasattr(self,nameExt):
return getattr(self,nameExt)
@@ -787,7 +856,15 @@ class ImageCollection(OrderedFolder, Per
def getImageStoragePath(self):
"""get ImageStoragePath"""
- return self.ImageStoragePath
+ if self.ImageViewerPath[0]=="/":
+ if len(self.ImageViewerPath)>1:
+ iv=self.ImageViewerPath[1:]
+ else:
+ iv=""
+ else:
+ iv=self.ImageViewerPath
+
+ return os.path.join(self.srcBasis,iv)
def refreshTxt(self):
"""txt fuer refresh"""
@@ -801,7 +878,7 @@ class ImageCollection(OrderedFolder, Per
if not threadName or threadName=="":
- threadStart=generateSet(self.REQUEST.SESSION['filenames'],self.REQUEST.SESSION['filenamesIds'],self.ImageViewerPath,self.show_thumbs(),self.absolute_url(),local=local,version=version)
+ threadStart=generateSet(self.REQUEST.SESSION['filenames'],self.REQUEST.SESSION['filenamesIds'],self.ImageViewerPath,self.ImageStoragePath,self.destBasis,self.show_thumbs(),self.absolute_url(),local=local,version=version)
thread=Thread(target=threadStart)
thread.start()
@@ -890,11 +967,11 @@ class ImageCollection(OrderedFolder, Per
#scale thumbs
dest=os.path.join(self.scaledBasis,'thumb')
- self.scale(dir=self.ImageStoragePath,dest=dest,scaleTo=100,RESPONSE=RESPONSE)
+ self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=100,RESPONSE=RESPONSE)
#ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/thumb -scaleto=100 &"% self.ImageViewerPath)
- if RESPONSE:
- RESPONSE.write(ret.read())
- RESPONSE.write("\n")
+ #if RESPONSE:
+ # RESPONSE.write(ret.read())
+ # RESPONSE.write("\n")
return "RESCALING STARTED"
@@ -904,10 +981,10 @@ class ImageCollection(OrderedFolder, Per
#scale standard
dest=os.path.join(self.scaledBasis,'small')
- self.scale(dir=self.ImageStoragePath,dest=dest,scaleTo=1000,RESPONSE=RESPONSE)
+ self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=1000,RESPONSE=RESPONSE)
dest=os.path.join(self.scaledBasis,'medium')
- self.scale(dir=self.ImageStoragePath,dest=dest,scaleTo=2000,RESPONSE=RESPONSE)
+ self.scale(dir=self.getImageStoragePath(),dest=dest,scaleTo=2000,RESPONSE=RESPONSE)
#ret=os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ -dir=%s -dest=/mpiwg/temp/online/scaled/small -scaleto=2000 &"% self.ImageViewerPath)
if RESPONSE:
@@ -916,13 +993,14 @@ class ImageCollection(OrderedFolder, Per
return "rescaling started"
- def __init__(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath=genericServerPath):
+ def __init__(self,id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath=genericServerPath):
self.id=id
self.title=title
- self.ImageStoragePath=ImageStoragePath
self.ImageViewerPath=ImageViewerPath
self.defaultMetaString=defaultMetaString
self.serverPath=serverPath
+ self.destBasis=destBasis
+ self.srcBasis=srcBasis
self.defaultrows = 6
self.defaultcols = 2
@@ -930,6 +1008,7 @@ class ImageCollection(OrderedFolder, Per
manage_options = optTMP+(
{'label':'Main Config','action':'ImageCollection_config'},
+ {'label':'Config Scaler','action':'configScaleForm'},
{'label':'Import','action':'ImportFiles'},
{'label':'Recalculate MetadataLink','action':'recalculateMetaLink'},
{'label':'Import Metadata File','action':'importMetaFileForm'},
@@ -1161,11 +1240,11 @@ class ImageCollection(OrderedFolder, Per
def ImportFiles2(self,RESPONSE=None):
"""Import the existing files of a folder"""
- files=os.listdir(self.ImageStoragePath)
+ files=os.listdir(self.getImageStoragePath())
ret=""
#print self.__dict__
for file in files:
- fn=os.path.splitext(file)[0]
+ fn=os.path.splitext(file)[0]
if not (file[0]=="."):
if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') :
@@ -1179,7 +1258,7 @@ class ImageCollection(OrderedFolder, Per
self._setObject(file,newObj)
#print ret
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
- #print self.ImageStoragePath
+ #print self.getImageStoragePath()
#scale thumb
@@ -1203,17 +1282,17 @@ class ImageCollection(OrderedFolder, Per
def ImportStructure(self,RESPONSE=None):
"""Import the existing files of a folder"""
- files=os.listdir(self.ImageStoragePath)
+ files=os.listdir(self.getImageStoragePath())
ret=""
#print self.__dict__
for file in files:
- if os.path.isdir(os.path.join(self.ImageStoragePath,file)):
- imageStoragePath=os.path.join(self.ImageStoragePath,file)
+ if os.path.isdir(os.path.join(self.getImageStoragePath(),file)):
+ ImageStoragePath=os.path.join(self.getImageStoragePath(),file)
imageViewerPath=os.path.join(self.ImageViewerPath,file)
- manage_AddImageCollection(self,file,file,imageStoragePath,imageViewerPath,self.defaultMetaString)
+ manage_AddImageCollection(self,file,file,self.getImageStoragePath(),imageViewerPath,self.defaultMetaString)
obj=getattr(self,file)
obj.ImportStructure()
@@ -1233,7 +1312,7 @@ class ImageCollection(OrderedFolder, Per
"""nothing yet"""
#print ret
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
- #print self.ImageStoragePath
+ #print self.getImageStoragePath()
#scale thumb
@@ -1248,11 +1327,11 @@ class ImageCollection(OrderedFolder, Per
def ImportFiles(self,RESPONSE=None):
"""Import the existing files of a folder"""
- files=os.listdir(self.ImageStoragePath)
+ files=os.listdir(self.getImageStoragePath())
ret=""
#print self.__dict__
for file in files:
- fn=os.path.splitext(file)[0]
+ fn=os.path.splitext(file)[0]
if not (file[0]=="."):
if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') :
@@ -1269,7 +1348,7 @@ class ImageCollection(OrderedFolder, Per
"""nothing yet"""
#print ret
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
- #print self.ImageStoragePath
+ #print self.getImageStoragePath()
#scale thumb
@@ -1290,13 +1369,14 @@ class ImageCollection(OrderedFolder, Per
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','ChangeImageCollectionForm.zpt')).__of__(self)
return pt()
- def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath,RESPONSE=None):
+ def ChangeImageCollection(self,title,ImageViewerPath,defaultMetaString,serverPath,destBasis,srcBasis,RESPONSE=None):
"""Change"""
self.title=title
- self.ImageStoragePath=ImageStoragePath
self.ImageViewerPath=ImageViewerPath
self.defaultMetaString=defaultMetaString
self.serverPath=serverPath
+ self.destBasis=destBasis
+ self.srcBasis=srcBasis
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
@@ -1563,16 +1643,17 @@ class ImageCollection(OrderedFolder, Per
return ret
- def show_thumbs_selected_rows(self,numberOfColumns):
+ def show_thumbs_selected_rows(self,numberOfColumns,start=0,max=10000):
"""Ausgabe anzahl"""
ids=self.show_selected_thumbs()
if not ids:
return None
self.REQUEST.SESSION['ids']=ids
- number=int(len(ids)/numberOfColumns)+1
- self.REQUEST.SESSION['number']=range(number)
- return range(number+1)
+ number=min(start+int(len(ids)/numberOfColumns)+1,max)
+
+ self.REQUEST.SESSION['number']=range(start,number)
+ return range(start,number+1)
def setColTimesRowForm(self):
"""form for matrix setting"""
@@ -1633,7 +1714,8 @@ class ImageCollection(OrderedFolder, Per
showall=self.REQUEST.SESSION.get('showall', 'No')
if showall=='yes':
rows=int(idsnumber/cols)+1
-
+
+ logTime("getColTimesRow finished")
return (cols,rows)
@@ -1676,32 +1758,26 @@ class ImageCollection(OrderedFolder, Per
self.REQUEST.SESSION['ids']=ids
number=int(len(ids)/numberOfColumns)+1
-
+
+ logTime("show_thumbs_rows finished (%s)"%str(number))
return range(number+1)
def show_thumbs_columns(self,row,numberOfColumns):
"""Ausgabe einer Liste der Reihe"""
ids=self.REQUEST.SESSION['ids']
max=len(ids)
+ logTime("show_thumb_columns finishes row: %s"%row)
if (row*numberOfColumns)
"+file+" created!"
newObj=ImageDigilib(file,file)
#print newObj,file
@@ -1888,13 +1975,15 @@ class ImageCollectionMD(ImageCollection,
except:
"""nothing yet"""
-
- args={}
- args['_table']=self.imageCollectionConfig.getTable()
- args[self.imageCollectionConfig.getKey()]=file
-
- if not self.ZSQLInlineSearch(args=args):
- self.ZSQLAdd(args=args)
+ # check entry in database
+ args={}
+ args['_table']=self.imageCollectionConfig.getTable()
+ args[self.imageCollectionConfig.getKey()]=file
+
+ if not self.ZSQLInline(args=args):
+ logger("ImageArchiveMD:import", logging.INFO, "adding DB: %s"%file)
+ self.ZSQLAdd(args=args)
+
#print ret
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
#print self.ImageStoragePath
@@ -1908,7 +1997,7 @@ class ImageCollectionMD(ImageCollection,
self.scaleWorkingVersions()
- self.scaleToJpgs()
+ #self.scaleToJpgs()
if RESPONSE:
RESPONSE.redirect('manage_main')
@@ -1992,6 +2081,7 @@ class ImageCollectionMD(ImageCollection,
rc=[]
fnIds={}
+
for found in self.ZSQLInlineSearch(args=self.REQUEST.form):
key=getattr(found,self.imageCollectionConfig.getKey())
key=self.getImageByName(key,onlyName="yes")
@@ -2025,7 +2115,7 @@ class ImageCollectionMD(ImageCollection,
def index_html(self,fn=None,selection=None,generic='No',REQUEST=None,RESPONSE=None):
"""main template collection"""
-
+ logTime("index_html %s"%self.REQUEST['QUERY_STRING'])
mode=self.REQUEST.get('mode','view')
if fn:
ret=[]
@@ -2176,13 +2266,19 @@ class ImageCollectionMD(ImageCollection,
def thumblistMD(self):
"""main template collection"""
+ logTime("thumbList MD %s"%self.REQUEST['QUERY_STRING'])
+
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbListMD.zpt')).__of__(self)
+ self.REQUEST.RESPONSE.setHeader('Cache-Control','max-age=3600')
+ self.REQUEST.RESPONSE.setHeader('Last-Modified',self.bobobase_modification_time().toZone('GMT').rfc822())
return pt()
+
def getRights(self,id):
"""get the rights from a database"""
#print self.rightsQuery%id
results=self.ZSQLSimpleSearch(self.getRightsQuery()%id)
+ logging.error("rightsQuery: %s"%(self.getRightsQuery()%id))
if results:
result = getattr(results[0],self.getRightsQueryField())
else:
@@ -2194,6 +2290,9 @@ class ImageCollectionMD(ImageCollection,
#return url
url=urllib.unquote(url)
+
+ url=url.replace(" ","+") # ersetze Leerzeichen in der URL durch "+"
+ print url
xmldoc=urllib.urlopen(url).read()
#return xmldoc
try:
@@ -2209,7 +2308,7 @@ class ImageCollectionMD(ImageCollection,
for imagename in imagenames:
#imagename=image.xpath('./imagename')[0]
- #print "im",imagename
+ #print "im",imagename
@@ -2232,9 +2331,9 @@ class ImageCollectionMD(ImageCollection,
texts=getText(imagename.childNodes).split("\n") #mehrere bilder in return getrennter liste
for text in texts:
if not text=="":
- #print "a"
+ #print "a"
text=self.getImageByName(text,onlyName="yes")
- #print "b"
+ #print "b"
try:
rc.append((str(text),id,nop))
fnIds[str(text)]=(id,nop)
@@ -2255,9 +2354,7 @@ class ImageCollectionMD(ImageCollection,
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)
return pt()
- pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selectedMD.zpt')).__of__(self)
- return pt()
-
+
def selection(self):
"""show only selected"""
if self.REQUEST.has_key('filename'):
@@ -2278,9 +2375,9 @@ def manage_AddImageCollectionMDForm(self
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionFormMD.zpt')).__of__(self)
return pt()
-def manage_AddImageCollectionMD(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):
+def manage_AddImageCollectionMD(self,id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath,RESPONSE=None):
"""Add ImageCollection"""
- newObj=ImageCollectionMD(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)
+ newObj=ImageCollectionMD(id,title,ImageViewerPath,defaultMetaString,destBasis,srcBasis,serverPath)
self._setObject(id,newObj)
if RESPONSE is not None:
@@ -2418,7 +2515,7 @@ def manage_AddImageZogiLib(self,id=None,
self._setObject(id,newObj)
getattr(self,id).caption=caption[0:]
if fileUpload:
- getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)
+ getattr(self,id).uploadImage(fileupload,self.getImageStoragePath())
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
@@ -2426,4 +2523,4 @@ def manage_AddImageZogiLib(self,id=None,
def manage_AddImageZogiLibForm(self):
"""to be done"""
-
\ No newline at end of file
+