version 1.71, 2008/08/05 16:47:15
|
version 1.76, 2008/09/05 23:15:57
|
Line 2
|
Line 2
|
This module contains extensions which where originally made for the VLP. |
This module contains extensions which where originally made for the VLP. |
""" |
""" |
from OFS.Cache import Cacheable |
from OFS.Cache import Cacheable |
from Products.ECHO_content.ECHO_collection import * |
|
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
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 OFS.Image import File |
from OFS.Image import File |
try: |
|
from Products.zogiLib import zogiLib |
|
except: |
|
print "Zogilib not installed, VLP_resource will not work" |
|
|
|
import xml.dom.minidom |
import xml.dom.minidom |
import urllib |
import urllib |
import xmlrpclib |
import xmlrpclib |
Line 23 from types import *
|
Line 17 from types import *
|
from Globals import package_home |
from Globals import package_home |
import transaction |
import transaction |
|
|
|
from Products.ECHO_content.ECHO_collection import * |
|
from vlp_xmlhelpers import * |
|
try: |
|
from Products.zogiLib import zogiLib |
|
except: |
|
print "Zogilib not installed, VLP_resource will not work" |
|
|
|
|
def lemmatize(str): |
def lemmatize(str): |
"""takes a str and addes links the dictionary service""" |
"""takes a str and addes links the dictionary service""" |
Line 52 def checkXMLfrag(str):
|
Line 53 def checkXMLfrag(str):
|
|
|
xmltempl = """<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
xmltempl = """<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
<txt>%s</txt>""" |
<txt>%s</txt>""" |
|
|
try: |
try: |
dom=xml.dom.minidom.parseString(xmltempl%str) |
dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str)) |
return str |
return str |
except: |
except: |
str=str.replace("& ","& ") |
str=str.replace("& ","& ") |
|
|
dom=xml.dom.minidom.parseString(xmltempl%str) |
dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str)) |
return str |
return str |
|
|
|
|
Line 246 class VLP_essay(Folder):
|
Line 248 class VLP_essay(Folder):
|
|
|
pages = self.objectItems(['DTML Document','File']) |
pages = self.objectItems(['DTML Document','File']) |
pages.sort(sortFind) |
pages.sort(sortFind) |
|
#logging.debug("pageList=%s"%repr(pages)) |
return pages |
return pages |
|
|
|
|
Line 262 class VLP_essay(Folder):
|
Line 265 class VLP_essay(Folder):
|
|
|
if pageObj is not None: |
if pageObj is not None: |
txt = "" |
txt = "" |
|
if pageObj.meta_type == 'File': |
data = pageObj.data |
data = pageObj.data |
|
#logging.debug("data=%s txt=%s"%(repr(data),txt)) |
while data is not None: |
while data is not None: |
txt += data |
|
if isinstance(data, str): |
if isinstance(data, str): |
|
txt += data |
data = None |
data = None |
else: |
else: |
|
txt += data.data |
data = data.next |
data = data.next |
|
|
|
else: |
|
# not a File object... perhaps its executable |
|
txt += pageObj() |
|
|
xml = checkXMLfrag(txt) |
xml = checkXMLfrag(txt) |
|
|
return xml |
return unicodify(xml) |
|
|
|
|
def getPage(self,pagenum): |
def getPage(self,pagenum): |
Line 552 class VLP_collection(ECHO_collection):
|
Line 562 class VLP_collection(ECHO_collection):
|
RESPONSE.write("<html><body>") |
RESPONSE.write("<html><body>") |
|
|
files=os.listdir(self.vlp_basis) |
files=os.listdir(self.vlp_basis) |
|
i=0 |
for fileName in files: |
for fileName in files: |
|
if i<100: |
|
i+=1 |
|
else: |
|
i=0 |
|
j=0 |
|
while j<5: |
|
try: |
|
transaction.get().commit() |
|
j=6 |
|
except: |
|
logging.error("Commit: %s"%j) |
|
j+=1 |
|
|
|
RESPONSE.write("<p>committed</p>") |
if fileName[0:3]=="lit": |
if fileName[0:3]=="lit": |
metalink=self.REQUEST['URL1']+"/"+fileName+"/index_meta" |
metalink=self.REQUEST['URL1']+"/"+fileName+"/index_meta" |
try: |
try: |
Line 699 class VLP_resource(ECHO_resource,Cacheab
|
Line 724 class VLP_resource(ECHO_resource,Cacheab
|
|
|
|
|
|
|
|
def identifyMediaType(self): |
|
"""identifiziert den Medientype aus der VLP Datenbank""" |
|
founds=self.ZSQLSimpleSearch('select * from vl_literature where reference=\''+self.resourceID+'\' order by id') |
|
if (not founds) or (len(founds)==0): |
|
self.mediaType="generic" # steht nicht in der Datenbank, dann nimm generisch an |
|
return self.mediaType |
|
|
|
|
|
if founds[0].referencetype =="Audio": |
|
self.mediaType ="audio" |
|
elif founds[0].referencetype =="Film": |
|
self.mediaType ="video" |
|
else: |
|
self.mediaType ="image" # nimm an, dass alle anderen Eintrage in der Datenbank auf images verweisen (Buecher oder Fotografien). |
|
|
|
return self.mediaType |
|
|
|
def getMediaType(self,cached=False): |
|
"""give the Media-type back, if chached False, then get it from the database""" |
|
|
|
if (not hasattr(self,'mediaType')) or (self.mediaType=="") or (not cached): |
|
self.identifyMediaType() |
|
|
|
return self.mediaType |
|
|
|
|
|
|
|
|
def copyTranscriptionFromDB(self): |
def copyTranscriptionFromDB(self): |
"""checks if transcription exits in DB""" |
"""checks if transcription exits in DB""" |
founds=self.ZSQLSimpleSearch('select * from vl_transcript where source=\''+self.resourceID+'\' order by id') |
founds=self.ZSQLSimpleSearch('select * from vl_transcript where source=\''+self.resourceID+'\' order by id') |
Line 753 class VLP_resource(ECHO_resource,Cacheab
|
Line 806 class VLP_resource(ECHO_resource,Cacheab
|
def show(self): |
def show(self): |
"""show the rendered file""" |
"""show the rendered file""" |
|
|
if self.REQUEST.get('p',None): |
mt = self.getMediaType() |
|
|
|
if (mt in ['video','audio']): |
|
pt = self.getVLPTemplate('libraryMovieTemplate') |
|
else: #zur zeit werden alle anderen type auf das libraryTemplate abgebildet. |
|
|
|
if self.REQUEST.get('p',None): #make sure that parameter p exists |
#self.REQUEST.set('pn',self.file2page(self.REQUEST.get('p',None))) |
#self.REQUEST.set('pn',self.file2page(self.REQUEST.get('p',None))) |
params = "pn=%s"%self.file2page(self.REQUEST.get('p',None)) |
params = "pn=%s"%self.file2page(self.REQUEST.get('p',None)) |
mk = self.REQUEST.get('mk',None) |
mk = self.REQUEST.get('mk',None) |
Line 761 class VLP_resource(ECHO_resource,Cacheab
|
Line 820 class VLP_resource(ECHO_resource,Cacheab
|
params += "&mk=%s"%mk |
params += "&mk=%s"%mk |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL']+'?'+params) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL']+'?'+params) |
|
|
if hasattr(self,'libraryTemplate.html'): |
pt = self.getVLPTemplate('libraryTemplate') |
return getattr(self,'libraryTemplate.html')() |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'vlp','library_template.zpt')).__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
return pt() |
|
|
|
def getVLPTemplate(self,name): |
|
html=name+".html" |
|
if hasattr(self,html): |
|
return getattr(self,html) |
|
|
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'vlp',name+'.zpt')).__of__(self) |
|
pt.content_type="text/html" |
|
return pt |
|
|
def index_html(self): |
def index_html(self): |
"""index_html""" |
"""index_html""" |
#return self.REQUEST |
#return self.REQUEST |