[Erp5-report] r20593 - in /erp5/trunk/products/ERP5OOo: ./ dtml/ www/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Apr 16 20:16:30 CEST 2008
Author: nicolas
Date: Wed Apr 16 20:16:30 2008
New Revision: 20593
URL: http://svn.erp5.org?rev=20593&view=rev
Log:
Support Editing of Any XML File contained in ODF Archive
Modified:
erp5/trunk/products/ERP5OOo/OOoTemplate.py
erp5/trunk/products/ERP5OOo/OOoUtils.py
erp5/trunk/products/ERP5OOo/dtml/OOoTemplate_add.dtml
erp5/trunk/products/ERP5OOo/www/formSettings.zpt
Modified: erp5/trunk/products/ERP5OOo/OOoTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoTemplate.py?rev=20593&r1=20592&r2=20593&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoTemplate.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoTemplate.py Wed Apr 16 20:16:30 2008
@@ -63,15 +63,16 @@
# Constructors
manage_addOOoTemplate = DTMLFile("dtml/OOoTemplate_add", globals())
-def addOOoTemplate(self, id, title="", REQUEST=None):
+def addOOoTemplate(self, id, title="", xml_file_id="content.xml", REQUEST=None):
"""Add OOo template to folder.
id -- the id of the new OOo template to add
title -- the title of the OOo to add
+ xml_file_id -- The Id of edited xml file
Result -- empty string
"""
# add actual object
- id = self._setObject(id, OOoTemplate(id, title))
+ id = self._setObject(id, OOoTemplate(id, title, xml_file_id))
if REQUEST is not None:
file = REQUEST.form.get('file')
if file.filename:
@@ -142,6 +143,7 @@
# Default Attributes
ooo_stylesheet = 'Base_getODTStyleSheet'
+ ooo_xml_file_id = 'content.xml'
# Default content type
#content_type = 'application/vnd.sun.xml.writer' # Writer type by default
@@ -160,11 +162,11 @@
__name__='formSettings')
formSettings._owner = None
- def __init__(self,*args,**kw):
- ZopePageTemplate.__init__(self,*args,**kw)
+ def __init__(self, id, title, xml_file_id='content.xml', *args,**kw):
+ ZopePageTemplate.__init__(self, id, title, *args, **kw)
# we store the attachments of the uploaded document
self.OLE_documents_zipstring = None
-
+ self.ooo_xml_file_id = xml_file_id
# Every OOoTemplate uses UTF-8 or Unicode, so a special StringIO class
# must be used, which does not care about response.
def StringIO(self):
@@ -207,8 +209,7 @@
xsl_content = None
if xsl_dtml is not None:
xsl_content = xsl_dtml()
- file = builder.prepareContentXml(xsl_content)
-
+ file = builder.prepareContentXml(self.ooo_xml_file_id, xsl_content)
return ZopePageTemplate.pt_upload(self, REQUEST, file)
security.declareProtected('Change Page Templates', 'pt_edit')
@@ -220,13 +221,14 @@
self.write(text)
security.declareProtected('Change Page Templates', 'doSettings')
- def doSettings(self, REQUEST, title, ooo_stylesheet):
+ def doSettings(self, REQUEST, title, xml_file_id, ooo_stylesheet):
"""
- Change title and ooo_stylesheet.
+ Change title, xml_file_id and ooo_stylesheet.
"""
if SUPPORTS_WEBDAV_LOCKS and self.wl_isLocked():
raise ResourceLockedError, "File is locked via WebDAV"
self.ooo_stylesheet = ooo_stylesheet
+ self.ooo_xml_file_id = xml_file_id
self.pt_setTitle(title)
#REQUEST.set('text', self.read()) # May not equal 'text'!
message = "Saved changes."
@@ -507,7 +509,7 @@
return doc_xml
# Replace content.xml in master openoffice template
- ooo_builder.replace('content.xml', doc_xml)
+ ooo_builder.replace(self.ooo_xml_file_id, doc_xml)
# Old templates correction
try:
Modified: erp5/trunk/products/ERP5OOo/OOoUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoUtils.py?rev=20593&r1=20592&r2=20593&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoUtils.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoUtils.py Wed Apr 16 20:16:30 2008
@@ -134,13 +134,13 @@
def getMimeType(self):
return self.extract('mimetype')
- def prepareContentXml(self, xsl_content=None):
+ def prepareContentXml(self, ooo_xml_file_id, xsl_content=None):
"""
extracts content.xml text and prepare it :
- add tal namespace
- indent the xml
"""
- content_xml = self.extract('content.xml')
+ content_xml = self.extract(ooo_xml_file_id)
output = StringIO()
try:
import libxml2
@@ -156,9 +156,6 @@
tal = root.newNs('http://xml.zope.org/namespaces/tal', 'tal')
i18n = root.newNs('http://xml.zope.org/namespaces/i18n', 'i18n')
metal = root.newNs('http://xml.zope.org/namespaces/metal', 'metal')
- root.setNs(tal)
- root.setNs(i18n)
- root.setNs(metal)
root.setNsProp(tal, 'attributes', 'dummy python:request.RESPONSE.setHeader(\'Content-Type\', \'text/html;; charset=utf-8\')')
buff = libxml2.createOutputBuffer(output, 'utf-8')
result_doc.saveFormatFileTo(buff, 'utf-8', 1)
Modified: erp5/trunk/products/ERP5OOo/dtml/OOoTemplate_add.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/dtml/OOoTemplate_add.dtml?rev=20593&r1=20592&r2=20593&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/dtml/OOoTemplate_add.dtml (original)
+++ erp5/trunk/products/ERP5OOo/dtml/OOoTemplate_add.dtml Wed Apr 16 20:16:30 2008
@@ -36,6 +36,23 @@
<tr>
<td align="left" valign="top">
+ <div class="form-label">
+ Edited XML File Id
+ </div>
+ </td>
+ <td align="left" valign="top">
+ <select type="select" name="xml_file_id">
+ <option value=""></option>
+ <option value="content.xml" selected="selected">Content</option>
+ <option value="styles.xml">Styles</option>
+ <option value="meta.xml">Meta</option>
+ <option value="settings.xml">Settings</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td align="left" valign="top">
<div class="form-optional">
File
</div>
Modified: erp5/trunk/products/ERP5OOo/www/formSettings.zpt
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/www/formSettings.zpt?rev=20593&r1=20592&r2=20593&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/www/formSettings.zpt (original)
+++ erp5/trunk/products/ERP5OOo/www/formSettings.zpt Wed Apr 16 20:16:30 2008
@@ -11,11 +11,16 @@
tal:attributes="value request/title | here/title | nothing"/></td>
</tr>
<tr>
+ <td class="form-label">OOo XML File Id (Manipulated File)</td>
+ <td><input name="xml_file_id" value="default_xml_file_id"
+ type="text" size="20"
+ tal:attributes="value request/ooo_xml_file_id | here/ooo_xml_file_id | nothing"/></td>
+ </tr>
+ <tr>
<td class="form-label">OOo Stylesheet (Master Document)</td>
<td><input name="ooo_stylesheet" value="default_ooo_template" type="text" size="20"
tal:attributes="value request/ooo_stylesheet | here/ooo_stylesheet | nothing"/></td>
</tr>
-
<tr>
<td align="left" valign="top">
<div class="form-element">
More information about the Erp5-report
mailing list