version 1.111, 2009/06/22 10:48:35
|
version 1.115, 2010/03/19 14:01:41
|
Line 90 class CDLIFileObject(CatalogAware,extVer
|
Line 90 class CDLIFileObject(CatalogAware,extVer
|
def getPNumber(self): |
def getPNumber(self): |
"""get the pnumber""" |
"""get the pnumber""" |
try: |
try: |
txt=re.match("&[Pp](\d*)\s*=([^\r\n]*)",self.getData()[0:]) |
txt=re.match("&[PpSs](\d*)\s*=([^\r\n]*)",self.getData()[0:]) |
except: |
except: |
txt=self.getData()[0:] |
txt=self.getData()[0:] |
|
|
Line 104 class CDLIFileObject(CatalogAware,extVer
|
Line 104 class CDLIFileObject(CatalogAware,extVer
|
def getDesignation(self): |
def getDesignation(self): |
"""get the designation out of the file""" |
"""get the designation out of the file""" |
try: |
try: |
txt=re.match("&[Pp](\d*)\s*=([^\r\n]*)",self.getData()[0:]) |
txt=re.match("&[PpSs](\d*)\s*=([^\r\n]*)",self.getData()[0:]) |
except: |
except: |
txt=self.getData()[0:] |
txt=self.getData()[0:] |
|
|
Line 318 def checkFile(filename,data,folder):
|
Line 318 def checkFile(filename,data,folder):
|
# first check the file name |
# first check the file name |
fn=filename.split(".") # no extension |
fn=filename.split(".") # no extension |
|
|
if not fn[0][0]=="P": |
if not (fn[0][0]=="P" or fn[0][0]=="S"): |
return False,"P missing in the filename" |
return False,"P/S missing in the filename" |
elif len(fn[0])!=7: |
elif len(fn[0])!=7: |
return False,"P number has not the right length 6" |
return False,"P number has not the right length 6" |
elif not checkUTF8(data): |
elif not checkUTF8(data): |
Line 794 class CDLIRoot(Folder):
|
Line 794 class CDLIRoot(Folder):
|
RESPONSE.redirect(ob[0].absolute_url+"/unlock") |
RESPONSE.redirect(ob[0].absolute_url+"/unlock") |
return "not found" |
return "not found" |
|
|
|
|
def getFileObject(self,fileId): |
def getFileObject(self,fileId): |
"""get an object""" |
"""get an object""" |
|
logging.debug("getFileObj:"+repr(fileId)) |
if isinstance(fileId,CDLIFileObject): # support for old baskets |
if isinstance(fileId,CDLIFileObject): # support for old baskets |
return fileId |
return fileId |
x=self.v_files.get(fileId) |
x=self.v_files.get(fileId) |
#logging.debug("getFileObj:"+repr(fileId)) |
logging.debug("obj: "+repr(x)) |
|
if x==None: |
|
folder=fileId[0:3] |
|
f2=fileId[0:5] |
|
fObj = getattr(self.cdliRoot.cdli_main,folder); |
|
f2Obj = getattr(fObj,f2) |
|
|
|
o = getattr(f2Obj,fileId) |
|
logging.debug(o); |
|
self.updateOrAddToFileBTree(o) |
|
return o |
return x |
return x |
|
|
def getFileObjectLastVersion(self,fileId): |
def getFileObjectLastVersion(self,fileId): |
"""get an object""" |
"""get an object""" |
x=self.v_files_lastVersion.get(fileId) |
x=self.v_files_lastVersion.get(fileId) |
#logging.debug("lastVersion: "+repr(x)) |
logging.debug("lastVersion: "+repr(x)) |
|
if x==None: |
|
folder=fileId[0:3] |
|
f2=fileId[0:5] |
|
fObj = getattr(self.cdliRoot.cdli_main,folder); |
|
f2Obj = getattr(fObj,f2) |
|
|
|
o =getattr(f2Obj,fileId) |
|
logging.debug(o); |
|
return o.getLastVersion() |
|
|
|
|
return x |
return x |
|
|
def showFileIds(self): |
def showFileIds(self): |
Line 834 class CDLIRoot(Folder):
|
Line 857 class CDLIRoot(Folder):
|
self.v_files_lastVersion.update({obj.getId():obj.getLastVersion()}) |
self.v_files_lastVersion.update({obj.getId():obj.getLastVersion()}) |
|
|
self.v_file_ids.add(obj.getId()) |
self.v_file_ids.add(obj.getId()) |
|
#change everthing around to make it persistent... |
|
tmp = self.v_files |
|
self.v_files=tmp |
|
|
|
tmp2=self.v_file_ids |
|
self.v_file_ids=tmp2 |
|
|
|
self.CDLICache.cleanCache() #be sure that the cache is clean |
logging.debug("update:"+obj.getId()+"XXX"+repr(obj)) |
logging.debug("update:"+obj.getId()+"XXX"+repr(obj)) |
|
|
|
|
def deleteFromBTree(self,objId): |
def deleteFromBTree(self,objId): |
"""delete an obj""" |
"""delete an obj""" |
self.v_files.pop(objId) |
self.v_files.pop(objId) |
Line 968 class CDLIRoot(Folder):
|
Line 1000 class CDLIRoot(Folder):
|
if line.lstrip().startswith('#lem:'): |
if line.lstrip().startswith('#lem:'): |
continue |
continue |
# ignore p-num line |
# ignore p-num line |
if line.startswith('&P'): |
if line.startswith('&P') or line.startswith('&S'): |
continue |
continue |
# ignore version lines |
# ignore version lines |
if line.startswith('#version'): |
if line.startswith('#version'): |
Line 1059 class CDLIRoot(Folder):
|
Line 1091 class CDLIRoot(Folder):
|
lv.author=user |
lv.author=user |
lv.versionComment="XXXXXXX" |
lv.versionComment="XXXXXXX" |
|
|
|
def forceunlock(self,REQUEST=None,user=None,fid=None): |
|
|
gen |
|
def forceunlock(self,REQUEST=None,user=None): |
|
"break all locks" |
"break all locks" |
|
if fid is not None: |
|
self.getFileObject(fid).forceunlock() |
|
return fid |
ret=[] |
ret=[] |
|
|
for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1): |
for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1): |
Line 1084 class CDLIRoot(Folder):
|
Line 1116 class CDLIRoot(Folder):
|
"""hole alle gesperrten files""" |
"""hole alle gesperrten files""" |
ret={} |
ret={} |
|
|
for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1): |
for nm,f in self.v_files.items(): |
lb = f[1].lockedBy |
lb = str(f.lockedBy) |
add=False |
add=False |
if (lb is not None) and (lb!=""): |
if (lb is not None) and (lb!=""): |
|
|
Line 1097 class CDLIRoot(Folder):
|
Line 1129 class CDLIRoot(Folder):
|
if add==True: |
if add==True: |
if not ret.has_key(lb): |
if not ret.has_key(lb): |
ret[lb]=[] |
ret[lb]=[] |
ret[lb].append(f[0]) |
ret[lb].append(nm) |
|
|
|
|
if REQUEST is not None: |
if REQUEST is not None: |
Line 1282 class CDLIRoot(Folder):
|
Line 1314 class CDLIRoot(Folder):
|
|
|
def uploadATFfinally(self,procedure='',comment="",basketname='',unlock=None,repeat=None,RESPONSE=None): |
def uploadATFfinally(self,procedure='',comment="",basketname='',unlock=None,repeat=None,RESPONSE=None): |
"""nowupload the files""" |
"""nowupload the files""" |
|
|
|
|
|
|
threadName=repeat |
threadName=repeat |
if not threadName or threadName=="": |
if not threadName or threadName=="": |
thread=uploadATFfinallyThread() |
thread=uploadATFfinallyThread() |
Line 1344 class CDLIRoot(Folder):
|
Line 1373 class CDLIRoot(Folder):
|
try: |
try: |
self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject()) |
self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject()) |
except: |
except: |
|
|
logging.error("uploadATFfinally - cannot update Object %s Error: %s %s"%(ob[1],sys.exc_info()[0],sys.exc_info()[1])) |
logging.error("uploadATFfinally - cannot update Object %s Error: %s %s"%(ob[1],sys.exc_info()[0],sys.exc_info()[1])) |
|
for x in stObj.returnValue['newPs']: |
|
obj=self.getFileObject(x) #updates the object in the cache |
|
logging.debug("Got:"+repr(obj)) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect(self.absolute_url()) |
RESPONSE.redirect(self.absolute_url()) |
|
|
Line 1391 class CDLIRoot(Folder):
|
Line 1424 class CDLIRoot(Folder):
|
id=f |
id=f |
logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2))) |
logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2))) |
fobj2.addFile(vC='',file=file(file2),author=author,newName=f) |
fobj2.addFile(vC='',file=file(file2),author=author,newName=f) |
|
logging.debug("importfiles: fobj2.add") |
count+=1 |
count+=1 |
|
|
#now add the file to the storage |
#now add the file to the storage |
ob = getattr(fobj2,f) |
ob = getattr(fobj2,f) |
self.cdliRoot.updateOrAddToFileBTree(ob) |
logging.debug("importfiles: btree_start") |
|
#self.cdliRoot.updateOrAddToFileBTree(ob) |
|
logging.debug("importfiles: btree_end") |
if count%100==0: |
if count%100==0: |
logging.debug("importfiles: committing") |
logging.debug("importfiles: committing") |
transaction.get().commit() |
transaction.get().commit() |
|
|
|
logging.debug("importfiles: committing") |
transaction.get().commit() |
transaction.get().commit() |
|
logging.debug("importfiles: committing done") |
return "ok" |
return "ok" |
|
|
|
|