Annotation of kupuMPIWG/zope2/__init__.py, revision 1.1

1.1     ! dwinter     1: ##############################################################################
        !             2: #
        !             3: # Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
        !             4: #
        !             5: # This software is distributed under the terms of the Kupu
        !             6: # License. See LICENSE.txt for license text. For a list of Kupu
        !             7: # Contributors see CREDITS.txt.
        !             8: #
        !             9: ##############################################################################
        !            10: """Zope2 integration module
        !            11: 
        !            12: This is a solution for plain Zope2 integration using the
        !            13: FileSystemSite product. FileSystemSite can be found at
        !            14: http://www.zope.org/Members/k_vertigo/Products/FileSystemSite
        !            15: Note that FileSystemSite 1.3 is required.
        !            16: 
        !            17: $Id: __init__.py 9879 2005-03-18 12:04:00Z yuppie $
        !            18: """
        !            19: 
        !            20: import Globals
        !            21: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
        !            22: 
        !            23: from Products.FileSystemSite.DirectoryView import DirectoryView
        !            24: from Products.FileSystemSite.DirectoryView import DirectoryViewSurrogate
        !            25: from Products.FileSystemSite.DirectoryView import DirectoryRegistry
        !            26: from Products.FileSystemSite.DirectoryView import registerFileExtension
        !            27: from Products.FileSystemSite.DirectoryView import manage_listAvailableDirectories
        !            28: from Products.FileSystemSite.FSFile import FSFile
        !            29: 
        !            30: def initialize(context):
        !            31:     context.registerClass(
        !            32:         KupuEditorSurrogate,
        !            33:         constructors=(('manage_addKupuEditorForm', manage_addKupuEditorForm),
        !            34:                       manage_addKupuEditor
        !            35:                       ),
        !            36:         icon='kupu_icon.gif'
        !            37:     )
        !            38: 
        !            39: #_dirreg = DirectoryRegistry()
        !            40: from Products.FileSystemSite.DirectoryView import _dirreg
        !            41: _dirreg.registerDirectory('../common', globals())
        !            42: 
        !            43: # for library drawers
        !            44: registerFileExtension('xsl', FSFile)
        !            45: registerFileExtension('xml', FSFile)
        !            46: 
        !            47: class KupuEditor(DirectoryView):
        !            48:     meta_type = 'kupu editor'
        !            49: 
        !            50:     def __of__(self, parent):
        !            51:         info = _dirreg.getDirectoryInfo(self._dirpath)
        !            52:         if info is not None:
        !            53:             info = info.getContents(_dirreg)
        !            54:         if info is None:
        !            55:             data = {}
        !            56:             objects = ()
        !            57:         else:
        !            58:             data, objects = info
        !            59:         s = KupuEditorSurrogate(self, data, objects)
        !            60:         res = s.__of__(parent)
        !            61:         return res
        !            62: 
        !            63: Globals.InitializeClass(KupuEditor)
        !            64: 
        !            65: class KupuEditorSurrogate(DirectoryViewSurrogate):
        !            66:     meta_type = "kupu editor"
        !            67: 
        !            68: Globals.InitializeClass(KupuEditorSurrogate)
        !            69: 
        !            70: manage_addKupuEditorForm = PageTemplateFile('addKupuEditor.pt', globals())
        !            71: 
        !            72: def createKupuEditor(parent, filepath, id=None):
        !            73:     """Adds either a DirectoryView or a derivative object.
        !            74:     """
        !            75:     info = _dirreg.getDirectoryInfo(filepath)
        !            76:     if info is None:
        !            77:         raise ValueError('Not a registered directory: %s' % filepath)
        !            78:     if not id:
        !            79:         id = path.split(filepath)[-1]
        !            80:     else:
        !            81:         id = str(id)
        !            82:     ob = KupuEditor(id, filepath)
        !            83:     parent._setObject(id, ob)
        !            84: 
        !            85: def manage_addKupuEditor(self, filepath="Products/kupu/common",
        !            86:                          id=None, REQUEST=None):
        !            87:     """Adds either an kupu editor object
        !            88:     """
        !            89:     createKupuEditor(self, filepath, id)
        !            90:     if REQUEST is not None:
        !            91:         return self.manage_main(self, REQUEST)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>