--- ImageArchive/ImageArchive.py 2006/07/24 17:31:06 1.98
+++ ImageArchive/ImageArchive.py 2007/01/31 14:24:17 1.103
@@ -24,9 +24,18 @@ 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)
+
+
+
from AccessControl import ClassSecurityInfo, getSecurityManager
try:
@@ -499,7 +508,7 @@ class ImageDigilib(Folder,Persistent,Imp
self.scaleWorkingVersions()
- self.scaleToJpg()
+ #self.scaleToJpg()
if RESPONSE:
RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
@@ -518,12 +527,12 @@ class ImageDigilib(Folder,Persistent,Imp
newName=os.path.join(path,self.getId())
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()
@@ -564,10 +573,10 @@ 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))
+ #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()
@@ -757,14 +766,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:
@@ -774,12 +783,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
- #zLOG.LOG("ImageCollection:scale",zLOG.INFO,scaleStr)
+ #logger("ImageCollection:scale",logging.INFO,scaleStr)
ret=os.popen2(scaleStr,1)[1].read()
if RESPONSE:
@@ -1731,20 +1740,12 @@ class ImageCollection(OrderedFolder, Per
else:
return ids[(row-1)*numberOfColumns:]
- def thumblistSelected_old(self):
- """main template collection"""
- pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected.zpt')).__of__(self)
- return pt()
def thumblistSelected(self):
"""main template collection"""
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected2.zpt')).__of__(self)
return pt()
- def thumblist_old(self):
- """main template collection"""
- pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self)
- return pt()
def thumblist(self):
"""main template collection"""
@@ -1932,6 +1933,7 @@ class ImageCollectionMD(ImageCollection,
ret=ret+"
"+file+" already exists!"
else:
+ logger("ImageArchiveMD:import", logging.INFO, "adding ZOPE: %s"%file)
ret=ret+"
"+file+" created!"
newObj=ImageDigilib(file,file)
#print newObj,file
@@ -1941,13 +1943,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
@@ -1961,7 +1965,7 @@ class ImageCollectionMD(ImageCollection,
self.scaleWorkingVersions()
- self.scaleToJpgs()
+ #self.scaleToJpgs()
if RESPONSE:
RESPONSE.redirect('manage_main')
@@ -2045,6 +2049,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")
@@ -2247,6 +2252,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:
@@ -2308,9 +2316,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'):
@@ -2479,4 +2485,4 @@ def manage_AddImageZogiLib(self,id=None,
def manage_AddImageZogiLibForm(self):
"""to be done"""
-
\ No newline at end of file
+