############################################################################## # # Copyright (c) 2003 Epoz Contributors. See CREDITS.txt # # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Zope2 integration module This is a solution for plain Zope2 integration using the FileSystemSite product. FileSystemSite can be found at http://www.zope.org/Members/k_vertigo/Products/FileSystemSite Note that FileSystemSite 1.3 is required. $Id: __init__.py,v 1.3 2003/10/24 14:46:00 philikon Exp $ """ import Globals from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.FileSystemSite.DirectoryView import DirectoryRegistry, \ DirectoryView, DirectoryViewSurrogate, manage_listAvailableDirectories def initialize(context): context.registerClass( EpozEditorSurrogate, constructors=(('manage_addEpozEditorForm', manage_addEpozEditorForm), manage_addEpozEditor ), icon='zope2/epozeditor.png' ) #_dirreg = DirectoryRegistry() from Products.FileSystemSite.DirectoryView import _dirreg _dirreg.registerDirectory('../common', globals()) class EpozEditor(DirectoryView): meta_type = 'epoz editor' def __of__(self, parent): info = _dirreg.getDirectoryInfo(self._dirpath) if info is not None: info = info.getContents(_dirreg) if info is None: data = {} objects = () else: data, objects = info s = EpozEditorSurrogate(self, data, objects) res = s.__of__(parent) return res Globals.InitializeClass(EpozEditor) class EpozEditorSurrogate(DirectoryViewSurrogate): meta_type = "epoz editor" Globals.InitializeClass(EpozEditorSurrogate) manage_addEpozEditorForm = PageTemplateFile('addEpozEditor.pt', globals()) def createEpozEditor(parent, filepath, id=None): """Adds either a DirectoryView or a derivative object. """ info = _dirreg.getDirectoryInfo(filepath) if info is None: raise ValueError('Not a registered directory: %s' % filepath) if not id: id = path.split(filepath)[-1] else: id = str(id) ob = EpozEditor(id, filepath) parent._setObject(id, ob) def manage_addEpozEditor(self, filepath="Products/epoz/common", id=None, REQUEST=None): """Adds either an epoz editor object """ createEpozEditor(self, filepath, id) if REQUEST is not None: return self.manage_main(self, REQUEST)