[Zope-CVS] SVN: PluginRegistry/trunk/ Wired in DAV / FTP /
ExternalEditor support for the registry,
along with a ZMI form for updating it as XML.
Tres Seaver
tseaver at palladion.com
Fri Nov 4 17:53:48 EST 2005
Log message for revision 39898:
Wired in DAV / FTP / ExternalEditor support for the registry, along with a ZMI form for updating it as XML.
Changed:
U PluginRegistry/trunk/CHANGES.txt
U PluginRegistry/trunk/PluginRegistry.py
U PluginRegistry/trunk/exportimport.py
A PluginRegistry/trunk/www/export_import.zpt
-=-
Modified: PluginRegistry/trunk/CHANGES.txt
===================================================================
--- PluginRegistry/trunk/CHANGES.txt 2005-11-04 21:38:03 UTC (rev 39897)
+++ PluginRegistry/trunk/CHANGES.txt 2005-11-04 22:53:48 UTC (rev 39898)
@@ -3,6 +3,9 @@
After PluginRegistry-1.0.2
+ - Wired in DAV / FTP / ExternalEditor support for the registry,
+ along with a ZMI form for updating it as XML.
+
- Added support for exporting / importing registry via GenericSetup.
- Saner version name
Modified: PluginRegistry/trunk/PluginRegistry.py
===================================================================
--- PluginRegistry/trunk/PluginRegistry.py 2005-11-04 21:38:03 UTC (rev 39897)
+++ PluginRegistry/trunk/PluginRegistry.py 2005-11-04 22:53:48 UTC (rev 39898)
@@ -25,11 +25,19 @@
from Persistence import PersistentMapping
from OFS.SimpleItem import SimpleItem
from App.class_init import default__class_init__ as InitializeClass
+from webdav.WriteLockInterface import WriteLockInterface
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
from interfaces.plugins import IPluginRegistry
+try:
+ from exportimport import _updatePluginRegistry
+except ImportError:
+ _HAS_GENERIC_SETUP = False
+else:
+ _HAS_GENERIC_SETUP = True
+
from utils import _wwwdir
class PluginRegistry( SimpleItem ):
@@ -38,7 +46,7 @@
o Each plugin type holds an ordered list of ( id, wrapper ) tuples.
"""
- __implements__ = ( IPluginRegistry, )
+ __implements__ = ( IPluginRegistry, WriteLockInterface )
security = ClassSecurityInfo()
@@ -315,6 +323,48 @@
+ SimpleItem.manage_options
)
+ if _HAS_GENERIC_SETUP:
+ security.declareProtected( ManageUsers, 'manage_exportImportForm' )
+ manage_exportImportForm = PageTemplateFile( 'export_import', _wwwdir )
+
+ security.declareProtected( ManageUsers, 'getConfigAsXML' )
+ def getConfigAsXML(self):
+ """ Return XML representing the registry's configuration.
+ """
+ from exportimport import PluginRegistryExporter
+ pre = PluginRegistryExporter(self).__of__(self)
+ return pre.generateXML()
+
+ security.declareProtected( ManageUsers, 'manage_exportImport' )
+ def manage_exportImport(self, updated_xml, should_purge, RESPONSE):
+ """ Parse XML and update the registry.
+ """
+ #XXX encoding?
+ _updatePluginRegistry(self, updated_xml, should_purge)
+ RESPONSE.redirect('%s/manage_exportImportForm'
+ '?manage_tabs_message=Registry+updated.'
+ % self.absolute_url())
+
+ security.declareProtected( ManageUsers, 'manage_FTPget' )
+ def manage_FTPget(self, REQUEST, RESPONSE):
+ """
+ """
+ return self.getConfigAsXML()
+
+ security.declareProtected( ManageUsers, 'PUT' )
+ def PUT(self, REQUEST, RESPONSE):
+ """
+ """
+ xml = REQUEST['BODYFILE'].read()
+ _updatePluginRegistry(self, xml, True)
+
+ manage_options = ( manage_options[:2]
+ + ( { 'label' : 'Export / Import'
+ , 'action' : 'manage_exportImportForm'
+ },)
+ + manage_options[2:]
+ )
+
#
# Helper methods
#
Modified: PluginRegistry/trunk/exportimport.py
===================================================================
--- PluginRegistry/trunk/exportimport.py 2005-11-04 21:38:03 UTC (rev 39897)
+++ PluginRegistry/trunk/exportimport.py 2005-11-04 22:53:48 UTC (rev 39898)
@@ -59,18 +59,10 @@
return 'Plugin registry exported.'
-def importPluginRegistry(context):
- """ Import plugin registry from an XML file.
- """
- registry = _getRegistry(context.getSite())
- encoding = context.getEncoding()
+def _updatePluginRegistry(registry, xml, should_purge, encoding=None):
- xml = context.readDataFile(_FILENAME)
- if xml is None:
- return 'Site properties: Nothing to import.'
+ if should_purge:
- if context.shouldPurge():
-
registry._plugin_types = []
registry._plugin_type_info = PersistentMapping()
registry._plugins = PersistentMapping()
@@ -87,6 +79,18 @@
}
registry._plugins[iface] = tuple([x['id'] for x in info['plugins']])
+def importPluginRegistry(context):
+ """ Import plugin registry from an XML file.
+ """
+ registry = _getRegistry(context.getSite())
+ encoding = context.getEncoding()
+
+ xml = context.readDataFile(_FILENAME)
+ if xml is None:
+ return 'Site properties: Nothing to import.'
+
+ _updatePluginRegistry(registry, xml, context.shouldPurge(), encoding)
+
return 'Plugin registry imported.'
class PluginRegistryExporter(ExportConfiguratorBase):
Added: PluginRegistry/trunk/www/export_import.zpt
===================================================================
--- PluginRegistry/trunk/www/export_import.zpt 2005-11-04 21:38:03 UTC (rev 39897)
+++ PluginRegistry/trunk/www/export_import.zpt 2005-11-04 22:53:48 UTC (rev 39898)
@@ -0,0 +1,45 @@
+<h1 tal:replace="structure here/manage_page_header"> PAGE HEADER </h1>
+<h2 tal:replace="structure here/manage_tabs"> TABS </h2>
+
+<h3> Export / Import Registry Configuration </h3>
+
+<p class="form-help">
+ This view allows you to view and edit the registry configuration as
+ a single XML document.
+</p>
+
+<form action="." method="POST" enctype="multipart/form-data"
+ tal:attributes="action
+ string:${context/absolute_url}/manage_exportImportForm;
+ ">
+<table>
+
+ <tr>
+ <th> Purge old config? </th>
+ <td>
+ <input type="hidden" name="should_purge:default:int" value="0" />
+ <input type="checkbox" name="should_purge:int" value="1" checked="checked" />
+ </td>
+ </tr>
+
+ <tr>
+ <th> Configuration </th>
+ <td>
+ <textarea name="xml:text" rows="30" cols="80"
+ tal:content="context/getConfigAsXML"
+ ></textarea>
+ </td>
+ </tr>
+
+ <tr>
+ <td />
+ <td>
+ <input type="submit" value=" Save " />
+ </td>
+ </tr>
+
+</table>
+</form>
+
+<h1 tal:replace="structure here/manage_page_footer"> PAGE FOOTER </h1>
+
Property changes on: PluginRegistry/trunk/www/export_import.zpt
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Zope-CVS
mailing list