version 1.20, 2004/11/24 17:02:56
|
version 1.32, 2005/03/21 08:12:46
|
Line 53 class versionedFileFolder(Folder,ECHO_ba
|
Line 53 class versionedFileFolder(Folder,ECHO_ba
|
"""lege standard index.html an""" |
"""lege standard index.html an""" |
|
|
|
|
|
if not self.ZopeFind(self,obj_ids=['index.html']): |
|
|
if not hasattr(self,'index.html'): |
|
zt=ZopePageTemplate('index.html') |
zt=ZopePageTemplate('index.html') |
self._setObject('index.html',zt) |
self._setObject('index.html',zt) |
default_content_fn = os.path.join(package_home(globals()), |
default_content_fn = os.path.join(package_home(globals()), |
Line 75 class versionedFileFolder(Folder,ECHO_ba
|
Line 73 class versionedFileFolder(Folder,ECHO_ba
|
|
|
|
|
|
|
|
if not self.ZopeFind(self,obj_ids=['history_template.html']): |
if not hasattr(self,'history_template.html'): |
|
zt=ZopePageTemplate('history_template.html') |
zt=ZopePageTemplate('history_template.html') |
self._setObject('history_template.html',zt) |
self._setObject('history_template.html',zt) |
default_content_fn = os.path.join(package_home(globals()), |
default_content_fn = os.path.join(package_home(globals()), |
Line 90 class versionedFileFolder(Folder,ECHO_ba
|
Line 87 class versionedFileFolder(Folder,ECHO_ba
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
|
def getVersionedFiles(self,sortField='title'): |
def getVersionedFiles(self,sortField='title'): |
"""get all versioned files""" |
"""get all versioned files""" |
|
|
Line 99 class versionedFileFolder(Folder,ECHO_ba
|
Line 99 class versionedFileFolder(Folder,ECHO_ba
|
def sortDate(x,y): |
def sortDate(x,y): |
return cmp(y[1].getLastVersion().getTime(),x[1].getLastVersion().getTime()) |
return cmp(y[1].getLastVersion().getTime(),x[1].getLastVersion().getTime()) |
|
|
|
|
|
def sortComment(x,y): |
|
try: |
|
x=getattr(x[1],'comment','ZZZZZZZZZZZZZ').lower() |
|
except: |
|
x='zzzzzzzzzzzzzzzz' |
|
try: |
|
y=getattr(y[1],'comment','ZZZZZZZZZZZZZ').lower() |
|
except: |
|
y='zzzzzzzzzzzzzzzz' |
|
return cmp(x,y) |
|
|
def sortAuthor(x,y): |
def sortAuthor(x,y): |
|
|
return cmp(x[1].getLastVersion().lastEditor(),y[1].getLastVersion().lastEditor()) |
return cmp(x[1].getLastVersion().lastEditor().lower(),y[1].getLastVersion().lastEditor().lower()) |
|
|
versionedFiles=self.ZopeFind(self,obj_metatypes=['versionedFile']) |
versionedFiles=self.ZopeFind(self,obj_metatypes=['versionedFile']) |
|
|
Line 111 class versionedFileFolder(Folder,ECHO_ba
|
Line 123 class versionedFileFolder(Folder,ECHO_ba
|
versionedFiles.sort(sortDate) |
versionedFiles.sort(sortDate) |
elif sortField=='author': |
elif sortField=='author': |
versionedFiles.sort(sortAuthor) |
versionedFiles.sort(sortAuthor) |
|
elif sortField=='comment': |
|
versionedFiles.sort(sortComment) |
|
|
return versionedFiles |
return versionedFiles |
|
|
Line 135 class versionedFileFolder(Folder,ECHO_ba
|
Line 149 class versionedFileFolder(Folder,ECHO_ba
|
|
|
def addFileForm(self): |
def addFileForm(self): |
"""add a file""" |
"""add a file""" |
|
ext=self.ZopeFind(self,obj_ids=["addFileForm.dtml"]) |
|
if ext: |
|
return ext[0][1]('',globals(),version='1',AUTHENTICATED_USER=self.REQUEST.AUTHENTICATED_USER) |
|
|
out=DTMLFile('dtml/newFileAdd', globals(),Kind='VersionedFileObject',kind='versionedFileObject',version='1').__of__(self) |
out=DTMLFile('dtml/newFileAdd', globals(),Kind='VersionedFileObject',kind='versionedFileObject',version='1').__of__(self) |
return out() |
return out() |
|
|
Line 142 class versionedFileFolder(Folder,ECHO_ba
|
Line 160 class versionedFileFolder(Folder,ECHO_ba
|
def addFile(self,vC,file,author,newName='',content_type='',RESPONSE=None): |
def addFile(self,vC,file,author,newName='',content_type='',RESPONSE=None): |
""" add a new file""" |
""" add a new file""" |
if newName=='': |
if newName=='': |
id=file.filename |
filename=file.filename |
|
id=filename[max(filename.rfind('/'), |
|
filename.rfind('\\'), |
|
filename.rfind(':'), |
|
)+1:] |
|
|
else: |
else: |
id=newName |
id=newName |
|
|
vC=self.REQUEST.form['vC'] |
vC=self.REQUEST.form['vC'] |
manage_addVersionedFile(self,id,'','') |
manage_addVersionedFile(self,id,'','') |
|
#if (getattr(self,'commentNonEmpty',0)==1) and vC.strip()=="": |
|
|
|
|
ob=self._getOb(id) |
ob=self._getOb(id) |
ob.title=id |
ob.title=id |
file2=file |
file2=file |
ob.manage_addVersionedFileObject(id,vC,author,file2,content_type=content_type) |
|
|
obj=ob.manage_addVersionedFileObject(id,vC,author,file2,content_type=content_type) |
|
self.REQUEST.SESSION['objID']=ob.getId() |
|
self.REQUEST.SESSION['objID_parent']=None |
|
|
|
if obj.getSize()==0: |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','errorUploadFile')).__of__(self) |
|
return pt() |
|
|
|
RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
|
|
|
def deleteEmptyObject(self,submit,RESPONSE=None): |
|
"""deleteemptyobject""" |
|
if submit=="delete it": |
|
if self.REQUEST.SESSION['objID_parent']: |
|
obj=getattr(self,self.REQUEST.SESSION['objID_parent']) |
|
|
|
else: |
|
obj=self |
|
obj.manage_delObjects([self.REQUEST.SESSION['objID']]) |
|
|
RESPONSE.redirect(self.REQUEST['URL1']) |
RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
Line 199 class versionedFileObject(File):
|
Line 245 class versionedFileObject(File):
|
Kind='File',kind='file') |
Kind='File',kind='file') |
manage_editForm._setName('manage_editForm') |
manage_editForm._setName('manage_editForm') |
|
|
|
def getVComment(self): |
|
"""get the comment of this file""" |
|
if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""): |
|
return "Add comment" |
|
|
|
else: |
|
return self.vComment |
|
|
|
def manageVCommentForm(self): |
|
"""add a comment""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addVComment')).__of__(self) |
|
return pt() |
|
|
|
def manageVComment(self,text,comment_author,submit,REQUEST=None): |
|
"""manage comments""" |
|
if submit =='change': |
|
if text=='': |
|
self.vComment=None |
|
else: |
|
self.vComment=text |
|
self.vComment_author=comment_author |
|
|
|
self.vComment_date=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) |
|
|
|
return REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()+"/history") |
|
|
|
|
def getTime(self): |
def getTime(self): |
"""getTime""" |
"""getTime""" |
#return self.bobobase_modification_time().ISO() |
#return self.bobobase_modification_time().ISO() |
Line 242 class versionedFileObject(File):
|
Line 315 class versionedFileObject(File):
|
"""get version""" |
"""get version""" |
return self.versionNumber |
return self.versionNumber |
|
|
|
|
|
|
def lastEditor(self): |
def lastEditor(self): |
"""last Editor""" |
"""last Editor""" |
if hasattr(self,'author'): |
if hasattr(self,'author'): |
return self.author |
ret=self.author.replace("-","\n") |
|
ret=ret.replace("\r","\n") |
|
return ret |
|
|
else: |
else: |
jar=self._p_jar |
jar=self._p_jar |
oid=self._p_oid |
oid=self._p_oid |
Line 304 class versionedFile(Folder):
|
Line 382 class versionedFile(Folder):
|
self.lockedBy=lockedBy |
self.lockedBy=lockedBy |
self.author=author |
self.author=author |
|
|
|
def getComment(self): |
|
"""get the comment of this file""" |
|
if not hasattr(self,'comment') or (not self.comment) or (self.comment.lstrip()==""): |
|
return "Add comment" |
|
|
|
else: |
|
return self.comment |
|
|
|
|
meta_type="versionedFile" |
meta_type="versionedFile" |
|
|
|
def manageCommentForm(self): |
|
"""add a comment""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addComment')).__of__(self) |
|
return pt() |
|
|
|
def manageComment(self,text,comment_author,submit,REQUEST=None): |
|
"""manage comments""" |
|
if submit =='change': |
|
if text=='': |
|
self.comment=None |
|
else: |
|
self.comment=text |
|
self.comment_author=comment_author |
|
|
|
self.comment_date=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) |
|
|
|
return REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()) |
|
|
def getLastVersion(self): |
def getLastVersion(self): |
"""Last Version""" |
"""Last Version""" |
Line 360 class versionedFile(Folder):
|
Line 463 class versionedFile(Folder):
|
ret.sort(sortv) |
ret.sort(sortv) |
return ret |
return ret |
|
|
|
security.declareProtected('AUTHENTICATED_USER','forceunlock') |
|
def forceunlock(self,RESPONSE): |
|
"""unlock""" |
|
self.lockedBy='' |
|
|
security.declareProtected('AUTHENTICATED_USER','unlock') |
security.declareProtected('AUTHENTICATED_USER','unlock') |
def unlock(self,RESPONSE): |
def unlock(self,RESPONSE): |
"""unlock""" |
"""unlock""" |
Line 370 class versionedFile(Folder):
|
Line 478 class versionedFile(Folder):
|
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']) |
|
|
|
|
|
|
security.declareProtected('AUTHENTICATED_USER','addVersionedFileObjectForm') |
security.declareProtected('AUTHENTICATED_USER','addVersionedFileObjectForm') |
|
|
def addVersionedFileObjectForm(self): |
def addVersionedFileObjectForm(self): |
Line 390 class versionedFile(Folder):
|
Line 499 class versionedFile(Folder):
|
author=self.REQUEST['author'] |
author=self.REQUEST['author'] |
|
|
if changeName=="yes": |
if changeName=="yes": |
self.title=file.filename[0:] |
filename=file.filename |
|
self.title=filename[max(filename.rfind('/'), |
|
filename.rfind('\\'), |
|
filename.rfind(':'), |
|
)+1:] |
|
|
|
|
if not newName=='': |
if not newName=='': |
self.title=newName[0:] |
self.title=newName[0:] |
|
|
id="V%i"%self.getVersion()+"_"+self.title |
id="V%i"%self.getVersion()+"_"+self.title |
|
|
manage_addVersionedFileObject(self,id,vC,author,file,"V%i"%self.getVersion()+"_"+self.title,precondition, content_type) |
manage_addVersionedFileObject(self,id,vC,author,file,"V%i"%self.getVersion()+"_"+self.title,precondition, content_type) |
objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion())) |
objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion())) |
|
self.REQUEST.SESSION['objID_parent']=self.getId() |
|
|
if RESPONSE: |
if RESPONSE: |
|
obj=self.ZopeFind(self,obj_ids=[id])[0][1] |
|
if obj.getSize()==0: |
|
self.REQUEST.SESSION['objID']=obj.getId() |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','errorUploadFile')).__of__(self) |
|
return pt() |
|
|
|
else: |
RESPONSE.redirect(self.REQUEST['URL2']) |
RESPONSE.redirect(self.REQUEST['URL2']) |
|
|
|
else: |
|
return self.ZopeFind(self,obj_ids=[id])[0][1] |
|
|
security.declareProtected('AUTHENTICATED_USER','downloadLocked') |
security.declareProtected('AUTHENTICATED_USER','downloadLocked') |
|
|
def download(self): |
def download(self): |