|
|
Choosing A Webhost: |
CVS: Products/CMFCore - TypesTool.py:1.83 __init__.py:1.30: msg#00123web.zope.cmf.cvs
Update of /cvs-repository/Products/CMFCore In directory cvs.zope.org:/tmp/cvs-serv4222/CMFCore Modified Files: TypesTool.py __init__.py Log Message: - replaced hardcoded 'typeClasses' by an IFAwareObjectManager based solution === Products/CMFCore/TypesTool.py 1.82 => 1.83 === --- Products/CMFCore/TypesTool.py:1.82 Mon Nov 22 06:56:28 2004 +++ Products/CMFCore/TypesTool.py Sun Nov 28 16:40:27 2004 @@ -25,6 +25,7 @@ from Globals import DTMLFile from Globals import InitializeClass from OFS.Folder import Folder +from OFS.ObjectManager import IFAwareObjectManager from Products.PageTemplates.PageTemplateFile import PageTemplateFile from zLOG import LOG, ERROR import Products @@ -43,6 +44,7 @@ from utils import _wwwdir from utils import cookString from utils import getActionContext +from utils import getToolByName from utils import SimpleItemWithProperties from utils import UniqueObject @@ -536,6 +538,15 @@ InitializeClass( FactoryTypeInformation ) +def manage_addFactoryTIForm(self, REQUEST): + """ Get the add form for factory-based type infos. + """ + addTIForm = DTMLFile('addTypeInfo', _dtmldir).__of__(self) + ttool = getToolByName(self, 'portal_types') + return addTIForm( self, REQUEST, + add_meta_type=FactoryTypeInformation.meta_type, + types=ttool.listDefaultTypeInformation() ) + class ScriptableTypeInformation( TypeInformation ): """ @@ -592,24 +603,20 @@ InitializeClass( ScriptableTypeInformation ) +def manage_addScriptableTIForm(self, REQUEST): + """ Get the add form for scriptable type infos. + """ + addTIForm = DTMLFile('addTypeInfo', _dtmldir).__of__(self) + ttool = getToolByName(self, 'portal_types') + return addTIForm( self, REQUEST, + add_meta_type=ScriptableTypeInformation.meta_type, + types=ttool.listDefaultTypeInformation() ) + # Provide aliases for backward compatibility. ContentFactoryMetadata = FactoryTypeInformation ContentTypeInformation = ScriptableTypeInformation - -typeClasses = [ - {'class':FactoryTypeInformation, - 'name':FactoryTypeInformation.meta_type, - 'action':'manage_addFactoryTIForm', - 'permission':ManagePortal}, - {'class':ScriptableTypeInformation, - 'name':ScriptableTypeInformation.meta_type, - 'action':'manage_addScriptableTIForm', - 'permission':ManagePortal}, - ] - - allowedTypes = [ 'Script (Python)', 'Python Method', @@ -618,7 +625,8 @@ ] -class TypesTool(UniqueObject, Folder, ActionProviderBase): +class TypesTool(UniqueObject, IFAwareObjectManager, Folder, + ActionProviderBase): """ Provides a configurable registry of portal content types. """ @@ -627,6 +635,7 @@ id = 'portal_types' meta_type = 'CMF Types Tool' + _product_interfaces = (ITypeInformation,) security = ClassSecurityInfo() @@ -652,20 +661,12 @@ # ObjectManager methods # def all_meta_types(self): - """Adds TypesTool-specific meta types.""" + # this is a workaround and should be removed again if allowedTypes + # have an interface we can use in _product_interfaces all = TypesTool.inheritedAttribute('all_meta_types')(self) - return tuple(typeClasses) + tuple(all) - - def filtered_meta_types(self, user=None): - # Filters the list of available meta types. - allowed = {} - for tc in typeClasses: - allowed[tc['name']] = 1 - for name in allowedTypes: - allowed[name] = 1 - - all = TypesTool.inheritedAttribute('filtered_meta_types')(self) - return tuple( [ mt for mt in all if mt['name'] in allowed ] ) + others = [ mt for mt in Products.meta_types + if mt['name'] in allowedTypes ] + return tuple(all) + tuple(others) # # other methods @@ -700,24 +701,6 @@ return res - _addTIForm = DTMLFile( 'addTypeInfo', _dtmldir ) - - security.declareProtected(ManagePortal, 'manage_addFactoryTIForm') - def manage_addFactoryTIForm(self, REQUEST): - ' ' - return self._addTIForm( - self, REQUEST, - add_meta_type=FactoryTypeInformation.meta_type, - types=self.listDefaultTypeInformation()) - - security.declareProtected(ManagePortal, 'manage_addScriptableTIForm') - def manage_addScriptableTIForm(self, REQUEST): - ' ' - return self._addTIForm( - self, REQUEST, - add_meta_type=ScriptableTypeInformation.meta_type, - types=self.listDefaultTypeInformation()) - security.declareProtected(ManagePortal, 'manage_addTypeInformation') def manage_addTypeInformation(self, add_meta_type, id=None, typeinfo_name=None, RESPONSE=None): @@ -737,9 +720,9 @@ id = fti.get('id', None) if not id: raise BadRequest('An id is required.') - for mt in typeClasses: + for mt in Products.meta_types: if mt['name'] == add_meta_type: - klass = mt['class'] + klass = mt['instance'] break else: raise ValueError, ( === Products/CMFCore/__init__.py 1.29 => 1.30 === --- Products/CMFCore/__init__.py:1.29 Tue Sep 14 15:02:21 2004 +++ Products/CMFCore/__init__.py Sun Nov 28 16:40:27 2004 @@ -32,6 +32,7 @@ import utils from permissions import AddPortalFolders +from permissions import ManagePortal bases = ( @@ -99,6 +100,20 @@ icon = 'images/registry.gif' ) + context.registerClass( + TypesTool.FactoryTypeInformation, + permission=ManagePortal, + constructors=( TypesTool.manage_addFactoryTIForm, ), + icon='images/typeinfo.gif', + visibility=None) + + context.registerClass( + TypesTool.ScriptableTypeInformation, + permission=ManagePortal, + constructors=( TypesTool.manage_addScriptableTIForm, ), + icon='images/typeinfo.gif', + visibility=None) + utils.registerIcon(FSDTMLMethod.FSDTMLMethod, 'images/fsdtml.gif', globals()) utils.registerIcon(FSPythonScript.FSPythonScript, @@ -113,10 +128,6 @@ 'images/fsprops.gif', globals()) utils.registerIcon(FSZSQLMethod.FSZSQLMethod, 'images/fssqlmethod.gif', globals()) - utils.registerIcon(TypesTool.FactoryTypeInformation, - 'images/typeinfo.gif', globals()) - utils.registerIcon(TypesTool.ScriptableTypeInformation, - 'images/typeinfo.gif', globals()) context.registerHelpTitle('CMF Core Help') context.registerHelp(directory='interfaces')
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS: CMF - CHANGES.txt:1.278, Yvo Schubbe |
|---|---|
| Next by Date: | CVS: Products/CMFDefault/tests - test_RestrictedAcquisition.py:1.1.2.2, Stefan H. Holek |
| Previous by Thread: | CVS: CMF - CHANGES.txt:1.278, Yvo Schubbe |
| Next by Thread: | CVS: Products/CMFDefault/tests - test_RestrictedAcquisition.py:1.1.2.2, Stefan H. Holek |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |