--- ImageArchive/ImageArchive.py 2004/01/15 11:01:21 1.14
+++ ImageArchive/ImageArchive.py 2005/10/25 19:42:59 1.69
@@ -1,29 +1,274 @@
+genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config
+
+
+
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
-from Globals import Persistent
+from Globals import Persistent,package_home
from Acquisition import Implicit
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PageTemplates.PageTemplate import PageTemplate
+from xmlrpclib import ServerProxy
import re
import os
import os.path
import urllib
import xml.dom.minidom
+import operator
+import tempfile
+import shutil
+from types import *
+import time
+from threading import Thread
+import Queue
+import cgi
+
+from AccessControl import ClassSecurityInfo, getSecurityManager
+
+try:
+ from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
+except:
+ print "ZSQL Extend Folder nicht importiert"
+ print "Metadatendfolder funktioniert nicht!!!"
+
+
+
+try:
+ from Products.ECHO_content.ECHO_collection import ECHO_basis
+except:
+ print "ECHO Elements not imported"
+ class ECHO_basis:
+ """leer"""
+
+ manage_options=()
+
+
+tdir = "/mpiwg/temp/tmp/archivesImageServer/"
+#tdir="/tmp/archivesImageServer/"
+
+def splitPath(str):
+ str2=str.replace("\\","/")
+ return os.path.split(str2)[1]
def getText(nodelist):
rc = ""
for node in nodelist:
- if node.nodeType == node.TEXT_NODE:
+ if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
+def getTextFromNode(nodename):
+ nodelist=nodename.childNodes
+ rc = ""
+ for node in nodelist:
+ if node.nodeType == node.TEXT_NODE:
+ rc = rc + node.data
+ return rc
+
+class generateSet:
+ """generateSetThread"""
+
+
+ def __init__(self,filenames,filenamesIds,ImageViewerPath,ids,url,local=None,version="working"):
+ """init generateSet"""
+ self.filenames=filenames
+ self.filenamesIds=filenamesIds
+ self.ImageViewerPath=ImageViewerPath
+ self.ids=ids
+ self.local=local
+ self.url=url
+ self.version=version
+ self.done=None
+
+
+ def __call__(self):
+ """call generate Set"""
+
+ storeTempDir=tempfile.tempdir
+ tempfile.tempdir=tdir
+
+ tmpPath=tempfile.mktemp()
+ tmpZip=tempfile.mktemp()+".gtz"
+ tmpFn=os.path.split(tmpZip)[1]
+
+ if not os.path.exists(tempfile.tempdir):
+ os.mkdir(tempfile.tempdir)
+ if not os.path.exists(tmpPath):
+ os.mkdir(tmpPath)
+
+ self.response=""
+
+
+ self.response="
1. step: getting the images "
+
+ for id in self.filenames:
+
+ if self.filenamesIds.has_key(id[0]):
+ filename=self.filenamesIds[id[0]][0]+"_"+id[0]
+ else:
+ filename=id[0]
+
+ self.response+=str("Get File: %s \n"%filename)
+
+
+ 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]
+ targetPath=tmpPath+"/"+filename
+ try:
+ shutil.copyfile(sourcePath,targetPath)
+ except:
+ self.response+=(str("
Error in File: %s (possible missing) \n"%filename))
+ else:
+ if self.version=="working":
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&dh=2000&dw=2000"
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+ else:
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(urllib.quote(id[0]))[0]+"&mo=rawfile,hires"
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+
+ image=urllib.urlopen(path).read()
+
+
+ fh=file(tmpPath+"/"+filename,"w")
+
+
+ fh.write(image)
+ fh.close()
+
+ #folgeseiten
+
+ if int(self.filenamesIds[id[0]][1])>1:
+ #ids=self.show_thumbs()
+
+ try:
+ nr=self.ids.index(id[0])
+ except:
+ self.response+=str("
Error in File: %s (possible missing) \n"%id[0])
+
+
+ nr=0
+
+ numberOfPages=self.filenamesIds[id[0]][1]
+ for k in range(int(numberOfPages)-1):
+ i=k+1
+ if self.filenamesIds.has_key(id[0]):
+ filename=self.filenamesIds[id[0]][0]+"_"+self.ids[nr+i]
+ else:
+ filename=id[0]
+
+ self.response+=str("
Get File: %s \n"%filename)
+
+ if self.local:
+ sourcePath="/mpiwg/online/"+self.ImageViewerPath+"/"+self.ids[nr+i]
+ targetPath=tmpPath+"/"+filename
+ try:
+ shutil.copyfile(sourcePath,targetPath)
+
+ except:
+ self.response+=str("
Error in File: %s (missing?) \n"%filename)
+
+ else:
+
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(ids[nr+i])[0]+"&mo=rawfile,hires"
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+ image=urllib.urlopen(path).read()
+
+
+ fh=file(tmpPath+"/"+filename,"w")
+ fh.write(image)
+ fh.close()
+
+ self.response+="
2. step: creating the downloadable file "
+ self.response+="Create gtar "
+ self.response+="
This can take a while.... \n"
+
+ fh=os.popen2("gnutar zcvf %s %s/*"%(tmpZip,tmpPath),1)[1]
+ self.response+=" "
+ for c in fh.read():
+ self.response+=c
+ if c==")":
+ self.response+=" \n"
+
+
+
+
+ shutil.rmtree(tmpPath)
+
+ self.response+="
finished \n"
+
+ len=os.stat(tmpZip)[6]
+ downloadUrl=self.url+"/downloadSet"
+ self.response+="""
\n"""%(tmpFn,len)
+ self.response+="""The file will be stored for a while, you can download it later, the URL is:
+ %s?fn=%s \n"""%(tmpFn,downloadUrl,tmpFn)
+
+ self.done=True
+ def getResult(self):
+ """get result"""
+ return self.response
+
+ def isDone(self):
+ if self.done:
+ return True
+ else:
+ return False
+
+class metaData(SimpleItem):
+ """Klasse fuer metadaten"""
+ meta_type="metaData"
+
+ def __init__(self,xmlurl,container=None):
+ """__init__"""
+ return self.update(xmlurl,container)
+
+
+ def update(self,xmlurl,container=None):
+ """update"""
+
+ try:
+ xmlfh=urllib.urlopen(xmlurl)
+ dom=xml.dom.minidom.parse(xmlfh)
+ except:
+ return None
+
+ md=dom.getElementsByTagName(container)
+ mlist=[]
+ if md:
+ for node in md[0].childNodes:
+ if node.nodeType==dom.ELEMENT_NODE:
+ name=node.tagName
+ content=getTextFromNode(node)
+ setattr(self,name,content)
+ mlist.append(name)
+ self.mlist=mlist[0:]
+ else:
+ self.mlist=[]
+
+ def index_html(self):
+ """index"""
+ ret="
"
+ for tag in self.mlist:
+ ret+="%s=%s
"%(tag,getattr(self,tag))
+ return ret+""
+
+
+
+
class ImageDigilib(Folder,Persistent,Implicit):
"""Anzeige object fuer digilib"""
meta_type="ImageDigilib"
-
+ security=ClassSecurityInfo()
leiden_meta_fields=['image_id','date','country','place','people','description','photographer']
manage_options = Folder.manage_options+(
@@ -32,14 +277,37 @@ class ImageDigilib(Folder,Persistent,Imp
)
+ def getAccessRight(self):
+ """get the accessright, return is string "extern" or "intern" """
+ return self.getRights(self.filename.split('.')[0])
+
+
+ def isAccessible(self):
+ """gives true if obejct is accessible taking the rights of the user into account"""
+
+ #TODO: implement rights, currently true if external and false if internal, and true if user has role authenticated
+
+ username=self.REQUEST['AUTHENTICATED_USER']
+ #print username
+ #print self.acl_users.getUserNames()
+ user=getSecurityManager().getUser()
+
+ roles=user.getRoles()
+ if 'Authenticated' in roles:
+ return True
+
+ if self.getAccessRight()=="extern":
+ return True
+ else:
+ return False
+
def addMetaObject(self,id,RESPONSE=None):
"""Add an MetaObject"""
objectType=getattr(self.Control_Panel.Products.ImageMetaData,self.genericMetaDataType)
request=self.REQUEST
objectCreate=objectType.createObjectManager(id,request)
- #for field in self.leiden_meta_fields:
- # self.REQUEST[field]=argv[field]
+
self._setObject(id,objectCreate)
objectCreate.propertysheets.meta.manage_editProperties(request)
@@ -52,7 +320,7 @@ class ImageDigilib(Folder,Persistent,Imp
def addMetaObjectForm(self):
"""Add Form"""
- pt=PageTemplateFile('Products/ImageArchive/addMetaObject.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMetaObject.zpt')).__of__(self)
return pt()
@@ -62,71 +330,269 @@ class ImageDigilib(Folder,Persistent,Imp
self.filename=filename
self.meta=meta
+
def getMeta(self):
"""ausgabe der metadaten"""
return self.meta
-
+
+ def manageMetaData(self,strict=None):
+ """create or updateMetadata"""
+
+ md=self.ZopeFind(self,obj_metatypes=["metaData"])
+
+ if not md:
+ self._setObject("metaData",metaData(self.meta,"ROW"))
+
+ else:
+ if not strict:
+ md[0][1].update(self.meta,"ROW")
+ else:
+ print "strict"
+ if len(md[0][1].mlist)==0:
+ print " +++",self.getId()
+ md[0][1].update(self.meta,"ROW")
+ else:
+ print " ---",self.getId()
+
def uploadImage(self,fileupload,path_name):
"""upload an Image from an Requast"""
#path_name=self.ImageStoragePath
- filename=path_name+"/"+fileupload.filename
+ fn=splitPath(fileupload.filename)
+ filename=path_name+"/"+fn
filedata=fileupload.read()
f=open(filename,"w")
f.write(filedata)
f.close()
- os.chmod(filename,0644)
- os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 100 &"% self.ImageViewerPath)
+ try:
+ os.chmod(filename,0664)
+ except:
+ """hack"""
+ #scale thumb
+
+ self.scaleThumbs()
-
+ #scale standard
+
+ self.scaleWorkingVersions()
-
- def download(self):
- """download"""
- path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&mo=rawfile,highres"
- #self.REQUEST.SESSION['string']=" "% path
- #pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self)
- return self.REQUEST.RESPONSE.redirect(path)
+
+ def downloadWorkingVersion(self):
+ """download working version (2000 pixel)"""
+
+ return self.download(fmt="&dw=2000&dh=2000",suffix=".jpg")
- def thumb(self):
- """show thumb"""
- thumbname=os.path.splitext(self.filename)[0]+".jpg"
- ## if not os.path.exists("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname):
-## image=urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:18080/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&dw=150&mo=lores").read()
-## f=open("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname,"w")
-## f.write(image)
-## f.close()
-## os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 150 &"% self.ImageViewerPath)
+ def download(self,fmt="&mo=rawfile,hires",suffix=None):
+ """download"""
+
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+fmt
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+
+ if self.REQUEST.SESSION.has_key('filenamesIds') and self.REQUEST.SESSION['filenamesIds'].has_key(self.filename):
+ filename=self.REQUEST.SESSION['filenamesIds'][self.filename][0]+"_"+self.filename
+ else:
+ filename=self.filename
+
+ if suffix:
+ filename=os.path.splitext(filename)[0]+suffix
+
+ self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename="%s" """%filename)
+ self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")
+ #print path
+ imagefh=urllib.urlopen(path,'rb')
+
+ self.REQUEST.RESPONSE.write(imagefh.read())
+ self.REQUEST.RESPONSE.close()
+ #return self.REQUEST.RESPONSE.redirect(path)
+
+ def updateImageForm(self):
+ """form"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','upDateImageForm.zpt')).__of__(self)
+ return pt()
+
+
+ security.declareProtected('View management screens','renameImageForm')
+ def renameImageForm(self):
+ """form"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','renameImageForm.zpt')).__of__(self)
+ return pt()
+
+ security.declareProtected('View management screens','renameImage')
+ def renameImage(self,newname,RESPONSE=None):
+ """umbenennen"""
+ #umbennen des files im folder
+ oldname=self.getId()
+ self.aq_parent.manage_renameObjects(ids=[oldname],new_ids=[newname])
+ 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)
+ os.rename(oldpath,newpath)
+
+ #umbenennen des versionsfolders
+ oldfolder=os.path.join(self.ImageStoragePath,"."+oldname+".dir")
+ newfolder=os.path.join(self.ImageStoragePath,"."+newname+".dir")
+ if os.path.exists(oldfolder):
+ os.rename(oldfolder,newfolder)
+ else:
+ os.mkdir(newfolder)
+
+ #schreibe info uber umbennenung
+
+ renameName=os.path.join(newfolder,"renamed")
+ if os.path.exists(renameName):
+ fh=file(renameName,'a')
+ else:
+ fh=file(renameName,'w')
+
+ tm=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
+ try:
+ user=self.REQUEST['AUTHENTICATED_USER']
+ except:
+ user="unknown"
+
+ str="""%s %s %s %s\n"""%(tm,user,oldname,newname)
+ fh.write(str)
+ fh.close()
- #DEVEL:take nausikaa for server solution
+ #scale thumb
- path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&dw=100&dh=100&mo=lores"
- #path="/mpiwg/online/"+self.ImageViewerPath+"/"+thumbname
+ self.scaleThumbs()
+
+ #scale standard
+
+ self.scaleWorkingVersions()
+
+
+ if RESPONSE:
+ RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
+
+
+ def updateImage(self,file,rename=None,RESPONSE=None):
+ """lade neues Version des Bildes"""
+ #teste ob Dokumenten ordner schon vorhanden
+ imagePath=os.path.join(self.ImageStoragePath,self.getId())
+ path=os.path.join(self.ImageStoragePath,"."+self.getId()+".dir")
+
+ if not os.path.exists(path):
+ os.mkdir(path,0775)
+ os.chmod(path,0775)
+
+ versionNumber=getattr(self,'versionNumber',0)+1
+
+ #teste ob version schon existiert
+
+ while os.path.exists(os.path.join(path,"V%i_%s"%(versionNumber,self.getId()))):
+ versionNumber+=1
+
+ #kopieren der bestehenden Version in den Versions ordner.
+ imageNewPath=os.path.join(path,"V%i_%s"%(versionNumber,self.getId()))
+ os.rename(imagePath,imageNewPath)
+
+ #lesen des upload files und schreiben
+ filedata=file.read()
+ f=open(imagePath,"w")
+ f.write(filedata)
+ f.close()
+ try:
+ os.chmod(imagePath,0664)
+ except:
+ """hack"""
+ #scale thumb
+
+ self.scaleThumbs()
+
+ #scale standard
+
+ self.scaleWorkingVersions()
+
+ if rename:
+ self.renameImage(file.filename)
+
+
+ if RESPONSE:
+ RESPONSE.redirect(self.aq_parent.absolute_url()+"?filename="+self.filename)
+
+
+ return "done"
+
+ def thumb(self,url=None):
+ """show thumb"""
+ thumbname=os.path.splitext(self.filename)[0]+".jpg"
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores"
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+
self.REQUEST.SESSION['string']=" "% path
- pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self)
- return pt()
+ if url:
+ return " "% path
+ else:
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumb.zpt')).__of__(self)
+ return pt()
+
+
+ def thumbMD(self,url=None):
+ """show thumb mit Metadaten erwarten image in ImageCollectionMD
+ """
+ thumbname=os.path.splitext(self.filename)[0]+".jpg"
+
+ requestString=self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores"
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString
+
+
+ self.REQUEST.SESSION['string']=" "% path
+ if url:
+ return " "% path
+ else:
+
+ overview=self.ZopeFind(self.aq_parent,obj_ids=['thumb.html'])
+ if overview:
+ return getattr(self,overview[0][0])()
+ else:
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbMD.zpt')).__of__(self)
+ return pt()
+
+
+ def image(self,dw=None,dh=None):
+ """show image only with scaler"""
+ str=[]
+ if (not dw) and (not dh):
+ str.append("mo=file")
+ if dw:
+ str.append("dw=%s"%dw)
+
+ if dh:
+ str.append("dw=%s"%dh)
+
+ str.append("lv=2&fn=%s"%self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0])
+
+
+ requestString="&".join(str)
+
+ self.REQUEST.RESPONSE.redirect(getattr(self,'serverPath',genericServerPath)+"/scaledImage?"+requestString)
+
def index_html(self):
- """show image"""
+ """show image with zogilib"""
#DEVELOP: take first one for server
-
- path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/digilib.jsp?fn="+self.ImageViewerPath+"/"+self.filename
-
- #path="http://localhost:8080/mpiwg/online/"+self.ImageViewerPath+"/"+self.filename
- #self.REQUEST.SESSION['string']=" "% path
- #pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self)
+ #path="http://127.0.0.1:8080/zogilib_images?lv=2&fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]
+ path=getattr(self,'serverPath',genericServerPath)+"?lv=2&fn="+self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]
return self.REQUEST.RESPONSE.redirect(path)
def manage_AddImageDigilibForm(self):
"""Nothing yet"""
- pt=PageTemplateFile('Products/ImageArchive/AddImageDigilibForm.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageDigilibForm.zpt')).__of__(self)
return pt()
def manage_AddImageDigilib(self,id,fileupload,meta=None,RESPONSE=None):
"""Add ImageCollection"""
+
#fileupload=self.REQUEST['fileupload']
- newObj=ImageDigilib(id,fileupload.filename,meta)
+ fn=splitPath(fileupload.filename)
+ newObj=ImageDigilib(id,fn,meta)
self._setObject(id,newObj)
getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)
@@ -135,10 +601,20 @@ def manage_AddImageDigilib(self,id,fileu
RESPONSE.redirect('manage_main')
-class ImageCollection(Folder, Persistent, Implicit):
- """Sammelordner für Bilder"""
+
+class ImageCollection(Folder, Persistent, Implicit,ECHO_basis):
+ """Sammelordner fuer Bilder"""
meta_type="ImageCollection"
+
+ security=ClassSecurityInfo()
+
+ #scalerPath="http://127.0.0.1:18080/digitallibrary/servlet/Scaler/?fn="
+ #scalerPath="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="
+
+ zipThreads={}
+ zipThreads2={}
+
genericMetaDataType="leiden_meta"
leiden_meta_fields=['image_id','date','country','place','people','description','photographer']
@@ -146,33 +622,169 @@ class ImageCollection(Folder, Persistent
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
- def scaleThumbs(self):
+ def getServerPath(self):
+ """get Server path"""
+ return getattr(self,'serverPath',genericServerPath)
+
+ def getScalerPath(self):
+ """get ScalerPath"""
+ path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="
+
+ def getImageViewerPath(self):
+ """get ImageViewerPath"""
+ return self.ImageViewerPath
+
+ def getImageStoragePath(self):
+ """get ImageStoragePath"""
+ return self.ImageStoragePath
+
+ def refreshTxt(self):
+ """txt fuer refresh"""
+ tn=self.REQUEST.SESSION['threadName']
+ return """ 2;url=%s?repeat=%s """%(self.absolute_url()+"/createSet",tn)
+
+ def createSet(self,RESPONSE=None,local=None,version="working",repeat=None):
+ """download aller gewaehlten files"""
+
+ threadName=repeat
+
+
+ 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)
+ thread=Thread(target=threadStart)
+
+ thread.start()
+
+
+ self.zipThreads[thread.getName()[0:]]=threadStart
+ self.zipThreads2[thread.getName()[0:]]=thread
+ self.REQUEST.SESSION['threadName']=thread.getName()[0:]
+ wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['zip_wait_template'])
+ if wait_template:
+ return wait_template[0][1]()
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','zip_wait.zpt')).__of__(self)
+ return pt()
+ #xmltrans.run()
+ else:
+ self.REQUEST.SESSION['threadName']=threadName
+
+ if (self.zipThreads[threadName].getResult()==None):
+
+ wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
+ if wait_template:
+ return wait_template[0][1]()
+
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','zip_wait.zpt')).__of__(self)
+ return pt()
+ else:
+ if self.zipThreads[threadName].isDone():
+ self.REQUEST.SESSION['result']=self.zipThreads[threadName].getResult()
+ self.zipThreads2[threadName].join()
+ del(self.zipThreads2[threadName])
+ del(self.zipThreads[threadName])
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','zip_result.zpt')).__of__(self)
+ return pt()
+
+ else:
+ self.REQUEST.SESSION['result']=self.zipThreads[threadName].getResult()
+ self.REQUEST.SESSION['threadName']=threadName
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','zip_wait_result.zpt')).__of__(self)
+ return pt()
+
+
+
+
+
+ def checkThreads(self):
+ """teste running threads"""
+ ret="""
+
+ Threads of %s """%(self.absolute_url(),self.getId())
+
+ for threadName in self.zipThreads.keys():
+ if self.zipThreads2[threadName].isAlive():
+ ret+="%s --> alive
"%threadName
+ else:
+ ret+="%s --> dead
"%threadName
+ return ret+""
+
+ def downloadSet(self,fn):
+ """download prepared set"""
+ filename=os.path.join(tdir,fn)
+
+
+ self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename="%s" """%"image.tgz")
+ self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")
+ len=os.stat(filename)[6]
+ self.REQUEST.RESPONSE.setHeader("Content-Length",len)
+ images=file(filename).read()
+ self.REQUEST.RESPONSE.write(images)
+ self.REQUEST.RESPONSE.close()
+
+
+
+ def scaleThumbs(self,RESPONSE=None):
"""scale thumbs"""
- os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 100 &"% self.ImageViewerPath)
+
+ #scale thumbs
+ 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")
+
return "RESCALING STARTED"
+
+ def scaleWorkingVersions(self,RESPONSE=None):
+ """scale working versions"""
+
+ #scale standard
+
+ 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:
+ RESPONSE.write(ret.read())
+ RESPONSE.write("\n")
+ return "rescaling started"
+
+
- def __init__(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString):
+ def __init__(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath=genericServerPath):
self.id=id
self.title=title
self.ImageStoragePath=ImageStoragePath
self.ImageViewerPath=ImageViewerPath
self.defaultMetaString=defaultMetaString
+ self.serverPath=serverPath
- manage_options = Folder.manage_options+(
+ optTMP= Folder.manage_options
+
+ manage_options = optTMP+(
{'label':'Main Config','action':'ImageCollection_config'},
{'label':'Import','action':'ImportFiles'},
- {'label':'Recalculate Metadata','action':'recalculateMeta'},
- {'label':'Import Metadata','action':'importMetaForm'},
+ {'label':'Recalculate MetadataLink','action':'recalculateMetaLink'},
+ {'label':'Import Metadata File','action':'importMetaFileForm'},
+ {'label':'Import Metadata','action':'importMetaData'},
{'label':'Rescale thumbs','action':'scaleThumbs'},
+ {'label':'Rescale working version','action':'scaleWorkingVersions'},
)
+
+
+ def importMetaData(self,strict=None):
+ """import metadata, if strict ist not None then only metadata will be rebuild where metadata is empty"""
+
+ for image in self.ZopeFind(self,obj_metatypes=["ImageDigilib"]):
+ print image[1].getId()
+ image[1].manageMetaData(strict)
+ return "ok"
+
- def importMetaForm(self):
+ def importMetaFileForm(self):
"""import metadata"""
- pt=PageTemplateFile('Products/ImageArchive/importMeta.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importMeta.zpt')).__of__(self)
return pt()
- def importMeta(self,fileupload,tag):
+ def importMetaFile(self,fileupload,tag):
"""import"""
filedata=fileupload.read()
dom=xml.dom.minidom.parseString(filedata)
@@ -206,7 +818,7 @@ class ImageCollection(Folder, Persistent
return "OK"
- def nextImage(self,request,selected=None):
+ def nextImage(self,request,selected=None,returnFn=None):
"""show nextimage"""
try:
ids=self.show_thumbs()
@@ -214,14 +826,18 @@ class ImageCollection(Folder, Persistent
filename=request.SESSION["filename"]
try:
nr=ids.index(filename)
+
except:
nr=0
else:
nr=0
if nr==len(ids)-1:
- return ""
+ return ""
else:
+ if returnFn:
+ return ids[nr+1]
+
if selected:
return "next image "
else:
@@ -255,7 +871,7 @@ class ImageCollection(Folder, Persistent
def meta_default(self,filename):
"""url der metadaten"""
- return self.defaultMetaString % filename
+ return self.defaultMetaString % urllib.quote(filename)
def getThumbAttribute(self,id,attr):
if hasattr(self,id):
@@ -271,26 +887,52 @@ class ImageCollection(Folder, Persistent
def xmlinput(self,url):
- """Anzeige von ausgewaehlten thumbs"""
+ """Anzeige 0) and (splitted[1][0]=="."):
+## 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)):
+ imageStoragePath=os.path.join(self.ImageStoragePath,file)
+ imageViewerPath=os.path.join(self.ImageViewerPath,file)
+ manage_AddImageCollection(self,file,file,imageStoragePath,imageViewerPath,self.defaultMetaString)
+
+ obj=getattr(self,file)
+ obj.ImportStructure()
+ else:
+ if not file[0]==".":
+ if self.__dict__.has_key(file):
+
+ ret=ret+" "+file+" already exists!"
+ else:
+ ret=ret+" "+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):
"""Import the existing files of a folder"""
@@ -365,34 +1079,45 @@ class ImageCollection(Folder, Persistent
except:
"""nothing yet"""
#print ret
- #pt=PageTemplateFile('Products/ImageArchive/out.zpt').__of__(self)
+ #pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self)
#print self.ImageStoragePath
- os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 100 &"% self.ImageStoragePath)
- RESPONSE.redirect('manage_main')
+
+ #scale thumb
+
+ self.scaleThumbs()
+
+ #scale standard
+
+ self.scaleWorkingVersions()
+
+ if RESPONSE:
+ RESPONSE.redirect('manage_main')
def ImageCollection_config(self):
"""Nothing yet"""
if not hasattr(self,'defaultMetaString'):
self.defaultMetaString=""
- pt=PageTemplateFile('Products/ImageArchive/ChangeImageCollectionForm.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','ChangeImageCollectionForm.zpt')).__of__(self)
return pt()
- def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):
+ def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath,RESPONSE=None):
"""Change"""
self.title=title
self.ImageStoragePath=ImageStoragePath
self.ImageViewerPath=ImageViewerPath
self.defaultMetaString=defaultMetaString
+ self.serverPath=serverPath
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
def show_selected_thumbs(self):
#ids=[]
-
- return self.REQUEST.SESSION['filenames']
-
+ try:
+ return self.REQUEST.SESSION['filenames']
+ except:
+ return None
def show_thumbs(self):
ids=[]
for entry in self.__dict__:
@@ -490,10 +1215,113 @@ class ImageCollection(Folder, Persistent
return "previous sets "
else:
return ""
+ def showFolders(self):
+ """show subfolders"""
+ ret=""
+ link=""" %s """
+
+ if self.aq_parent.meta_type=="ImageCollection":
+ ret+=link%(self.aq_parent.absolute_url(), "back ("+self.aq_parent.title+")")
+ ret+=" "
+ iCs=self.ZopeFind(self,obj_metatypes=["ImageCollection"])
+ if not iCs:
+ return ret
+ else:
+
+ link=""" %s """
+ for iC in iCs:
+ ret+=link%(iC[1].absolute_url(),iC[0])
+ ret+=" "
+ return ret
+ def showRuler(self,selected=None):
+ """show ruler"""
+ showall =self.REQUEST.SESSION.get('showall','no')
+ ids=self.show_thumbs()
+ if len(ids)==0:
+ return "No entries "
+
+ if showall=='no':
+ actualNr=0
+ ids=self.show_thumbs()
+ colRows=self.getColTimesRow()
+ num=int(len(ids)/(colRows[0]*colRows[1]))
+ if not (operator.mod(len(ids),colRows[0]*colRows[1])==0):
+ num+=1
+ a=colRows[0]*colRows[1]
+ #print num,num+1
+
+ if num>1:
+
+ ret=""
+ if selected:
+ ret+=""""""
+ else:
+ ret+=""""""
+ for i in range(num):
+ try:
+ nr=ids.index(self.REQUEST.SESSION['filename'])
+ except:
+ nr=0
+ k=i*a
+ if (k <= nr) and (nr < i*(a+1)):
+ actualNr=i
+ ret+="""%i """%(ids[k],i)
+ else:
+ ret+="""%i """%(ids[k],i)
+ ret+=" "
+ anf="Show thumbnail group no: "
+
+
+ try:
+ if selected:
+ href=self.REQUEST['URL1']+"/selection?filename="+ids[(actualNr-1)*a]
+ else:
+ href=self.REQUEST['URL1']+"?filename="+ids[int((actualNr-1)*a)]
+
+ anf+="""%s """%(href,"prev")
+ except:
+ pass
+ ret=anf+ret
+
+ 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="""%s """%(href,"next")
+ except:
+ end=""
+ ret=ret+end
+
+
+ #for i in range(num):
+ #
+ # ret +=" " #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+="""%i """%(href,i)
+
+ else:
+ ret=""
+ ret+="""show all """%self.REQUEST['URL1']
+ else:
+ ret="""show groups """%self.REQUEST['URL1']
+
+ return ret
+
def show_thumbs_selected_rows(self,numberOfColumns):
"""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)
@@ -501,13 +1329,13 @@ class ImageCollection(Folder, Persistent
def setColTimesRowForm(self):
"""form for matrix setting"""
- pt=PageTemplateFile('Products/ImageArchive/selectColTimesRow.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','selectColTimesRow.zpt')).__of__(self)
return pt()
def setDone(self):
"""done"""
- pt=PageTemplateFile('Products/ImageArchive/changedColTimesRow.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changedColTimesRow.zpt')).__of__(self)
return pt()
def setColTimesRow(self,cols,rows):
@@ -524,7 +1352,7 @@ class ImageCollection(Folder, Persistent
RESPONSE.redirect(self.REQUEST['URL1']+"/setDone")
- def getColTimesRow(self):
+ def getColTimesRow(self,showall='No'):
"""coltimesrow"""
REQUEST=self.REQUEST
@@ -534,54 +1362,68 @@ class ImageCollection(Folder, Persistent
try:
rows=int(REQUEST.cookies["ImageViewerRows"])
except:
- rows=None
+ rows=6
else:
- rows=None
+ rows=6
if REQUEST.cookies.has_key("ImageViewerCols"):
#print "COLS",REQUEST.cookies["ImageViewerCols"]
cols=int(REQUEST.cookies["ImageViewerCols"])
else:
- cols=4
+ cols=2
idsnumber=len(self.show_thumbs())
if rows:
if cols*rows >idsnumber:
rows=int(idsnumber/cols)+1
+
+ #print cols,rows
+ if showall=='yes':
+ rows=int(idsnumber/cols)+1
+
return (cols,rows)
- def show_thumbs_rows(self,numberOfColumns,numberOfRows=None,startId=None):
+ def show_thumbs_rows(self,numberOfColumns,numberOfRows=None,startId=None,showall="No"):
"""Ausgabe anzahl"""
idsAll=self.show_thumbs()
-
- if self.REQUEST.SESSION.has_key("filename"):
+ if len(idsAll)==0: #keine Einträge
+ return 0
+ if self.REQUEST.SESSION.has_key("filename") and not (showall=="yes"):
filename=self.REQUEST.SESSION["filename"]
+ filename=self.getImageByName(filename,onlyName="yes")
+
try:
startId=filename
+ if startId=="":
+ startId=idsAll[0][0:]
except:
- startId=idsAll[0]
+ startId=idsAll[0][0:]
else:
- startId=idsAll[0]
+ startId=idsAll[0][0:]
- print "NOR:",numberOfRows
+
if numberOfRows:
+
+ startPic=idsAll.index(startId)
try:
+
startPic=idsAll.index(startId)
endPic=startPic+numberOfColumns*numberOfRows
ids=idsAll[startPic:endPic]
except:
ids=idsAll
else:
+
ids=idsAll
-
+
self.REQUEST.SESSION['ids']=ids
number=int(len(ids)/numberOfColumns)+1
-
+
return range(number+1)
def show_thumbs_columns(self,row,numberOfColumns):
@@ -595,34 +1437,41 @@ class ImageCollection(Folder, Persistent
def thumblistSelected_old(self):
"""main template collection"""
- pt=PageTemplateFile('Products/ImageArchive/thumbselected.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected.zpt')).__of__(self)
return pt()
def thumblistSelected(self):
"""main template collection"""
- pt=PageTemplateFile('Products/ImageArchive/thumbselected2.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbselected2.zpt')).__of__(self)
return pt()
def thumblist_old(self):
"""main template collection"""
- pt=PageTemplateFile('Products/ImageArchive/thumbs.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbs.zpt')).__of__(self)
return pt()
def thumblist(self):
"""main template collection"""
- pt=PageTemplateFile('Products/ImageArchive/thumb2.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumb2.zpt')).__of__(self)
+ return pt()
+
+ def thumblistNewWindow(self):
+ """Thumbs mit clik neues Fenster oeffnen"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbNewWindow.zpt')).__of__(self)
return pt()
+
def navig_selected_html(self):
"""navigation"""
#self.REQUEST.SESSION['URL']=self.REQUEST['URL0']
- pt=PageTemplateFile('Products/ImageArchive/navigation_selected.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','navigation_selected.zpt')).__of__(self)
return pt()
def navig_html(self):
"""navigation"""
#self.REQUEST.SESSION['URL']=self.REQUEST['URL0']
- pt=PageTemplateFile('Products/ImageArchive/navigation.zpt').__of__(self)
+
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','navigation.zpt')).__of__(self)
return pt()
@@ -633,22 +1482,74 @@ class ImageCollection(Folder, Persistent
else:
filen=""
self.REQUEST.SESSION['filename']=filen
- pt=PageTemplateFile('Products/ImageArchive/overview_selected2.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selected2.zpt')).__of__(self)
return pt()
+
+ def getImageByName(self,filename,onlyName=None):
+ """get filename"""
- def index_html(self):
+ fn=getattr(self,filename,None)
+ if not fn:
+ filenameM=filename.split(".")[0]
+ founds=self.ZopeFind(self,obj_metatypes=['ImageDigilib'])
+ for found in founds:
+ foundM=found[0].split(".")[0]
+ if filenameM.lower()==foundM.lower():
+ if onlyName:
+ return found[0]
+ else:
+ return found[1]
+ if onlyName:
+ return filename
+ else:
+ return fn
+
+
+ security.declareProtected('View','index_html')
+ def index_html(self,fn=None):
"""main template collection"""
+
+ if fn:
+ ret=[]
+
+ if type(fn) is ListType:
+ """experimentell mehr als ein filename"""
+ for filename in fn:
+ if not (filename == ""):
+ ret.append((filename,'',1))
+ else:
+ ret.append((fn,'',1))
+
+ self.REQUEST.SESSION['filenames']=ret
+ #self.REQUEST.SESSION['filenamesIds']=fnIds
+
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selected.zpt')).__of__(self)
+ return pt()
+
if self.REQUEST.has_key('filename'):
filen=self.REQUEST['filename']
else:
filen=""
- self.REQUEST.SESSION['filename']=filen
- pt=PageTemplateFile('Products/ImageArchive/overview.zpt').__of__(self)
- return pt()
+
+ self.REQUEST.SESSION['filename']=filen[0:]
+
+ if self.REQUEST.has_key('showall'):
+
+ self.REQUEST.SESSION['showall']=self.REQUEST.get('showall')
+ else:
+ self.REQUEST.SESSION['showall']=self.REQUEST.SESSION.get('showall','no')
+
+
+ overview=self.ZopeFind(self,obj_ids=['overview.html'])
+ if overview:
+ return overview[0][1]()
+ else:
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview.zpt')).__of__(self)
+ return pt()
def manage_AddImageCollectionForm(self):
"""Nothing yet"""
- pt=PageTemplateFile('Products/ImageArchive/AddImageCollectionForm.zpt').__of__(self)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionForm.zpt')).__of__(self)
return pt()
def manage_AddImageCollection(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):
@@ -660,3 +1561,227 @@ def manage_AddImageCollection(self,id,ti
RESPONSE.redirect('manage_main')
+
+class ImageCollectionMD(ImageCollection,ZSQLExtendFolder):
+ """Imageviewer and Metadata"""
+ meta_type="ImageCollection MD"
+ #scalerPath="http://127.0.0.1:18080/digitallibrary/servlet/Scaler/?fn="
+ scalerPath="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="
+ rightsQueryDefault="SELECT accessibility from vision_main where id_image=(SELECT id from vision_images where filename ~ '%s*' )"
+ rightsQueryFieldDefault="accessibility"
+
+ manage_options=ImageCollection.manage_options+(
+ {'label':'ZSQLExtend','action':'changeZSQLExtendForm'},
+ {'label':'Change Rights Query','action':'changeRightsQueryForm'},
+ )
+
+ try:
+ changeZSQLExtendForm=ZSQLExtendFolder.changeZSQLExtendForm
+ except:
+ pass
+
+ def changeRightsQueryForm(self):
+ """change Rights Query"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','ChangeRightsQueryForm.zpt')).__of__(self)
+ return pt()
+
+ def changeRightsQuery(self,rightsQuery,rightsQueryField,RESPONSE=None):
+ """change Rightsquery"""
+
+ self.rightsQuery=rightsQuery
+ self.rightsQueryField=rightsQueryField
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+
+ def getRightsQuery(self):
+ """get Query"""
+ return getattr(self,'rightsQuery',self.rightsQueryDefault)
+
+ def getRightsQueryField(self):
+ """get Query Fiueld"""
+ return getattr(self,'rightsQueryField',self.rightsQueryFieldDefault)
+
+
+
+ def setGenericSearchStringForm(self):
+ """form setze generischen search string fuer MD"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','setGenericSearchStringForm.zpt')).__of__(self)
+ return pt()
+
+ def setGenericSearchString(self,searchString):
+ """setze generischen search string"""
+ self.searchString=searchString
+
+ def thumblistMD(self):
+ """main template collection"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumbListMD.zpt')).__of__(self)
+ return pt()
+
+ def getRights(self,id):
+ """get the rights from a database"""
+ #print self.rightsQuery%id
+ results=self.ZSQLSimpleSearch(self.getRightsQuery()%id)
+ if results:
+ result = getattr(results[0],self.getRightsQueryField())
+ else:
+ result = ''
+ return result
+
+
+def manage_AddImageCollectionMDForm(self):
+ """Nothing yet"""
+ 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):
+ """Add ImageCollection"""
+ newObj=ImageCollectionMD(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)
+ self._setObject(id,newObj)
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+
+
+class ImageCollectionIFrame(ImageCollection):
+ """Class fuer Collection set als IFrame"""
+
+ meta_type="ImageCollectionIFrame"
+ label=ImageCollection.title
+
+ def getImageTag(self):
+ """ hack : method needed by echo_content"""
+ return ""
+
+ def rotate(self,angle,url,RESPONSE):
+ """rotate"""
+
+ RESPONSE.redirect("javascript:document.domain='mpg.de';parent.iframe.right.rotation(%i)"%int(angle))
+ RESPONSE.redirect(url)
+ def request(self):
+ """request"""
+ return self.REQUEST
+
+ def index_html(self):
+ """index"""
+ if self.REQUEST.has_key('filename'):
+ filen=self.REQUEST['filename']
+ else:
+ filen=""
+ self.REQUEST.SESSION['filename']=filen
+
+
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','IFrameMain.zpt')).__of__(self)
+ return pt()
+
+ def iframe_html(self):
+ """iframe"""
+ if self.REQUEST.has_key('filename'):
+ filen=self.REQUEST['filename']
+ else:
+ filen=""
+ self.REQUEST.response.setCookie('filename',filen)
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','IFrameOverview.zpt')).__of__(self)
+ return pt()
+
+
+def manage_AddImageCollectionIFrameForm(self):
+ """Nothing yet"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddImageCollectionIFrameForm.zpt')).__of__(self)
+ return pt()
+
+def manage_AddImageCollectionIFrame(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None):
+ """Add ImageCollection"""
+ newObj=ImageCollectionIFrame(id,title,ImageStoragePath,ImageViewerPath,defaultMetaString)
+ self._setObject(id,newObj)
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+class ImageZogiLib(ImageDigilib):
+ """Anzeige Object fuer Bilder ausserhalb von collections
+ ImageViewerPath und ImageStoragePath und wenn vorhanden Pfad zur Collection
+ werden zusaetzlich abgespeichert
+ """
+ #TODO: scaler path notwendig?
+ meta_type="ImageZogiLib"
+
+ manage_options=ImageDigilib.manage_options+(
+ {'label':'Main Config','action':'changeImageZogiLibForm'},
+ )
+
+ def __init__(self,id,fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath=None,REQUEST=None):
+ ImageDigilib.__init__(self,id,fn)
+ self.ImageViewerPath=ImageViewerPath
+ self.ImageStoragePath=ImageStoragePath
+ self.ImageCollectionPath=ImageCollectionPath
+ self.scalerPath=scalerPath
+
+ def changeImageZogiLibForm(self):
+ """change zogilib Form"""
+ pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeImageZogiLib.zpt')).__of__(self)
+ return pt()
+
+
+ def changeImageZogilib(fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath,REQUEST=None):
+ """Change it"""
+ self.ImageViewerPath=ImageViewerPath
+ self.ImageStoragePath=ImageStoragePath
+ self.ImageCollectionPath=ImageColectionPath
+ self.scalerPath=scalerPath
+
+def manage_AddImageZogiLib(self,id=None,ImageViewerPath=None,ImageStoragePath=None,fileUpload=None,ImageCollectionPath=None,scalerPath=None,libPath=None,caption=None,RESPONSE=None):
+ """hinzufuegen eineis zogilibImage"""
+
+ if libPath:
+ splitted=libPath.split("?")
+ urlSplit=splitted[0].split("/")
+ params=cgi.parse_qs(splitted[1])
+ #is LibPath a digilib path?
+ if urlSplit[-1]=="Scaler":
+ if type(params['fn']) is ListType:
+ fnParam=params['fn'][0]
+ else:
+ fnParam=params['fn']
+ fileNameSplit=os.path.split(fnParam)
+ ImageViewerPath=fileNameSplit[0]
+ id=fileNameSplit[1]
+ scalerPath=splitted[0]+"?fn="
+ else: #assume if not the path is a path to an ImageCollection
+ if type(params['filename']) is ListType:
+ id=params['filename'][0]
+ else:
+ id=params['filename']
+
+ server=ServerProxy(splitted[0])
+ ImageCollectionPath=libPath
+ ImageViewerPath=server.getImageViewerPath()
+ ImageStoragePath=server.getImageStoragePath()
+ scalerPath=server.getScalerPath()
+
+
+
+ if fileUpload:
+ fn=splitPath(fileUpload.filename)
+ else:
+ fn=id
+
+ newObj=ImageZogiLib(id,fn,ImageViewerPath,ImageStoragePath,scalerPath,ImageCollectionPath)
+
+ self._setObject(id,newObj)
+ getattr(self,id).caption=caption[0:]
+ if fileUpload:
+ getattr(self,id).uploadImage(fileupload,self.ImageStoragePath)
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+def manage_AddImageZogiLibForm(self):
+ """to be done"""
+