--- cdli/cdli_files.py 2006/06/15 22:02:40 1.25 +++ cdli/cdli_files.py 2006/06/17 14:53:35 1.26 @@ -18,7 +18,7 @@ from ZPublisher.HTTPRequest import HTTPR from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.BaseRequest import RequestContainer import threading - + class uploadATFfinallyThread(Thread): @@ -58,7 +58,7 @@ class uploadATFfinallyThread(Thread): req = HTTPRequest(None, env, resp) return app.__of__(RequestContainer(REQUEST = req)) - + def run(self): """run""" @@ -1062,6 +1062,25 @@ class CDLIFileObject(versionedFileObject security=ClassSecurityInfo() + + security.declarePublic('makeThisVersionCurrent') + + def makeThisVersionCurrent_html(self): + """form for making this version current""" + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','makeThisVersionCurrent.zpt')).__of__(self) + return pt() + def makeThisVersionCurrent(self,comment,author): + """copy this version to current""" + parent=self.aq_parent + + + newversion=parent.manage_addCDLIFileObject('',comment,author) + newversion.data=self.data[0:] + return True + + security.declarePublic('view') + def view(self): """view file""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','viewCDLIFile.zpt')).__of__(self) @@ -1121,7 +1140,18 @@ class CDLIFile(versionedFile,CatalogAwar meta_type="CDLI file" default_catalog='CDLICatalog' - + #security.declarePublic('history') + def history(self): + """history""" + + ext=self.ZopeFind(self.aq_parent,obj_ids=["history_template.html"]) + if ext: + return getattr(self,ext[0][1].getId())() + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','versionHistory')).__of__(self) + return pt() + + def isContainedInBaskets(self,context=None): """check is this file is part of any basket @@ -1321,8 +1351,23 @@ class CDLIFileFolder(versionedFileFolder - - + def findObjectsFromListWithVersion(self,list): + """find objects from a list with versions + @param list: list of tuples (cdliFile,version) + """ + + + + #self.REQUEST.SESSION['fileIds']=list#store fieldIds in session for further usage + #self.REQUEST.SESSION['searchList']=self.REQUEST.SESSION['fileIds'] + + + pt=getattr(self,'filelistVersioned.html') + + return pt(search=list) + + + def findObjectsFromList(self,display=False,start=None,upload=None,list=None,basketName=None,numberOfObjects=None,RESPONSE=None): """findObjectsFromList (, TAB oder LINE separated)""" @@ -1493,14 +1538,41 @@ class CDLIRoot(Folder): meta_type="CDLIRoot" - def getChangesByAuthor(self,author): + def forceunlock(self): + "break all locks" + ret=[] + for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1): + un=f[1].forceunlock() + print un + if un and un !="": + ret.append((f[0],un)) + print ret + return ret + + def getChangesByAuthor(self,author,n=100): """getChangesByAuthor""" - zcat=self.CDLICatalog - return zcat({'lastEditor':author, + zcat=self.CDLIObjectsCatalog + res=zcat({'lastEditor':author, 'sort_on':'getTime', 'sort_order':'descending', 'sort_limit':n})[:n ] - + + return res + + def getChangesByAuthor_html(self,author,n=100): + """html output for changes by author""" + tmp={} + list=[] + for x in self.getChangesByAuthor(author): + nr=x.getObject().getVersionNumber() + id=x.getObject().aq_parent.getId() + #hinzufuegen, wenn Version neuer als die + if tmp.get(id,(0,0))[1] < nr: + tmp[id]=(x.getObject().aq_parent,nr) + + + return self.cdli_main.findObjectsFromListWithVersion(list=tmp.values()) + def getLastChanges(self,n=100): """get the last n changes""" n=int(n)