| 1 | ################################################################################
|
|---|
| 2 | # ZMSMetamodelProvider.py
|
|---|
| 3 | #
|
|---|
| 4 | # This program is free software; you can redistribute it and/or
|
|---|
| 5 | # modify it under the terms of the GNU General Public License
|
|---|
| 6 | # as published by the Free Software Foundation; either version 2
|
|---|
| 7 | # of the License, or (at your option) any later version.
|
|---|
| 8 | #
|
|---|
| 9 | # This program is distributed in the hope that it will be useful,
|
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | # GNU General Public License for more details.
|
|---|
| 13 | #
|
|---|
| 14 | # You should have received a copy of the GNU General Public License
|
|---|
| 15 | # along with this program; if not, write to the Free Software
|
|---|
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 17 | ################################################################################
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | # Imports.
|
|---|
| 21 | from App.special_dtml import HTMLFile
|
|---|
| 22 | import copy
|
|---|
| 23 | import zope.interface
|
|---|
| 24 | # Product Imports.
|
|---|
| 25 | import IZMSConfigurationProvider
|
|---|
| 26 | import IZMSMetamodelProvider, ZMSMetaobjManager, ZMSMetadictManager
|
|---|
| 27 | import ZMSItem
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | ################################################################################
|
|---|
| 31 | ################################################################################
|
|---|
| 32 | ###
|
|---|
| 33 | ### Class
|
|---|
| 34 | ###
|
|---|
| 35 | ################################################################################
|
|---|
| 36 | ################################################################################
|
|---|
| 37 | class ZMSMetamodelProvider(
|
|---|
| 38 | ZMSItem.ZMSItem,
|
|---|
| 39 | ZMSMetaobjManager.ZMSMetaobjManager,
|
|---|
| 40 | ZMSMetadictManager.ZMSMetadictManager):
|
|---|
| 41 | zope.interface.implements(
|
|---|
| 42 | IZMSConfigurationProvider.IZMSConfigurationProvider,
|
|---|
| 43 | IZMSMetamodelProvider.IZMSMetamodelProvider)
|
|---|
| 44 |
|
|---|
| 45 | # Properties.
|
|---|
| 46 | # -----------
|
|---|
| 47 | meta_type = 'ZMSMetamodelProvider'
|
|---|
| 48 | icon = "misc_/zms/ZMSMetamodelProvider.gif"
|
|---|
| 49 |
|
|---|
| 50 | # Management Options.
|
|---|
| 51 | # -------------------
|
|---|
| 52 | manage_options_default_action = '../manage_customize'
|
|---|
| 53 | def manage_options(self):
|
|---|
| 54 | return map( lambda x: self.operator_setitem( x, 'action', '../'+x['action']), copy.deepcopy(self.aq_parent.manage_options()))
|
|---|
| 55 |
|
|---|
| 56 | def manage_sub_options(self):
|
|---|
| 57 | return (
|
|---|
| 58 | {'label': 'TAB_METADATA','action': 'manage_metas'},
|
|---|
| 59 | {'label': 'TAB_METAOBJ','action': 'manage_main'},
|
|---|
| 60 | )
|
|---|
| 61 |
|
|---|
| 62 | # Management Interface.
|
|---|
| 63 | # ---------------------
|
|---|
| 64 | manage = HTMLFile('dtml/ZMSMetamodelProvider/manage_main', globals())
|
|---|
| 65 | manage_main = HTMLFile('dtml/ZMSMetamodelProvider/manage_main', globals()) # -"-
|
|---|
| 66 | manage_bigpicture = HTMLFile('dtml/ZMSMetamodelProvider/manage_bigpicture', globals())
|
|---|
| 67 | manage_analyze = HTMLFile('dtml/ZMSMetamodelProvider/manage_analyze', globals())
|
|---|
| 68 | manage_metas = HTMLFile('dtml/ZMSMetamodelProvider/manage_metas', globals())
|
|---|
| 69 |
|
|---|
| 70 | # Management Permissions.
|
|---|
| 71 | # -----------------------
|
|---|
| 72 | __administratorPermissions__ = (
|
|---|
| 73 | 'manage_changeProperties', 'manage_ajaxChangeProperties', 'manage_main', 'manage_bigpicture',
|
|---|
| 74 | 'manage_changeMetaProperties', 'manage_metas',
|
|---|
| 75 | )
|
|---|
| 76 | __ac_permissions__=(
|
|---|
| 77 | ('ZMS Administrator', __administratorPermissions__),
|
|---|
| 78 | )
|
|---|
| 79 |
|
|---|
| 80 | ############################################################################
|
|---|
| 81 | # ZMSMetamodelProvider.__init__:
|
|---|
| 82 | #
|
|---|
| 83 | # Constructor.
|
|---|
| 84 | ############################################################################
|
|---|
| 85 | def __init__(self, model={}, metas=[]):
|
|---|
| 86 | self.id = 'metaobj_manager'
|
|---|
| 87 | self.model = model.copy()
|
|---|
| 88 | self.metas = copy.deepcopy(metas)
|
|---|
| 89 |
|
|---|
| 90 | # --------------------------------------------------------------------------
|
|---|
| 91 | # ZMSMetamodelProvider.__bobo_traverse__
|
|---|
| 92 | # --------------------------------------------------------------------------
|
|---|
| 93 | def __bobo_traverse__(self, TraversalRequest, name):
|
|---|
| 94 |
|
|---|
| 95 | # If the name is in the list of attributes, call it.
|
|---|
| 96 | attr = getattr( self, name, None)
|
|---|
| 97 | if attr is not None:
|
|---|
| 98 | return attr
|
|---|
| 99 |
|
|---|
| 100 | # otherwise do some 'magic'
|
|---|
| 101 | else:
|
|---|
| 102 | print "ZMSMetamodelProvider.__bobo_traverse__: otherwise do some 'magic'"
|
|---|
| 103 | ob = self.getHome().aq_parent
|
|---|
| 104 | while ob is not None:
|
|---|
| 105 | content = getattr( ob, 'content', None)
|
|---|
| 106 | if content is not None:
|
|---|
| 107 | metaobj_manager = getattr( content, self.id, None)
|
|---|
| 108 | if metaobj_manager is not None:
|
|---|
| 109 | # If the name is in the list of attributes, call it.
|
|---|
| 110 | attr = getattr( metaobj_manager, name, None)
|
|---|
| 111 | if attr is not None:
|
|---|
| 112 | return attr
|
|---|
| 113 | ob = getattr( ob, 'aq_parent', None)
|
|---|
| 114 | return None
|
|---|
| 115 |
|
|---|
| 116 | ################################################################################
|
|---|