Mercurial > hg > documentViewer
changeset 486:f2c5417b7ff4 elementtree
more new template stuff
author | casties |
---|---|
date | Mon, 22 Aug 2011 17:00:28 +0200 |
parents | 1e51d440f08b |
children | 8fd6f26fe29e |
files | __init__.py documentViewer.py |
diffstat | 2 files changed, 3 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py Mon Aug 22 11:12:42 2011 +0200 +++ b/__init__.py Mon Aug 22 17:00:28 2011 +0200 @@ -12,14 +12,6 @@ ) context.registerClass( - documentViewer.DocumentViewerTemplate, - constructors = ( - documentViewer.manage_addDocumentViewerTemplateForm, - documentViewer.manage_addDocumentViewerTemplate - ) - ) - - context.registerClass( MpdlXmlTextServer.MpdlXmlTextServer, constructors = ( MpdlXmlTextServer.manage_addMpdlXmlTextServerForm,
--- a/documentViewer.py Mon Aug 22 11:12:42 2011 +0200 +++ b/documentViewer.py Mon Aug 22 17:00:28 2011 +0200 @@ -1,7 +1,8 @@ from OFS.Folder import Folder from OFS.Image import File from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate -from Products.PageTemplates.PageTemplateFile import PageTemplateFile +from Products.PageTemplates.PageTemplateFile import PageTemplateFile +from Products.ZSimpleFile import ZSimpleFile from AccessControl import ClassSecurityInfo from AccessControl import getSecurityManager from Globals import package_home @@ -139,7 +140,7 @@ head_main = PageTemplateFile('zpt/head_main', globals()) info_xml = PageTemplateFile('zpt/info_xml', globals()) # TODO: can this be nicer? - docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css') + docuviewer_css = ZSimpleFile(content_type='text/css',filename='css/docuviewer.css', id='docuviewer_css',_prefix=globals()) thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) @@ -919,37 +920,3 @@ if RESPONSE is not None: RESPONSE.redirect('manage_main') - -## DocumentViewerTemplate class -class DocumentViewerTemplate(ZopePageTemplate): - """Template for document viewer""" - meta_type="DocumentViewer Template" - - -def manage_addDocumentViewerTemplateForm(self): - """Form for adding""" - pt=PageTemplateFile('zpt/addDocumentViewerTemplate', globals()).__of__(self) - return pt() - -def manage_addDocumentViewerTemplate(self, id='viewer_main', title=None, text=None, - REQUEST=None, submit=None): - "Add a Page Template with optional file content." - - self._setObject(id, DocumentViewerTemplate(id)) - ob = getattr(self, id) - txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read() - logging.info("txt %s:"%txt) - ob.pt_edit(txt,"text/html") - if title: - ob.pt_setTitle(title) - try: - u = self.DestinationURL() - except AttributeError: - u = REQUEST['URL1'] - - u = "%s/%s" % (u, urllib.quote(id)) - REQUEST.RESPONSE.redirect(u+'/manage_main') - return '' - - -