--- ImageArchive/ImageArchive.py 2005/10/12 19:33:39 1.66 +++ ImageArchive/ImageArchive.py 2005/10/25 19:42:59 1.69 @@ -1,6 +1,5 @@ +genericServerPath="http://www.mpiwg-berlin.mpg.de/zogilib_images" #can be changed with main config -#genericServerPath="http://content.mpiwg-berlin.mpg.de/zogilib_images" -genericServerPath="http://127.0.0.1:8080/zogilib_images" from OFS.Folder import Folder @@ -24,7 +23,7 @@ from threading import Thread import Queue import cgi -from AccessControl import ClassSecurityInfo +from AccessControl import ClassSecurityInfo, getSecurityManager try: from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder @@ -278,6 +277,30 @@ 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) @@ -599,6 +622,10 @@ 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 getServerPath(self): + """get Server path""" + return getattr(self,'serverPath',genericServerPath) + def getScalerPath(self): """get ScalerPath""" path=getattr(self,'serverPath',genericServerPath)+"/scaledImage?fn=" @@ -1074,12 +1101,13 @@ class ImageCollection(Folder, Persistent 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') @@ -1539,8 +1567,12 @@ class ImageCollectionMD(ImageCollection, 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: @@ -1548,6 +1580,32 @@ class ImageCollectionMD(ImageCollection, 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) @@ -1561,7 +1619,17 @@ class ImageCollectionMD(ImageCollection, """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"""