Commit b172c130 authored by Julien Muchembled's avatar Julien Muchembled

Add some comments

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29282 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6dbeb193
......@@ -55,7 +55,6 @@ from Products.ERP5Type.Utils import readLocalTest, \
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Core.RoleInformation import RoleInformation
from OFS.Traversable import NotFound
from OFS import SimpleItem, XMLExportImport
from cStringIO import StringIO
......@@ -2378,6 +2377,7 @@ class ActionTemplateItem(ObjectTemplateItem):
url, value = id.split(' | ')
url = posixpath.split(url)
obj = p.unrestrictedTraverse(url)
# Several tools still use CMF actions
is_new_action = obj.getParentId() == 'portal_types'
id_id = is_new_action and 'reference' or 'id'
for action in (is_new_action and obj.getActionInformationList
......@@ -2418,6 +2418,8 @@ class ActionTemplateItem(ObjectTemplateItem):
portal_type_dict.setdefault(path, {})[reference] = obj
continue
# Following code is for actions outside Types Tool.
# It will be removed when they are also converted to ERP5 actions.
obj, action = container, obj
action_list = obj.listActions()
for index in range(len(action_list)):
......
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002-2009 Nexedi SARL and Contributors. All Rights Reserved.
# Julien Muchembled <jm@nexedi.com>
#
# 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
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# 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.
#
##############################################################################
""" Information about customizable roles.
......
......@@ -57,6 +57,8 @@ from Products.CMFCore.exceptions import zExceptions_Unauthorized
class LocalRoleAssignorMixIn(object):
"""Mixin class used by type informations to compute and update local roles
"""
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -188,6 +190,29 @@ class LocalRoleAssignorMixIn(object):
return REQUEST.RESPONSE.redirect('%s/%s?portal_status_message=%s'
% (self.absolute_url_path(), form_id, message))
def _importRole(self, role_property_dict):
"""Import a role from a BT or from an old portal type"""
from Products.ERP5Type.Document.RoleInformation import RoleInformation
role = RoleInformation(self.generateNewId())
for k, v in role_property_dict.iteritems():
if k == 'condition':
if isinstance(v, Expression):
v = v.text
if not v:
continue
v = Expression(v)
elif k == 'priority':
continue
elif k == 'id':
k, v = 'role_name', tuple(x.strip() for x in v.split(';'))
elif k in ('base_category', 'category'):
k, v = 'role_' + k, tuple(x.strip() for x in v)
elif k == 'base_category_script':
k = 'role_base_category_script_id'
setattr(role, k, v)
role.uid = None
return self[self._setObject(role.id, role, set_owner=0)]
class ERP5TypeInformation(XMLObject,
FactoryTypeInformation,
......@@ -553,6 +578,10 @@ class ERP5TypeInformation(XMLObject,
key=lambda x: (x.getFloatIndex(), x.getId()))
def _importOldAction(self, old_action):
"""Convert a CMF action to an ERP5 action
This is used to update an existing site or to import a BT.
"""
from Products.ERP5Type.Document.ActionInformation import ActionInformation
old_action = old_action.__getstate__()
action_type = old_action.pop('category', None)
......@@ -573,6 +602,10 @@ class ERP5TypeInformation(XMLObject,
return action
def _exportOldAction(self, action):
"""Convert an ERP5 action to a CMF action
This is used to export a BT.
"""
from Products.CMFCore.ActionInformation import ActionInformation
old_action = ActionInformation(action.reference,
category=action.getActionType(),
......@@ -588,27 +621,5 @@ class ERP5TypeInformation(XMLObject,
setattr(old_action, k, v)
return old_action
def _importRole(self, role_property_dict):
from Products.ERP5Type.Document.RoleInformation import RoleInformation
role = RoleInformation(self.generateNewId())
for k, v in role_property_dict.iteritems():
if k == 'condition':
if isinstance(v, Expression):
v = v.text
if not v:
continue
v = Expression(v)
elif k == 'priority':
continue
elif k == 'id':
k, v = 'role_name', tuple(x.strip() for x in v.split(';'))
elif k in ('base_category', 'category'):
k, v = 'role_' + k, tuple(x.strip() for x in v)
elif k == 'base_category_script':
k = 'role_base_category_script_id'
setattr(role, k, v)
role.uid = None
return self[self._setObject(role.id, role, set_owner=0)]
InitializeClass( ERP5TypeInformation )
......@@ -33,7 +33,8 @@ class PropertyDomainDict(Implicit):
Combined with TranslationProviderBase.property_domain_dict,
this class makes TranslationInformation objects inside
TranslationProviderBase._property_domain_dict accessible with
(un)restrictedTraverse. This hack allows forms to use Base_edit such objects.
(un)restrictedTraverse. This hack allows forms to use Base_edit
for such objects.
"""
def _aq_dynamic(self, attr):
type_info = self.aq_parent
......
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