Changeset 486:f2c5417b7ff4 in documentViewer


Ignore:
Timestamp:
Aug 22, 2011, 3:00:28 PM (13 years ago)
Author:
casties
Branch:
elementtree
Message:

more new template stuff

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • __init__.py

    r130 r486  
    1313
    1414    context.registerClass(
    15         documentViewer.DocumentViewerTemplate,
    16         constructors = (
    17           documentViewer.manage_addDocumentViewerTemplateForm,
    18           documentViewer.manage_addDocumentViewerTemplate
    19           )
    20         )
    21 
    22     context.registerClass(
    2315        MpdlXmlTextServer.MpdlXmlTextServer,
    2416        constructors = (
  • documentViewer.py

    r483 r486  
    22from OFS.Image import File
    33from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
    4 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
     4from Products.PageTemplates.PageTemplateFile import PageTemplateFile
     5from Products.ZSimpleFile import ZSimpleFile
    56from AccessControl import ClassSecurityInfo
    67from AccessControl import getSecurityManager
     
    140141    info_xml = PageTemplateFile('zpt/info_xml', globals())
    141142    # TODO: can this be nicer?
    142     docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css')
     143    docuviewer_css = ZSimpleFile(content_type='text/css',filename='css/docuviewer.css', id='docuviewer_css',_prefix=globals())
    143144   
    144145   
     
    920921    if RESPONSE is not None:
    921922        RESPONSE.redirect('manage_main')
    922 
    923 ## DocumentViewerTemplate class
    924 class DocumentViewerTemplate(ZopePageTemplate):
    925     """Template for document viewer"""
    926     meta_type="DocumentViewer Template"
    927 
    928 
    929 def manage_addDocumentViewerTemplateForm(self):
    930     """Form for adding"""
    931     pt=PageTemplateFile('zpt/addDocumentViewerTemplate', globals()).__of__(self)
    932     return pt()
    933 
    934 def manage_addDocumentViewerTemplate(self, id='viewer_main', title=None, text=None,
    935                            REQUEST=None, submit=None):
    936     "Add a Page Template with optional file content."
    937 
    938     self._setObject(id, DocumentViewerTemplate(id))
    939     ob = getattr(self, id)
    940     txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read()
    941     logging.info("txt %s:"%txt)
    942     ob.pt_edit(txt,"text/html")
    943     if title:
    944         ob.pt_setTitle(title)
    945     try:
    946         u = self.DestinationURL()
    947     except AttributeError:
    948         u = REQUEST['URL1']
    949        
    950     u = "%s/%s" % (u, urllib.quote(id))
    951     REQUEST.RESPONSE.redirect(u+'/manage_main')
    952     return ''
    953 
    954 
    955    
Note: See TracChangeset for help on using the changeset viewer.