|
|
| version 1.53, 2005/11/21 20:05:29 | version 1.57, 2006/05/10 16:58:49 |
|---|---|
| Line 7 from AccessControl import getSecurityMan | Line 7 from AccessControl import getSecurityMan |
| from Products.PageTemplates.PageTemplate import PageTemplate | from Products.PageTemplates.PageTemplate import PageTemplate |
| from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate | from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
| from AccessControl import ClassSecurityInfo | from AccessControl import ClassSecurityInfo |
| from difflib import Differ | |
| from pprint import pprint | |
| from Products.ZCatalog.CatalogPathAwareness import CatalogAware | from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
| Line 517 class versionedFileObject(File): | Line 518 class versionedFileObject(File): |
| manage_editForm._setName('manage_editForm') | manage_editForm._setName('manage_editForm') |
| security.declarePublic('getVComment') | security.declarePublic('getTitle') |
| def getTitle(self): | |
| """get title""" | |
| return self.title | |
| security.declarePublic('getVComment') | |
| def getVComment(self): | def getVComment(self): |
| """get the comment of this file""" | """get the comment of this file""" |
| if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""): | if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""): |
| Line 596 class versionedFileObject(File): | Line 602 class versionedFileObject(File): |
| #self.REQUEST.close() | #self.REQUEST.close() |
| security.declareProtected('AUTHENTICATED_USER','downloadLocked') | |
| def downloadLocked(self): | def downloadLocked(self): |
| """download and lock""" | """download and lock""" |
| if self.REQUEST['AUTHENTICATED_USER']=='Anonymous User': | if repr(self.REQUEST['AUTHENTICATED_USER'])=='Anonymous User': |
| return "please login first" | return "please login first" |
| if not self.aq_parent.lockedBy=="": | if not self.aq_parent.lockedBy=="": |
| return "cannot be locked because is already locked by %s"%self.lockedBy | return "cannot be locked because is already locked by %s"%self.lockedBy |
| Line 632 class versionedFileObject(File): | Line 639 class versionedFileObject(File): |
| def lastEditor(self): | def lastEditor(self): |
| """last Editor""" | """last Editor""" |
| if hasattr(self,'author'): | if hasattr(self,'author'): |
| try: | |
| ret=self.author.replace("-","\n") | ret=self.author.replace("-","\n") |
| except:#old version of versionded file sometimes stored the user object and not only the name the following corrects this | |
| ret=str(self.author).replace("-","\n") | |
| ret=ret.replace("\r","\n") | ret=ret.replace("\r","\n") |
| return ret | return ret |
| Line 689 class versionedFile(CatalogAware,Folder) | Line 699 class versionedFile(CatalogAware,Folder) |
| default_catalog='fileCatalog' | default_catalog='fileCatalog' |
| def getTitle(self): | |
| """get title""" | |
| return self.title | |
| def PrincipiaSearchSource(self): | def PrincipiaSearchSource(self): |
| """Return cataloguable key for ourselves.""" | """Return cataloguable key for ourselves.""" |
| return str(self) | return str(self) |
| Line 797 class versionedFile(CatalogAware,Folder) | Line 811 class versionedFile(CatalogAware,Folder) |
| lastVersion.versionNumber=1 | lastVersion.versionNumber=1 |
| return lastVersion | return lastVersion |
| def diff(self,data): | |
| """differenz between lastversion and data""" | |
| d=Differ() | |
| tmp=self.getLastVersion().data | |
| #print "XX",data,tmp | |
| l=list(d.compare(data.splitlines(1),tmp.splitlines(1))) | |
| plus=0 | |
| minus=0 | |
| for a in l: | |
| if a[0]=='+': | |
| plus+=1 | |
| if a[0]=='-': | |
| minus+=1 | |
| return max([plus,minus]),l | |
| def index_html(self): | def index_html(self): |
| """main view""" | """main view""" |
| lastVersion=self.getLastVersion() | lastVersion=self.getLastVersion() |
| #return "File:"+self.title+" Version:%i"%lastVersion.versionNumber," modified:",lastVersion.bobobase_modification_time()," size:",lastVersion.getSize(),"modified by:",lastVersion.lastEditor() | #return "File:"+self.title+" Version:%i"%lastVersion.versionNumber," modified:",lastVersion.bobobase_modification_time()," size:",lastVersion.getSize(),"modified by:",lastVersion.lastEditor() |
| return "File: %s Version:%i modified:%s size:%s modified by:%s"%(self.title,lastVersion.versionNumber,lastVersion.getTime(),lastVersion.getSize(),lastVersion.lastEditor()) | return "File: %s Version:%i modified:%s size:%s modified by:%s"%(self.title,lastVersion.versionNumber,lastVersion.getTime(),lastVersion.getSize(),lastVersion.lastEditor()) |
| security= ClassSecurityInfo() | security= ClassSecurityInfo() |
| security.declarePublic('getVersion') | security.declarePublic('getVersion') |
| def getVersion(self): | def getVersion(self): |
| tmp=0 | tmp=0 |
| Line 846 class versionedFile(CatalogAware,Folder) | Line 881 class versionedFile(CatalogAware,Folder) |
| """unlock""" | """unlock""" |
| if str(self.lockedBy) in [str(self.REQUEST['AUTHENTICATED_USER'])]: | if str(self.lockedBy) in [str(self.REQUEST['AUTHENTICATED_USER'])]: |
| self.lockedBy='' | self.lockedBy='' |
| RESPONSE.redirect(self.REQUEST['URL2']) | RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) |
| else: | else: |
| return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER']) | return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER']) |
| Line 941 class versionedFile(CatalogAware,Folder) | Line 976 class versionedFile(CatalogAware,Folder) |
| #self.getLastVersion().content_type="application/octet-stream" | #self.getLastVersion().content_type="application/octet-stream" |
| self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) | self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) |
| security.declareProtected('AUTHENTICATED_USER','downloadLocked') | |
| def downloadLocked(self): | def downloadLocked(self): |
| """download and lock""" | """download and lock""" |
| if self.REQUEST['AUTHENTICATED_USER']=='Anonymous User': | |
| if repr(self.REQUEST['AUTHENTICATED_USER'])=='Anonymous User': | |
| return "please login first" | return "please login first" |
| if not self.lockedBy=="": | if not self.lockedBy=="": |
| return "cannot be locked because is already locked by %s"%self.lockedBy | return "cannot be locked because is already locked by %s"%self.lockedBy |