version 1.12, 2004/01/06 16:47:49
|
version 1.75, 2006/02/07 20:29:31
|
Line 1
|
Line 1
|
|
genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config |
|
|
|
|
|
|
from OFS.Folder import Folder |
from OFS.Folder import Folder |
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from Globals import Persistent |
from Globals import Persistent,package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
|
from xmlrpclib import ServerProxy |
import re |
import re |
import os |
import os |
import os.path |
import os.path |
import urllib |
import urllib |
import xml.dom.minidom |
import xml.dom.minidom |
|
import operator |
|
import tempfile |
|
import shutil |
|
from types import * |
|
import time |
|
from threading import Thread |
|
import Queue |
|
import cgi |
|
import zLOG |
|
|
|
from AccessControl import ClassSecurityInfo, getSecurityManager |
|
|
|
try: |
|
from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder |
|
except: |
|
print "ZSQL Extend Folder nicht importiert" |
|
print "Metadatendfolder funktioniert nicht!!!" |
|
class ZSQLExtendFolder: |
|
"""leer""" |
|
manage_options=() |
|
|
|
|
|
|
|
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): |
def getText(nodelist): |
|
|
Line 19 def getText(nodelist):
|
Line 63 def getText(nodelist):
|
rc = rc + node.data |
rc = rc + node.data |
return rc |
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="<h3>1. step: getting the images</h3>" |
|
|
|
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("<p>Get File: %s<br>\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("<p>Error in File: %s (possible missing)<br>\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("<p>Error in File: %s (possible missing)<br>\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("<p>Get File: %s<br>\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("<p>Error in File: %s (missing?)<br>\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+="<h3>2. step: creating the downloadable file</h3>" |
|
self.response+="<p>Create gtar<br>" |
|
self.response+="<p>This can take a while....<br>\n" |
|
|
|
fh=os.popen2("gnutar zcvf %s %s/*"%(tmpZip,tmpPath),1)[1] |
|
self.response+="<br>" |
|
for c in fh.read(): |
|
self.response+=c |
|
if c==")": |
|
self.response+="<br>\n" |
|
|
|
|
|
|
|
|
|
shutil.rmtree(tmpPath) |
|
|
|
self.response+="<p>finished<br>\n" |
|
|
|
len=os.stat(tmpZip)[6] |
|
downloadUrl=self.url+"/downloadSet" |
|
self.response+="""<h1><a href="downloadSet?fn=%s">Click here for download ( %i Byte)</a></h1>\n"""%(tmpFn,len) |
|
self.response+="""<p>The file will be stored for a while, you can download it later, the URL is:</p> |
|
<p><a href="downloadSet?fn=%s">%s?fn=%s</a></h1>\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="<html><body>" |
|
for tag in self.mlist: |
|
ret+="<p>%s=%s</p>"%(tag,getattr(self,tag)) |
|
return ret+"</body></html>" |
|
|
|
|
|
|
|
|
class ImageDigilib(Folder,Persistent,Implicit): |
class ImageDigilib(Folder,Persistent,Implicit): |
"""Anzeige object fuer digilib""" |
"""Anzeige object fuer digilib""" |
meta_type="ImageDigilib" |
meta_type="ImageDigilib" |
|
security=ClassSecurityInfo() |
leiden_meta_fields=['image_id','date','country','place','people','description','photographer'] |
leiden_meta_fields=['image_id','date','country','place','people','description','photographer'] |
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
Line 32 class ImageDigilib(Folder,Persistent,Imp
|
Line 281 class ImageDigilib(Folder,Persistent,Imp
|
|
|
) |
) |
|
|
|
def getAccessRight(self): |
|
"""get the accessright, return is string "extern" or "intern" """ |
|
return self.getRights(self.filename.split('.')[0]) |
|
|
|
security.declarePublic('isAccessible') |
|
|
|
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): |
def addMetaObject(self,id,RESPONSE=None): |
"""Add an MetaObject""" |
"""Add an MetaObject""" |
objectType=getattr(self.Control_Panel.Products.ImageMetaData,self.genericMetaDataType) |
objectType=getattr(self.Control_Panel.Products.ImageMetaData,self.genericMetaDataType) |
|
|
request=self.REQUEST |
request=self.REQUEST |
objectCreate=objectType.createObjectManager(id,request) |
objectCreate=objectType.createObjectManager(id,request) |
#for field in self.leiden_meta_fields: |
|
# self.REQUEST[field]=argv[field] |
|
self._setObject(id,objectCreate) |
self._setObject(id,objectCreate) |
|
|
objectCreate.propertysheets.meta.manage_editProperties(request) |
objectCreate.propertysheets.meta.manage_editProperties(request) |
Line 52 class ImageDigilib(Folder,Persistent,Imp
|
Line 325 class ImageDigilib(Folder,Persistent,Imp
|
|
|
def addMetaObjectForm(self): |
def addMetaObjectForm(self): |
"""Add Form""" |
"""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() |
return pt() |
|
|
|
|
Line 62 class ImageDigilib(Folder,Persistent,Imp
|
Line 335 class ImageDigilib(Folder,Persistent,Imp
|
self.filename=filename |
self.filename=filename |
self.meta=meta |
self.meta=meta |
|
|
|
def getBasename(self): |
|
"""returns base filename (sans extension)""" |
|
return os.path.splitext(self.filename)[0] |
|
|
def getMeta(self): |
def getMeta(self): |
"""ausgabe der metadaten""" |
"""ausgabe der metadaten""" |
return self.meta |
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): |
def uploadImage(self,fileupload,path_name): |
"""upload an Image from an Requast""" |
"""upload an Image from an Requast""" |
#path_name=self.ImageStoragePath |
#path_name=self.ImageStoragePath |
filename=path_name+"/"+fileupload.filename |
fn = self.filename or splitPath(fileupload.filename) |
|
filename=path_name+"/"+fn |
filedata=fileupload.read() |
filedata=fileupload.read() |
f=open(filename,"w") |
f=open(filename,"w") |
f.write(filedata) |
f.write(filedata) |
f.close() |
f.close() |
os.chmod(filename,0644) |
self.filename = fn |
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 downloadWorkingVersion(self): |
|
"""download working version (2000 pixel)""" |
|
|
def download(self): |
return self.download(fmt="&dw=2000&dh=2000",suffix=".jpg") |
|
|
|
def download(self,fmt="&mo=rawfile,hires",suffix=None): |
"""download""" |
"""download""" |
path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&mo=rawfile,highres" |
|
#self.REQUEST.SESSION['string']="<img src=\"%s\">"% path |
|
#pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self) |
|
return self.REQUEST.RESPONSE.redirect(path) |
|
|
|
def thumb(self): |
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() |
|
|
|
#scale thumb |
|
|
|
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()) |
|
imagePath=os.path.join(self.ImageStoragePath,self.filename) |
|
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.filename))): |
|
versionNumber+=1 |
|
|
|
#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) |
|
except: |
|
zLOG.LOG("ImageArchive:updateImage", zLOG.ERROR, "rename: %s -> %s didn't work!"%(imagePath,imageNewPath)) |
|
|
|
#lesen des upload files und schreiben |
|
filedata=file.read() |
|
f=open(imagePath,"w") # if we wanted to have filename=id we should do it here! |
|
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" |
|
|
|
security.declarePublic('thumb') |
|
def thumb(self,url=None): |
"""show thumb""" |
"""show thumb""" |
thumbname=os.path.splitext(self.filename)[0]+".jpg" |
thumbname=os.path.splitext(self.filename)[0]+".jpg" |
## if not os.path.exists("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname): |
requestString=self.ImageViewerPath+"/"+os.path.splitext(self.filename)[0]+"&dw=100&dh=100&mo=lores" |
## image=urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:18080/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&dw=150&mo=lores").read() |
path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn="+requestString |
## f=open("/mpiwg/temp/online/scaled/small/"+self.ImageViewerPath+"/"+thumbname,"w") |
|
## f.write(image) |
|
## f.close() |
self.REQUEST.SESSION['string']="<img border=\"0\" src=\"%s\">"% path |
## os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/small 150 &"% self.ImageViewerPath) |
if url: |
|
return "<img border=\"0\" src=\"%s\">"% path |
#DEVEL:take nausikaa for server solution |
else: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','thumb.zpt')).__of__(self) |
path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?fn="+self.ImageViewerPath+"/"+self.filename+"&dw=100&dh=100&mo=lores" |
return pt() |
#path="/mpiwg/online/"+self.ImageViewerPath+"/"+thumbname |
|
self.REQUEST.SESSION['string']="<img width=100 border=\"0\" src=\"%s\">"% path |
|
pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self) |
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']="<img border=\"0\" src=\"%s\">"% path |
|
if url: |
|
return "<img border=\"0\" src=\"%s\">"% 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() |
return pt() |
|
|
def index_html(self): |
|
"""show image""" |
|
#DEVELOP: take first one for server |
|
|
|
path="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/digilib.jsp?fn="+self.ImageViewerPath+"/"+self.filename |
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) |
|
|
#path="http://localhost:8080/mpiwg/online/"+self.ImageViewerPath+"/"+self.filename |
self.REQUEST.RESPONSE.redirect(getattr(self,'serverPath',genericServerPath)+"/scaledImage?"+requestString) |
#self.REQUEST.SESSION['string']="<img src=\"%s\">"% path |
|
#pt=PageTemplateFile('Products/ImageArchive/thumb.zpt').__of__(self) |
def index_html(self): |
|
"""show image with zogilib""" |
|
#DEVELOP: take first one for server |
|
#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) |
return self.REQUEST.RESPONSE.redirect(path) |
|
|
|
|
def manage_AddImageDigilibForm(self): |
def manage_AddImageDigilibForm(self): |
"""Nothing yet""" |
"""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() |
return pt() |
|
|
def manage_AddImageDigilib(self,id,fileupload,meta=None,RESPONSE=None): |
def manage_AddImageDigilib(self,id,fileupload,meta=None,RESPONSE=None): |
"""Add ImageCollection""" |
"""Add ImageCollection""" |
|
|
#fileupload=self.REQUEST['fileupload'] |
#fileupload=self.REQUEST['fileupload'] |
newObj=ImageDigilib(id,fileupload.filename,meta) |
#fn=splitPath(fileupload.filename) |
|
fn = id # filename is the same as id |
|
newObj=ImageDigilib(id,fn,meta) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
getattr(self,id).uploadImage(fileupload,self.ImageStoragePath) |
getattr(self,id).uploadImage(fileupload,self.ImageStoragePath) |
Line 135 def manage_AddImageDigilib(self,id,fileu
|
Line 617 def manage_AddImageDigilib(self,id,fileu
|
RESPONSE.redirect('manage_main') |
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" |
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" |
genericMetaDataType="leiden_meta" |
|
|
leiden_meta_fields=['image_id','date','country','place','people','description','photographer'] |
leiden_meta_fields=['image_id','date','country','place','people','description','photographer'] |
Line 146 class ImageCollection(Folder, Persistent
|
Line 638 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 |
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): |
imgcoll_main = PageTemplateFile('zpt/overview', globals()) |
|
imgcoll_thumb = PageTemplateFile('zpt/thumb', globals()) |
|
|
|
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="""<html> |
|
<head> |
|
<meta http-equiv="REFRESH" content="5;url=%s/checkThreads" |
|
<body><h2>Threads of %s</h2>"""%(self.absolute_url(),self.getId()) |
|
|
|
for threadName in self.zipThreads.keys(): |
|
if self.zipThreads2[threadName].isAlive(): |
|
ret+="<p>%s --> alive</p>"%threadName |
|
else: |
|
ret+="<p>%s --> dead</p>"%threadName |
|
return ret+"</body></html>" |
|
|
|
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""" |
"""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" |
return "RESCALING STARTED" |
|
|
def __init__(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString): |
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,serverPath=genericServerPath): |
self.id=id |
self.id=id |
self.title=title |
self.title=title |
self.ImageStoragePath=ImageStoragePath |
self.ImageStoragePath=ImageStoragePath |
self.ImageViewerPath=ImageViewerPath |
self.ImageViewerPath=ImageViewerPath |
self.defaultMetaString=defaultMetaString |
self.defaultMetaString=defaultMetaString |
|
self.serverPath=serverPath |
|
self.defaultrows = 6 |
|
self.defaultcols = 2 |
|
|
manage_options = Folder.manage_options+( |
optTMP= Folder.manage_options |
|
|
|
manage_options = optTMP+( |
{'label':'Main Config','action':'ImageCollection_config'}, |
{'label':'Main Config','action':'ImageCollection_config'}, |
{'label':'Import','action':'ImportFiles'}, |
{'label':'Import','action':'ImportFiles'}, |
{'label':'Recalculate Metadata','action':'recalculateMeta'}, |
{'label':'Recalculate MetadataLink','action':'recalculateMetaLink'}, |
{'label':'Import Metadata','action':'importMetaForm'}, |
{'label':'Import Metadata File','action':'importMetaFileForm'}, |
|
{'label':'Import Metadata','action':'importMetaData'}, |
{'label':'Rescale thumbs','action':'scaleThumbs'}, |
{'label':'Rescale thumbs','action':'scaleThumbs'}, |
|
{'label':'Rescale working version','action':'scaleWorkingVersions'}, |
) |
) |
|
|
|
|
def importMetaForm(self): |
|
|
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"]): |
|
|
|
image[1].manageMetaData(strict) |
|
return "ok" |
|
|
|
|
|
def importMetaFileForm(self): |
"""import metadata""" |
"""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() |
return pt() |
|
|
def importMeta(self,fileupload,tag): |
def importMetaFile(self,fileupload,tag): |
"""import""" |
"""import""" |
filedata=fileupload.read() |
filedata=fileupload.read() |
dom=xml.dom.minidom.parseString(filedata) |
dom=xml.dom.minidom.parseString(filedata) |
Line 206 class ImageCollection(Folder, Persistent
|
Line 839 class ImageCollection(Folder, Persistent
|
return "OK" |
return "OK" |
|
|
|
|
def nextImage(self,request,selected=None): |
def nextImage(self,request,selected=None,returnFn=None): |
"""show nextimage""" |
"""show nextimage""" |
|
try: |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
if request.SESSION.has_key("filename"): |
if request.SESSION.has_key("filename"): |
filename=request.SESSION["filename"] |
filename=request.SESSION["filename"] |
try: |
try: |
nr=ids.index(filename) |
nr=ids.index(filename) |
|
|
except: |
except: |
nr=0 |
nr=0 |
else: |
else: |
Line 221 class ImageCollection(Folder, Persistent
|
Line 856 class ImageCollection(Folder, Persistent
|
if nr==len(ids)-1: |
if nr==len(ids)-1: |
return "" |
return "" |
else: |
else: |
|
if returnFn: |
|
return ids[nr+1] |
|
|
if selected: |
if selected: |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr+1]+"\" target=\"_top\">next image</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr+1]+"\" target=\"_top\">next image</a>" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr+1]+"\" target=\"_top\">next image</a>" |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr+1]+"\" target=\"_top\">next image</a>" |
|
except: |
|
return "" |
|
|
def prevImage(self,request,selected=None): |
def prevImage(self,request,selected=None): |
"""show nextimage""" |
"""show nextimage""" |
#return self.getId() |
#return self.getId() |
|
try: |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
if request.SESSION.has_key("filename"): |
if request.SESSION.has_key("filename"): |
filename=request.SESSION["filename"] |
filename=request.SESSION["filename"] |
Line 246 class ImageCollection(Folder, Persistent
|
Line 887 class ImageCollection(Folder, Persistent
|
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr-1]+"\" target=\"_top\">previous image</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr-1]+"\" target=\"_top\">previous image</a>" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr-1]+"\" target=\"_top\">previous image</a>" |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr-1]+"\" target=\"_top\">previous image</a>" |
|
except: |
|
return "" |
|
|
def meta_default(self,filename): |
def meta_default(self,filename): |
"""url der metadaten""" |
"""url der metadaten""" |
return self.defaultMetaString % filename |
return self.defaultMetaString % urllib.quote(filename) |
|
|
def getThumbAttribute(self,id,attr): |
def getThumbAttribute(self,id,attr): |
if hasattr(self,id): |
if hasattr(self,id): |
Line 270 class ImageCollection(Folder, Persistent
|
Line 913 class ImageCollection(Folder, Persistent
|
|
|
url=urllib.unquote(url) |
url=urllib.unquote(url) |
xmldoc=urllib.urlopen(url).read() |
xmldoc=urllib.urlopen(url).read() |
#print url |
#return xmldoc |
|
try: |
dom=xml.dom.minidom.parseString(xmldoc) |
dom=xml.dom.minidom.parseString(xmldoc) |
|
except: |
|
return xmldoc |
|
images=dom.getElementsByTagName('image') |
|
|
images=dom.getElementsByTagName('imagename') |
|
rc=[] |
rc=[] |
|
fnIds={} |
for image in images: |
for image in images: |
text=getText(image.childNodes) |
imagename=image.getElementsByTagName('imagename')[0] |
|
|
|
|
|
|
|
idnr=image.getElementsByTagName('idnr')[0] |
|
id=getText(idnr.childNodes) |
|
try: |
|
numberOfPages=image.getElementsByTagName('numberOfPages')[0] |
|
except: |
|
numberOfPages=None |
|
|
|
if numberOfPages: |
|
nopT=getText(numberOfPages.childNodes) |
|
try: |
|
nop=int(nopT) |
|
except: |
|
nop=0 |
|
else: |
|
nop=0 |
|
|
|
texts=getText(imagename.childNodes).split("\n") #mehrere bilder in return getrennter liste |
|
for text in texts: |
if not text=="": |
if not text=="": |
rc.append(str(text)) |
try: |
|
rc.append((str(text),id,nop)) |
|
fnIds[str(text)]=(id,nop) |
|
except: |
|
rc.append((repr(text),id,nop)) |
|
fnIds[repr(text)]=(id,nop) |
|
|
|
|
rc.sort() |
rc.sort() |
self.REQUEST.SESSION['filenames']=rc |
self.REQUEST.SESSION['filenames']=rc |
pt=PageTemplateFile('Products/ImageArchive/overview_selected.zpt').__of__(self) |
self.REQUEST.SESSION['filenamesIds']=fnIds |
|
|
|
overview=self.ZopeFind(self,obj_ids=['overview_selected.html']) |
|
|
|
if overview: |
|
return overview[0][1]() |
|
else: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selected.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def recalculateMeta(self): |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selected.zpt')).__of__(self) |
|
return pt() |
|
|
|
def recalculateMetaLink(self): |
"""recalculate the metadata""" |
"""recalculate the metadata""" |
|
|
for entryid in self.__dict__: |
for entryid in self.__dict__: |
Line 297 class ImageCollection(Folder, Persistent
|
Line 982 class ImageCollection(Folder, Persistent
|
|
|
def addImage(self): |
def addImage(self): |
"""Add an Image""" |
"""Add an Image""" |
pt=PageTemplateFile('Products/ImageArchive/addImage.zpt').__of__(self) |
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addImage.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def addImage2(self,fileupload,meta,use_default=None,RESPONSE=None): |
def addImage2(self,fileupload,fileName=None,meta=None,use_default=None,RESPONSE=None): |
"""Add""" |
"""Add""" |
|
|
#print "FU",fileupload |
#print "FU",fileupload |
|
|
if use_default: |
if use_default: |
Line 312 class ImageCollection(Folder, Persistent
|
Line 999 class ImageCollection(Folder, Persistent
|
else: |
else: |
meta=None |
meta=None |
|
|
manage_AddImageDigilib(self,fileupload.filename,fileupload,meta=meta) |
fn=fileName or splitPath(fileupload.filename) |
return RESPONSE.redirect(self.REQUEST['URL1']+'/'+fileupload.filename) |
|
|
manage_AddImageDigilib(self,fn,fileupload,meta=meta) |
|
|
|
if RESPONSE: |
|
return RESPONSE.redirect(self.REQUEST['URL1']+'/'+fn) |
#return self.REQUEST['URL1']+'/'+fileupload.filename |
#return self.REQUEST['URL1']+'/'+fileupload.filename |
|
|
def ImportFiles2(self,RESPONSE=None): |
def ImportFiles2(self,RESPONSE=None): |
Line 334 class ImageCollection(Folder, Persistent
|
Line 1025 class ImageCollection(Folder, Persistent
|
#print newObj |
#print newObj |
self._setObject(file,newObj) |
self._setObject(file,newObj) |
#print ret |
#print ret |
#pt=PageTemplateFile('Products/ImageArchive/out.zpt').__of__(self) |
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self) |
|
#print self.ImageStoragePath |
|
|
|
#scale thumb |
|
|
|
self.scaleThumbs() |
|
|
|
#scale standard |
|
|
|
self.scaleWorkingVersions() |
|
|
|
|
|
RESPONSE.redirect('manage_main') |
|
|
|
## def importStructure(self,path): |
|
## """import""" |
|
## splitted=os.path.split(path) |
|
## if os.path.isDir(path) and (len(splitted[1])>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+"<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 |
#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) |
|
|
#scale thumb |
|
|
|
#self.scaleThumbs() |
|
|
|
#scale standard |
|
|
|
#self.scaleWorkingVersions() |
|
|
|
if RESPONSE: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def ImportFiles(self,RESPONSE=None): |
def ImportFiles(self,RESPONSE=None): |
Line 359 class ImageCollection(Folder, Persistent
|
Line 1113 class ImageCollection(Folder, Persistent
|
except: |
except: |
"""nothing yet""" |
"""nothing yet""" |
#print ret |
#print ret |
#pt=PageTemplateFile('Products/ImageArchive/out.zpt').__of__(self) |
#pt=PageTemplateFile('Products/ImageArchive/out.zpt')).__of__(self) |
#print self.ImageStoragePath |
#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) |
|
|
#scale thumb |
|
|
|
self.scaleThumbs() |
|
|
|
#scale standard |
|
|
|
self.scaleWorkingVersions() |
|
|
|
if RESPONSE: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def ImageCollection_config(self): |
def ImageCollection_config(self): |
Line 369 class ImageCollection(Folder, Persistent
|
Line 1132 class ImageCollection(Folder, Persistent
|
if not hasattr(self,'defaultMetaString'): |
if not hasattr(self,'defaultMetaString'): |
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() |
return pt() |
|
|
def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None): |
def ChangeImageCollection(self,title,ImageStoragePath,ImageViewerPath,defaultMetaString,serverPath,RESPONSE=None): |
"""Change""" |
"""Change""" |
self.title=title |
self.title=title |
self.ImageStoragePath=ImageStoragePath |
self.ImageStoragePath=ImageStoragePath |
self.ImageViewerPath=ImageViewerPath |
self.ImageViewerPath=ImageViewerPath |
self.defaultMetaString=defaultMetaString |
self.defaultMetaString=defaultMetaString |
|
self.serverPath=serverPath |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
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 398 class ImageCollection(Folder, Persistent
|
Line 1163 class ImageCollection(Folder, Persistent
|
ids.sort() |
ids.sort() |
return ids |
return ids |
|
|
def firstSets(self,selected=None): |
def firstSets(self,selected=None,text='first set'): |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
|
if ids: |
if selected: |
if selected: |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[0]+"\" target=\"_top\">first sets</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[0]+"\" target=\"_top\">"+text+"</a>" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[0]+"\" target=\"_top\">first sets</a>" |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[0]+"\" target=\"_top\">"+text+"</a>" |
|
|
def lastSets(self,selected=None): |
def lastSets(self,selected=None,text='last set'): |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
|
if ids: |
colRows=self.getColTimesRow() |
colRows=self.getColTimesRow() |
|
|
if colRows[1]: |
if colRows[1]: |
Line 418 class ImageCollection(Folder, Persistent
|
Line 1185 class ImageCollection(Folder, Persistent
|
nr=0 |
nr=0 |
|
|
if selected: |
if selected: |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">last set</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">last sets</a>" |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
|
|
|
|
|
|
def nextSets(self,selected=None): |
def nextSets(self,selected=None,text='next set'): |
"""show nextimage""" |
"""show nextimage""" |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
colRows=self.getColTimesRow() |
colRows=self.getColTimesRow() |
|
pagesize = colRows[0] * colRows[1] |
|
if ids: |
if colRows[1]: |
if colRows[1]: |
|
|
if self.REQUEST.SESSION.has_key("filename"): |
if self.REQUEST.SESSION.has_key("filename"): |
filename=self.REQUEST.SESSION["filename"] |
filename=self.REQUEST.SESSION["filename"] |
try: |
try: |
nr=ids.index(filename)+colRows[0]*colRows[1] |
nr=ids.index(filename)+pagesize |
if nr>=len(ids): |
if nr>=len(ids): |
nr=len(ids)-1 |
return "" |
except: |
except: |
nr=0 |
nr=pagesize |
else: |
else: |
nr=0 |
nr = pagesize |
|
|
if nr==len(ids)-1: |
if nr>=len(ids)-1: |
return "" |
return "" |
else: |
else: |
if selected: |
if selected: |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">next set</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">next set</a>" |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
|
|
def prevSets(self,selected=None): |
def prevSets(self,selected=None,text='previous sets'): |
|
|
"""show nextimage""" |
"""show nextimage""" |
#return self.getId() |
#return self.getId() |
ids=self.show_thumbs() |
ids=self.show_thumbs() |
colRows=self.getColTimesRow() |
colRows=self.getColTimesRow() |
|
if ids: |
if colRows[1]: |
if colRows[1]: |
if self.REQUEST.SESSION.has_key("filename"): |
if self.REQUEST.SESSION.has_key("filename"): |
filename=self.REQUEST.SESSION["filename"] |
filename=self.REQUEST.SESSION["filename"] |
Line 475 class ImageCollection(Folder, Persistent
|
Line 1244 class ImageCollection(Folder, Persistent
|
return "" |
return "" |
else: |
else: |
if selected: |
if selected: |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">previous sets</a>" |
return "<a href=\""+self.REQUEST['URL1']+"/selection?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
|
else: |
|
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">"+text+"</a>" |
|
else: |
|
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 getSetSelector(self, selected=None): |
|
"""returns the HTML select element for the sets""" |
|
actualNr=0 |
|
ids=self.show_thumbs() |
|
colRows=self.getColTimesRow() |
|
pagesize = colRows[0]*colRows[1] |
|
numpages = int(len(ids)/pagesize) |
|
if not ((len(ids) % pagesize)==0): |
|
numpages+=1 |
|
|
|
ret="" |
|
if numpages>1: |
|
if selected: |
|
ret+="""<select onChange="parent.location.href='"""+self.REQUEST['URL1']+"""/selection?filename='+this.options[this.selectedIndex].value">""" |
else: |
else: |
return "<a href=\""+self.REQUEST['URL1']+"?filename="+ids[nr]+"\" target=\"_top\">previous sets</a>" |
ret+="""<select onChange="parent.location.href='"""+self.REQUEST['URL1']+"""?filename='+this.options[this.selectedIndex].value">""" |
|
|
|
for i in range(numpages): |
|
try: |
|
nr=ids.index(self.REQUEST.SESSION['filename']) |
|
except: |
|
nr=0 |
|
k=i * pagesize |
|
if (k <= nr) and (nr < i*(pagesize+1)): |
|
actualNr=i |
|
ret+="""<option value="%s" selected>%i</option>"""%(ids[k], i + 1) |
else: |
else: |
|
ret+="""<option value="%s">%i</option>"""%(ids[k], i + 1) |
|
|
|
ret+="</select>" |
|
|
|
return ret |
|
|
|
def isAllSets(self, showall=None): |
|
"""returns if there are any sets""" |
|
ids=self.show_thumbs() |
|
colRows=self.getColTimesRow(showall=showall) |
|
pagesize = colRows[0]*colRows[1] |
|
return (len(ids) <= pagesize) |
|
|
|
|
|
def allSets(self, texton='show all', textoff='show groups'): |
|
"""returns HTML to toggle 'show all'""" |
|
if self.isAllSets(showall='No'): |
return "" |
return "" |
|
showall=self.REQUEST.SESSION.get('showall','no') |
|
if showall=='no': |
|
ret='<a href="'+self.REQUEST['URL1']+'?showall=yes" target="_top">'+texton+'</a>' |
|
else: |
|
ret='<a href="'+self.REQUEST['URL1']+'?showall=no" target="_top">'+textoff+'</a>' |
|
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 "<b>No entries</b>" |
|
|
|
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+="""<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): |
|
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+="""<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: |
|
href=self.REQUEST['URL1']+"/selection?filename="+ids[(actualNr-1)*a] |
|
else: |
|
href=self.REQUEST['URL1']+"?filename="+ids[int((actualNr-1)*a)] |
|
|
|
anf+="""<a href="%s" target="_top">%s</a> """%(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="""<a href="%s" target="_top">%s</a> """%(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> """%(href,i) |
|
|
|
else: |
|
ret="" |
|
ret+="""<a href="%s?showall=yes" target="_top">show all</a> """%self.REQUEST['URL1'] |
|
else: |
|
ret="""<a href="%s?showall=no" target="_top">show groups</a> """%self.REQUEST['URL1'] |
|
|
|
return ret |
|
|
|
|
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) |
Line 491 class ImageCollection(Folder, Persistent
|
Line 1421 class ImageCollection(Folder, Persistent
|
|
|
def setColTimesRowForm(self): |
def setColTimesRowForm(self): |
"""form for matrix setting""" |
"""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() |
return pt() |
|
|
def setDone(self): |
def setDone(self): |
"""done""" |
"""done""" |
|
|
pt=PageTemplateFile('Products/ImageArchive/changedColTimesRow.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changedColTimesRow.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def setColTimesRow(self,cols,rows): |
def setColTimesRow(self,cols,rows): |
Line 514 class ImageCollection(Folder, Persistent
|
Line 1444 class ImageCollection(Folder, Persistent
|
|
|
RESPONSE.redirect(self.REQUEST['URL1']+"/setDone") |
RESPONSE.redirect(self.REQUEST['URL1']+"/setDone") |
|
|
def getColTimesRow(self): |
def setDefaultColTimesRow(self, cols, rows): |
|
"""sets default columns and rows""" |
|
self.defaultcols = cols |
|
self.defaultrows = rows |
|
|
|
def getColTimesRow(self,showall='No'): |
"""coltimesrow""" |
"""coltimesrow""" |
|
|
REQUEST=self.REQUEST |
REQUEST=self.REQUEST |
"""matrix""" |
"""matrix""" |
if REQUEST.cookies.has_key("ImageViewerRows"): |
if REQUEST.cookies.has_key("ImageViewerRows"): |
|
|
try: |
try: |
rows=int(REQUEST.cookies["ImageViewerRows"]) |
rows=int(REQUEST.cookies["ImageViewerRows"]) |
except: |
except: |
rows=None |
rows=getattr(self,'defaultrows',6) |
else: |
else: |
rows=None |
rows=getattr(self,'defaultrows',6) |
|
|
if REQUEST.cookies.has_key("ImageViewerCols"): |
if REQUEST.cookies.has_key("ImageViewerCols"): |
#print "COLS",REQUEST.cookies["ImageViewerCols"] |
#print "COLS",REQUEST.cookies["ImageViewerCols"] |
cols=int(REQUEST.cookies["ImageViewerCols"]) |
cols=int(REQUEST.cookies["ImageViewerCols"]) |
else: |
else: |
cols=4 |
cols=getattr(self,'defaultcols',3) |
|
|
|
|
idsnumber=len(self.show_thumbs()) |
idsnumber=len(self.show_thumbs()) |
if rows: |
if rows: |
if cols*rows >idsnumber: |
if cols*rows >idsnumber: |
rows=int(idsnumber/cols)+1 |
rows=int(idsnumber/cols)+1 |
|
|
|
if showall is None: |
|
showall=self.REQUEST.SESSION.get('showall', 'No') |
|
if showall=='yes': |
|
rows=int(idsnumber/cols)+1 |
|
|
return (cols,rows) |
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""" |
"""Ausgabe anzahl""" |
|
|
idsAll=self.show_thumbs() |
idsAll=self.show_thumbs() |
|
if len(idsAll)==0: #keine Eintraege |
if self.REQUEST.SESSION.has_key("filename"): |
return 0 |
|
if self.REQUEST.SESSION.has_key("filename") and not (showall=="yes"): |
filename=self.REQUEST.SESSION["filename"] |
filename=self.REQUEST.SESSION["filename"] |
|
filename=self.getImageByName(filename,onlyName="yes") |
|
|
try: |
try: |
startId=filename |
startId=filename |
|
if startId=="": |
|
startId=idsAll[0][0:] |
except: |
except: |
startId=idsAll[0] |
startId=idsAll[0][0:] |
else: |
else: |
startId=idsAll[0] |
startId=idsAll[0][0:] |
|
|
|
|
|
|
print "NOR:",numberOfRows |
|
|
|
if numberOfRows: |
if numberOfRows: |
|
|
|
startPic=idsAll.index(startId) |
try: |
try: |
|
|
startPic=idsAll.index(startId) |
startPic=idsAll.index(startId) |
endPic=startPic+numberOfColumns*numberOfRows |
endPic=startPic+numberOfColumns*numberOfRows |
ids=idsAll[startPic:endPic] |
ids=idsAll[startPic:endPic] |
except: |
except: |
ids=idsAll |
ids=idsAll |
else: |
else: |
|
|
ids=idsAll |
ids=idsAll |
|
|
|
|
Line 585 class ImageCollection(Folder, Persistent
|
Line 1535 class ImageCollection(Folder, Persistent
|
|
|
def thumblistSelected_old(self): |
def thumblistSelected_old(self): |
"""main template collection""" |
"""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() |
return pt() |
|
|
def thumblistSelected(self): |
def thumblistSelected(self): |
"""main template collection""" |
"""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() |
return pt() |
|
|
def thumblist_old(self): |
def thumblist_old(self): |
"""main template collection""" |
"""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() |
return pt() |
|
|
def thumblist(self): |
def thumblist(self): |
"""main template collection""" |
"""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() |
return pt() |
|
|
|
|
def navig_selected_html(self): |
def navig_selected_html(self): |
"""navigation""" |
"""navigation""" |
#self.REQUEST.SESSION['URL']=self.REQUEST['URL0'] |
#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() |
return pt() |
|
|
def navig_html(self): |
def navig_html(self): |
"""navigation""" |
"""navigation""" |
#self.REQUEST.SESSION['URL']=self.REQUEST['URL0'] |
#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() |
return pt() |
|
|
|
|
Line 623 class ImageCollection(Folder, Persistent
|
Line 1580 class ImageCollection(Folder, Persistent
|
else: |
else: |
filen="" |
filen="" |
self.REQUEST.SESSION['filename']=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() |
return pt() |
|
|
def index_html(self): |
def getImageByName(self,filename,onlyName=None): |
|
"""get filename""" |
|
|
|
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,generic=None): |
"""main template collection""" |
"""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 |
|
|
|
overview=self.ZopeFind(self,obj_ids=['overview_selected.html']) |
|
|
|
if overview and (generic is None): |
|
return overview[0][1]() |
|
else: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview_selected.zpt')).__of__(self) |
|
return pt() |
|
|
if self.REQUEST.has_key('filename'): |
if self.REQUEST.has_key('filename'): |
filen=self.REQUEST['filename'] |
filen=self.REQUEST['filename'] |
else: |
else: |
filen="" |
filen="" |
self.REQUEST.SESSION['filename']=filen |
|
pt=PageTemplateFile('Products/ImageArchive/overview.zpt').__of__(self) |
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 and (generic is None): |
|
return overview[0][1]() |
|
elif hasattr(self,'templates'): |
|
pt=self.templates.imgcoll_main.__of__(self) |
|
return pt() |
|
else: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','overview.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
|
|
def manage_AddImageCollectionForm(self): |
def manage_AddImageCollectionForm(self): |
"""Nothing yet""" |
"""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() |
return pt() |
|
|
def manage_AddImageCollection(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None): |
def manage_AddImageCollection(self,id,title,ImageStoragePath,ImageViewerPath,defaultMetaString,RESPONSE=None): |
Line 650 def manage_AddImageCollection(self,id,ti
|
Line 1668 def manage_AddImageCollection(self,id,ti
|
RESPONSE.redirect('manage_main') |
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""" |
|
|