version 1.79, 2008/10/08 10:18:04
|
version 1.84, 2008/11/20 10:45:14
|
Line 520 class VLP_collection(ECHO_collection,Acq
|
Line 520 class VLP_collection(ECHO_collection,Acq
|
|
|
actual_url=request['ACTUAL_URL'] |
actual_url=request['ACTUAL_URL'] |
lastActual=actual_url.split("/")[-1] |
lastActual=actual_url.split("/")[-1] |
|
logging.debug("pub_trav:"+actual_url) |
|
|
if name.startswith("lit"): #umleitung wenn lit aufgerufen wirk |
if name.startswith("lit"): #umleitung wenn lit aufgerufen wirk |
# umleitung auf den eigentlichen folder nur wenn direkt der Folder litXXX oder dessen index_html methode aufgerufen wird |
# umleitung auf den eigentlichen folder nur wenn direkt der Folder litXXX oder dessen index_html methode aufgerufen wird |
if lastActual.startswith("lit") or (lastActual=="index_html"): |
if lastActual.startswith("lit") or (lastActual=="index_html") or (lastActual=="index_meta"): |
#obj=self. ZopeFind(self,obj_ids=[name],search_sub=1) |
#obj=self. ZopeFind(self,obj_ids=[name],search_sub=1) |
ob=self.findObjFromLitName(name) |
ob=self.findObjFromLitName(name) |
if not ob: |
if not ob: |
return "LIt not found" |
return "LIt not found" |
else: |
else: |
|
|
logging.error("request:"+repr(ob)) |
logging.debug("request:"+repr(ob)) |
request.response.setStatus(200) |
request.response.setStatus(200) |
|
#if (lastActual=="index_meta"): |
|
# logging.debug("index_meta requested") |
|
# return ob.index_meta |
return ob |
return ob |
|
|
else: ## andern falls transversiere zum parent. |
else: ## andern falls transversiere zum parent. |
obj = self.aq_parent |
obj = self.aq_parent |
return obj |
return obj |
Line 553 class VLP_collection(ECHO_collection,Acq
|
Line 557 class VLP_collection(ECHO_collection,Acq
|
{'label':'Update Library','action':'updateCollection'}, |
{'label':'Update Library','action':'updateCollection'}, |
{'label':'Update Metadata','action':'updateCollectionMD'}, |
{'label':'Update Metadata','action':'updateCollectionMD'}, |
) |
) |
|
def getAllRessources(self): |
|
"""getallressources""" |
|
res=self.ZopeFind(self,obj_metatypes=['VLP_resource'],search_sub=1) |
|
ret=[] |
|
for r in res: |
|
ret.append([r[0],r[1].absolute_url()]) |
|
|
|
return ret |
|
|
def generateSubCollections(self,errorsTXT="",forceUpdate=False,RESPONSE=None): |
def generateSubCollections(self,errorsTXT="",forceUpdate=False,RESPONSE=None): |
"""erzeuge subcollectionen""" |
"""erzeuge subcollectionen""" |
Line 570 class VLP_collection(ECHO_collection,Acq
|
Line 582 class VLP_collection(ECHO_collection,Acq
|
if foundCol: |
if foundCol: |
col = foundCol |
col = foundCol |
logging.debug("generateSubCollections: subcollection %s exists (%s)"%(repr(col),found.reference)) |
logging.debug("generateSubCollections: subcollection %s exists (%s)"%(repr(col),found.reference)) |
if (col.title != found.titlerefdisplay) or (col.label != found.titlerefdisplay): |
logging.debug(repr([col.title,found.titlerefdisplay,col.label,found.titlerefdisplay])) |
|
if (unicodify(col.title) != found.titlerefdisplay) or (unicodify(col.label) != found.titlerefdisplay): |
# subcollection seems to have changed |
# subcollection seems to have changed |
logging.debug("generateSubCollections: subcollection has changed, recreating!") |
logging.debug("generateSubCollections: subcollection has changed, recreating!") |
col.aq_parent.manage_delObjects([col.getId()]) |
col.aq_parent.manage_delObjects([col.getId()]) |
Line 599 class VLP_collection(ECHO_collection,Acq
|
Line 612 class VLP_collection(ECHO_collection,Acq
|
error=sys.exc_info()[0:2] |
error=sys.exc_info()[0:2] |
logging.error("generateSubCollections: ERROR in %s"%litid) |
logging.error("generateSubCollections: ERROR in %s"%litid) |
if RESPONSE is not None: |
if RESPONSE is not None: |
|
RESPONSE.write("<p>(ERROR updateII(%s): %s %s TXT: %s)\n</p>"%(litid,error[0],error[1],sys.exc_info()[2])) |
RESPONSE.write("<p>(ERROR (%s): %s %s)</p>\n"%(litid,error[0],error[1])) |
RESPONSE.write("<p>(ERROR (%s): %s %s)</p>\n"%(litid,error[0],error[1])) |
#logging.error("generateSubCollections: %s %s"%error) |
logging.error("generateSubCollections: %s %s"%error) |
#self.REQUEST.RESPONSE.write("(ERROR (%s): %s %s)\n"%(litid,repr(error[0]),repr(error[1]))) |
self.REQUEST.RESPONSE.write("(ERROR (%s): %s %s)\n"%(litid,repr(error[0]),repr(error[1]))) |
errorsTXT+="<p>ERROR: No subcollection of %s (ERROR: %s %s)</p>\n"%(litid,error[0],error[1]) |
errorsTXT+="<p>ERROR: No subcollection of %s (ERROR: %s %s)</p>\n"%(litid,error[0],error[1]) |
#errorsTXT+="<p>No subcollection of %s "%litid+"(ERROR: %s %s)</p>"%error |
errorsTXT+="<p>No subcollection of %s "%litid+"(ERROR: %s %s)</p>"%error |
|
|
return errorsTXT |
return errorsTXT |
|
|
Line 641 class VLP_collection(ECHO_collection,Acq
|
Line 655 class VLP_collection(ECHO_collection,Acq
|
|
|
return current |
return current |
|
|
def updateCollection(self,forceUpdate=False,RESPONSE=None): |
def changeOrAddResources(self,forceUpdate=False,RESPONSE=None): |
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
"""changes ord updates all resources found in the file system""" |
|
|
errorsTXT="<h2>Errors</h2>" |
errorsTXT="<h2>Errors</h2>" |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.setHeader('Content-Type','text/html') |
RESPONSE.setHeader('Content-Type','text/html') |
Line 699 class VLP_collection(ECHO_collection,Acq
|
Line 714 class VLP_collection(ECHO_collection,Acq
|
except: |
except: |
error=sys.exc_info()[0:2] |
error=sys.exc_info()[0:2] |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.write("(ERROR (%s): %s %s) "%(fileName,error[0],error[1])) |
RESPONSE.write("(ERROR Update(%s): %s %s %s) "%(fileName,error[0],error[1],sys.exc_info()[2])) |
errorsTXT+="<p>ERROR creating index for %s "%fileName+"(ERROR: %s %s)</p>\n"%error |
errorsTXT+="<p>ERROR creating index for %s "%fileName+"(ERROR: %s %s)</p>\n"%error |
|
|
# update pageSizeSum for subcollections |
# update pageSizeSum for subcollections |
Line 718 class VLP_collection(ECHO_collection,Acq
|
Line 733 class VLP_collection(ECHO_collection,Acq
|
error=sys.exc_info()[0:2] |
error=sys.exc_info()[0:2] |
logging.error("updateCollection: ERROR in %s (%s %s)"%(fileName,error[0],error[1])) |
logging.error("updateCollection: ERROR in %s (%s %s)"%(fileName,error[0],error[1])) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.write("<p>(ERROR (%s): %s %s)</p>\n"%(fileName,error[0],error[1])) |
RESPONSE.write("(ERROR updateII(%s): %s %s %s) "%(fileName,error[0],error[1],sys.exc_info()[2])) |
errorsTXT+="<p>File not created:%s (ERROR: %s %s)</p>\n"%(fileName,error[0],error[1]) |
errorsTXT+="<p>File not created:%s (ERROR: %s %s)</p>\n"%(fileName,error[0],error[1]) |
|
return errorsTXT |
|
|
|
def updateCollection(self,forceUpdate=False,RESPONSE=None): |
|
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
|
|
# update subcollections |
# update subcollections |
|
errorsTXT="" |
|
errorsTXT+=self.changeOrAddResources(forceUpdate, RESPONSE); |
errorsTXT+=self.generateSubCollections(forceUpdate=forceUpdate,RESPONSE=RESPONSE) |
errorsTXT+=self.generateSubCollections(forceUpdate=forceUpdate,RESPONSE=RESPONSE) |
errorsTXT+="\n" |
errorsTXT+="\n" |
if RESPONSE is not None: |
if RESPONSE is not None: |
Line 955 class VLP_resource(ECHO_resource,Cacheab
|
Line 976 class VLP_resource(ECHO_resource,Cacheab
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def index_meta(self): |
def index_meta(self,RESPONSE=None): |
"""index_meta""" |
"""index_meta""" |
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'vlp','index_meta.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'vlp','index_meta.zpt')).__of__(self) |
pt.content_type="text/html" |
pt.content_type="text/xml" |
return pt() |
x= pt.pt_render() |
|
#logging.debug("index_meta 4:"+x) |
|
if RESPONSE: |
|
RESPONSE.setHeader("Content-Type","text/xml") |
|
return x |
def file2page(self,p): |
def file2page(self,p): |
"""converts filename to pagenumber""" |
"""converts filename to pagenumber""" |
dom=xml.dom.minidom.parse(ECHO_helpers.urlopen(getattr(self,'index.xml').absolute_url())) |
|
|
#dom=xml.dom.minidom.parse(ECHO_helpers.urlopen(getattr(self,'index.xml').absolute_url())) |
|
index=getattr(self,'index.xml') |
|
|
|
txt=index.pt_render() |
|
dom=xml.dom.minidom.parseString(txt) |
|
|
for page in dom.getElementsByTagName('page'): |
for page in dom.getElementsByTagName('page'): |
# pageummer mit lo oder hi sind aequivalent |
# pageummer mit lo oder hi sind aequivalent |
if (page.getAttribute('file')==p) or ("%slo"%page.getAttribute('file')==p) or ("%shi"%page.getAttribute('file')==p): |
if (page.getAttribute('file')==p) or ("%slo"%page.getAttribute('file')==p) or ("%shi"%page.getAttribute('file')==p): |
return page.getAttribute('nr') |
nr=page.getAttribute('nr') |
|
|
|
return nr |
|
|
return 0 |
return 0 |
|
|