Changeset 975


Ignore:
Timestamp:
26.04.2010 23:56:32 (2 years ago)
Author:
zmsdev
Message:

Added prototype for epub export-filter.

Location:
ZMS/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • ZMS/trunk/_filtermanager.py

    r794 r975  
    2626from App.Common import package_home 
    2727from App.special_dtml import HTMLFile 
     28from Products.ExternalMethod import ExternalMethod 
     29from Products.PageTemplates import ZopePageTemplate 
     30from Products.PythonScripts import PythonScript 
     31from Products.ZSQLMethods import SQL 
    2832import ZPublisher.HTTPRequest 
    2933import copy 
     
    146150def setProcess(self, newId, newAcquired=0, newName='', newType='process', newCommand=None, zms_system=0): 
    147151  if newCommand is None: 
    148     if newType == 'DTML Method': 
    149       newCommand = [] 
    150       newCommand.append( '<!-- BO %s -->\n\n'%newId) 
    151       newCommand.append( '<!-- EO %s -->\n'%newId) 
    152       newCommand = ''.join( newCommand) 
    153     else: 
    154       newCommand = '' 
     152    newCommand = '' 
     153    if newType in [ 'DTML Method']: 
     154      newCommand += '<dtml-comment>--// BO '+ newId + ' //--</dtml-comment>\n' 
     155      newCommand += '\n' 
     156      newCommand += '<dtml-comment>--// EO '+ newId + ' //--</dtml-comment>\n' 
     157    elif newType in [ 'Script (Python)']: 
     158      newCommand += '# --// BO '+ newId + ' //--\n' 
     159      newCommand += '# Example code:\n' 
     160      newCommand += '\n' 
     161      newCommand += '# Import a standard function, and get the HTML request and response objects.\n' 
     162      newCommand += 'from Products.PythonScripts.standard import html_quote\n' 
     163      newCommand += 'request = container.REQUEST\n' 
     164      newCommand += 'RESPONSE =  request.RESPONSE\n' 
     165      newCommand += '\n' 
     166      newCommand += '# Return a string identifying this script.\n' 
     167      newCommand += 'print "This is the", script.meta_type, \'"%s"\' % script.getId(),\n' 
     168      newCommand += 'if script.title:\n' 
     169      newCommand += '    print "(%s)" % html_quote(script.title),\n' 
     170      newCommand += 'print "in", container.absolute_url()\n' 
     171      newCommand += 'return printed\n' 
     172      newCommand += '\n' 
     173      newCommand += '# --// EO '+ newId + ' //--\n' 
    155174  # Set method. 
    156   if newType == 'DTML Method': 
    157     container = self.getHome() 
    158     if newId in container.objectIds([newType]): 
    159       dtml_method = getattr( container, newId) 
    160       dtml_method.manage_edit( newName, newCommand) 
    161     else: 
     175  container = self.getHome() 
     176  if newType in [ 'DTML Method']: 
     177    if newId not in container.objectIds([newType]): 
    162178      container.manage_addDTMLMethod( newId, newName, newCommand) 
     179    newOb = getattr( container, newId) 
     180    newOb.manage_edit( newName, newCommand) 
     181    roles=[ 'Manager'] 
     182    newOb._proxy_roles=tuple(roles) 
     183  elif newType in [ 'Script (Python)']: 
     184    if newId not in container.objectIds([newType]): 
     185      PythonScript.manage_addPythonScript( container, newId) 
     186    newOb = getattr( container, newId) 
     187    newOb.ZPythonScript_setTitle( newName) 
     188    newOb.write(newCommand) 
     189    roles=[ 'Manager'] 
     190    newOb._proxy_roles=tuple(roles) 
    163191  # Set. 
    164192  obs = getRawProcesses(self) 
     
    188216    if key == id: 
    189217      # Delete method. 
    190       if cp[key].get('type','') == 'DTML Method': 
     218      if cp[key].get('type','') in [ 'DTML Method', 'External Method', 'Script (Python)']: 
    191219        container = self.getHome() 
    192220        dtml_method = getattr( container, id, None) 
    193221        if dtml_method is not None: 
    194           container.manage_delObjects( ids = [ id]) 
     222          container.manage_delObjects( ids=[id]) 
    195223    else: 
    196224      obs[key] = cp[key] 
     
    586614          transfilename = '%s/%s'%( folder, trans.getFilename()) 
    587615          _fileutil.exportObj( trans.getData(), transfilename) 
    588         if processType == 'DTML Method': 
     616        if processType in [ 'DTML Method', 'External Method', 'Script (Python)']: 
    589617          filename = processMethod(self, processId, filename, trans, REQUEST) 
    590618        else: 
     
    646674      # Synchronize type. 
    647675      try: 
    648         if process.get('type') == 'DTML Method': 
    649           container = self.getHome() 
     676        container = self.getHome() 
     677        if process.get('type') in [ 'DTML Method']: 
    650678          ob = getattr( container, process['id']) 
    651679          process['command'] = ob.raw 
     680        elif process.get('type') in [ 'Script (Python)']: 
     681          ob = getattr( container, process['id']) 
     682          process['command'] = ob.read() 
    652683      except: 
    653684        pass 
  • ZMS/trunk/_mimetypes.py

    r882 r975  
    2525""" Globals. """ 
    2626 
     27application_epub = "mime_type.application_epub+zip.gif" 
    2728application_msaccess = "mime_type.application_msaccess.gif" 
    2829application_mspowerpoint = "mime_type.application_mspowerpoint.gif" 
     
    5758 
    5859dctMimeType = { 
    59          'application/mspowerpoint':application_mspowerpoint 
     60         'application/epub+zip':application_epub 
     61        ,'application/mspowerpoint':application_mspowerpoint 
    6062        ,'application/vnd.ms-access':application_msaccess 
    6163        ,'application/vnd.ms-excel':application_x_excel 
    6264        ,'application/vnd.ms-powerpoint':application_mspowerpoint 
    63   ,'application/vnd.openxmlformats-officedocument.wordprocessingml.document':application_docx 
    64   ,'application/vnd.openxmlformats-officedocument.presentationml.presentation':application_pptx 
    65   ,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':application_xlsx 
     65        ,'application/vnd.openxmlformats-officedocument.wordprocessingml.document':application_docx 
     66        ,'application/vnd.openxmlformats-officedocument.presentationml.presentation':application_pptx 
     67        ,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':application_xlsx 
    6668        ,'application/msword':application_msword 
    6769        ,'application/octet-stream':application_octet_stream 
  • ZMS/trunk/changes.txt

    r974 r975  
    15021502[974] Added new template-set myZMStheme61 (based on JQuery UI). 
    15031503-------------------------------------------------- 
     15042010-04-26:zms2-2.12.1-975 
     1505[975] Added prototype for epub export-filter (@see epub-reader for Firefox http://www.epubread.com/de/). 
     1506-------------------------------------------------- 
  • ZMS/trunk/dtml/ZMS/manage_customizefilterform.dtml

    r750 r975  
    396396             <table cellspacing="1" cellpadding="0" border="0"> 
    397397             <dtml-let process="getProcess(filterProcess['id'])"> 
    398              <dtml-if "process.get('type','process') == 'DTML Method' or  
     398             <dtml-if "process.get('type','process') in ['DTML Method','External Method','Script (Python)'] or  
    399399                       process.get('command','').find('{trans}')>=0"> 
    400400              <tr> 
     
    792792      <td width="20" rowspan="2"><input class="form-element" type="radio" name="id" value="<dtml-var "process['id']">" onclick="radioOnClick(this,'<dtml-var URL0>');" checked="checked"></td> 
    793793      <td> 
    794        <dtml-if "process.get('type','process') == 'DTML Method'"> 
    795         <img src="/misc_/OFSP/dtmlmethod.gif" title="DTML Method" border="0" align="absmiddle"/> 
     794       <dtml-if "process.get('type','process') in ['DTML Method','External Method','Script (Python)']"> 
     795        <img src="<dtml-var "getattr(this(),process['id']).icon">" title="<dtml-var "process['type']">" border="0" align="absmiddle"/> 
    796796       <dtml-else> 
    797797        <img src="<dtml-var MISC_ZMS>process.gif" title="process" border="0" align="absmiddle"/> 
     
    835835       <td class="form-small"><input class="form-element" type="radio" name="id" value="<dtml-var "process['id']">" onclick="radioOnClick(this,'<dtml-var URL0>');"></td> 
    836836       <td class="form-small" nowrap="nowrap"> 
    837         <dtml-if "process.get('type','process') == 'DTML Method'"> 
    838          <img src="/misc_/OFSP/dtmlmethod.gif" title="DTML Method" border="0" align="absmiddle"/> 
     837        <dtml-if "process.get('type','process') in ['DTML Method','External Method','Script (Python)']"> 
     838         <img src="<dtml-var "getattr(this(),process['id']).icon">" title="<dtml-var "process['type']">" border="0" align="absmiddle"/> 
    839839        <dtml-else> 
    840840         <img src="<dtml-var MISC_ZMS>process.gif" title="process" border="0" align="absmiddle"/> 
     
    890890      <option value="process"><dtml-var "getZMILangStr('ATTR_COMMANDLINE')"></option> 
    891891      <option value="DTML Method">DTML Method</option> 
     892      <option value="Script (Python)">Script (Python)</option> 
    892893     </select> 
    893894    <tr><td align="right" class="form-small"><dtml-var "getZMILangStr('ATTR_TYPE')"></td></tr> 
  • ZMS/trunk/import/enum.content_type.xml

    r121 r975  
    55<item key="text/html; charset=utf-8">HTML (UTF-8)</item> 
    66<item key="image/jpeg">JPEG</item> 
     7<item key="application/epub+zip">Epub</item> 
    78<item key="application/x-excel">MS Excel</item> 
    89<item key="application/x-ms-reader">MS Reader</item> 
  • ZMS/trunk/version.txt

    r974 r975  
    1 ZMS2 2.12.1-974 
     1ZMS2 2.12.1-975 
Note: See TracChangeset for help on using the changeset viewer.