Commit 630d55c7 authored by Jean-Paul Smets's avatar Jean-Paul Smets

license change to ZPL due to code reuse + mock up implementation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1333 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 914bda0a
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002-2004 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
...@@ -10,19 +11,12 @@ ...@@ -10,19 +11,12 @@
# garantees and support are strongly adviced to contract a Free Software # garantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This software is subject to the provisions of the Zope Public License,
# modify it under the terms of the GNU General Public License # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# as published by the Free Software Foundation; either version 2 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# of the License, or (at your option) any later version. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# This program is distributed in the hope that it will be useful, # FOR A PARTICULAR PURPOSE
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
...@@ -36,13 +30,7 @@ from Products.CMFCore.interfaces.portal_types import ContentTypeInformation as I ...@@ -36,13 +30,7 @@ from Products.CMFCore.interfaces.portal_types import ContentTypeInformation as I
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
from Products.ERP5Type import Permissions as ERP5Permissions from Products.ERP5Type import Permissions as ERP5Permissions
class ERP5AcquisitionType: class ERP5TypeInformation( FactoryTypeInformation, ScriptableTypeInformation ):
"""
Mix in class
"""
pass
class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ):
""" """
ERP5 Types are based on Scriptable Type (this will eventually require some rewriting ERP5 Types are based on Scriptable Type (this will eventually require some rewriting
of Utils... and addXXX methods) of Utils... and addXXX methods)
...@@ -52,7 +40,8 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ): ...@@ -52,7 +40,8 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ):
Another feature is to define the way attributes are stored (localy, Another feature is to define the way attributes are stored (localy,
database, etc.). This allows to combine multiple attribute sources database, etc.). This allows to combine multiple attribute sources
in a single object.. in a single object. This feature will be in reality implemented
through PropertySheet classes (TALES expressions)
""" """
__implements__ = ITypeInformation __implements__ = ITypeInformation
...@@ -60,12 +49,34 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ): ...@@ -60,12 +49,34 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ):
meta_type = 'ERP5 Type Information' meta_type = 'ERP5 Type Information'
security = ClassSecurityInfo() security = ClassSecurityInfo()
_properties = ScriptableTypeInformation._properties _properties = (ScriptableTypeInformation._basic_properties + (
{'id':'factory', 'type': 'string', 'mode':'w',
manage_options = (ScriptableTypeInformation.manage_options[:2] + 'label':'Product factory method'},
({'label':'Acquisition', {'id':'init_script', 'type': 'string', 'mode':'w',
'action':'manage_editAcquisitionForm'},) + 'label':'Init Script'},
ScriptableTypeInformation.manage_options[2:]) {'id':'permission', 'type': 'string', 'mode':'w',
'label':'Constructor permission'},
) + ScriptableTypeInformation._advanced_properties + (
{ 'id':'property_sheet_list'
, 'type': 'multiple selection'
, 'mode':'w'
, 'label':'Property Sheets'
, 'select_variable':'getPropertySheetList'
},
{ 'id':'base_category_list'
, 'type': 'multiple selection'
, 'mode':'w'
, 'label':'Bae Categories'
, 'select_variable':'getBaseCategoryList'
},
)) # Remove initial view name ? what is the use of meta_type ? Implicitly addable ? Allow Discusion ?
manage_options = ScriptableTypeInformation.manage_options
property_sheet_list = ()
base_category_list = ()
init_script = ''
product = 'ERP5Type'
# #
...@@ -74,33 +85,74 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ): ...@@ -74,33 +85,74 @@ class ERP5TypeInformation( ScriptableTypeInformation, ERP5AcquisitionType ):
_actions_form = DTMLFile( 'editActions', _dtmldir ) _actions_form = DTMLFile( 'editActions', _dtmldir )
security.declareProtected(ERP5Permissions.ManagePortal, 'manage_editAcquisitionForm')
def manage_editAcquisitionForm(self, REQUEST, manage_tabs_message=None): #
# Agent methods
#
security.declarePublic('constructInstance')
def constructInstance( self, container, id, *args, **kw ):
""" """
Shows the 'Actions' management tab. Build a "bare" instance of the appropriate type in
'container', using 'id' as its id. Return the object.
""" """
actions = [] # Check extra permissions
for a in self.getActions(): if self.permission:
a = a.copy() if not ScriptableTypeInformation.isConstructionAllowed(self, container):
p = a['permissions'] raise Unauthorized
if p:
a['permission'] = p[0] # Get the factory method, performing a security check
# in the process.
try:
if self.constructor_path != self.factory: self.factory = self.constructor_path
m = self._getFactoryMethod(container)
except ValueError:
m = None
if m is not None:
# Standard FTI constructor
id = str(id)
if getattr( m, 'isDocTemp', 0 ):
args = ( m.aq_parent, self.REQUEST ) + args
kw[ 'id' ] = id
else:
args = ( id, ) + args
id = apply( m, args, kw ) or id # allow factory to munge ID
ob = container._getOb( id )
else: else:
a['permission'] = '' # Scriptable type
if not a.has_key('category'): constructor = self.restrictedTraverse( self.constructor_path )
a['category'] = 'object' # make sure ownership is explicit before switching the context
if not a.has_key('id'): if not hasattr( aq_base(constructor), '_owner' ):
a['id'] = cookString(a['name']) constructor._owner = aq_get(constructor, '_owner')
if not a.has_key( 'visible' ):
a['visible'] = 1 # Rewrap to get into container's context.
actions.append(a) constructor = aq_base(constructor).__of__( container )
# possible_permissions is in AccessControl.Role.RoleManager.
pp = self.possible_permissions() id = str(id)
return self._actions_form(self, REQUEST, ob = apply(constructor, (container, id) + args, kw)
actions=actions,
possible_permissions=pp, return self._finishConstruction(ob)
management_view='Actions',
manage_tabs_message=manage_tabs_message) security.declareProtected(ERP5Permissions.AccessContentsInformation, 'getPropertySheetList')
def getPropertySheetList( self ):
"""
Return list of content types.
"""
from Products.ERP5Type import PropertySheet
result = PropertySheet.__dict__.keys()
result = filter(lambda k: not k.startswith('__'), result)
result.sort()
return result
security.declareProtected(ERP5Permissions.AccessContentsInformation, 'getBaseCategoryList')
def getBaseCategoryList( self ):
result = self.portal_categories.getBaseCategoryList()
result.sort()
return result
InitializeClass( ERP5TypeInformation ) InitializeClass( ERP5TypeInformation )
...@@ -135,6 +187,8 @@ class ERP5TypesTool(TypesTool): ...@@ -135,6 +187,8 @@ class ERP5TypesTool(TypesTool):
add_meta_type=ERP5TypeInformation.meta_type, add_meta_type=ERP5TypeInformation.meta_type,
types=self.listDefaultTypeInformation()) types=self.listDefaultTypeInformation())
# Dynamic patch # Dynamic patch
Products.CMFCore.TypesTool.typeClasses = typeClasses Products.CMFCore.TypesTool.typeClasses = typeClasses
Products.CMFCore.TypesTool.TypesTool.manage_addERP5TIForm = ERP5TypesTool.manage_addERP5TIForm Products.CMFCore.TypesTool.TypesTool.manage_addERP5TIForm = ERP5TypesTool.manage_addERP5TIForm
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment