[Erp5-dev] Username lost when installing a Person object from bt5 file
Ivan Tyagov
ivan at nexedi.com
Thu Jan 11 14:02:42 CET 2007
> We need a generic solution. It is unmaintainable to work around for every
> specific case.
> The first question is whether it is required to call manager_afterClone for an
It's required.
>
> If you cannot remove it, we need a way to bypass reseting properties (i.e. not
> to call a script specified by a portal type), by passing a parameter to the
> method, for example.
I would like to propose that we extend the arguments passed to scripts
like '<PortalType>_afteClone'. Currently this scripts doesn't accept any
arguments at all and thus we can not implement any logic for reseting or
not properties inside them.
Implementing this logic inside 'manage_afterClone' based on portal type
is not very flexible.
My suggestion is that we pass to these scripts an argument called
'pseudo_context'.
When creating an object from a business template this pseudo_context
will be the portal_templates tool itself. In any other cases
pseudo_context will be the copied object itself (which is the default
behavior).
Having this argument we can implement property reseting logic for every
type in '<PortalType>_afteClone' script.
Currently the following scripts shall be modified (just add
'pseudo_context' to parameter list):
- Person_afteClone
- AccountingTransaction_afterClone
- Invoice_afterClone
This would require following file system patches:
Index: BusinessTemplate.py
===================================================================
--- BusinessTemplate.py (revision 11986)
+++ BusinessTemplate.py (working copy)
@@ -646,7 +646,7 @@
obj = obj._getCopy(container)
container._setObject(object_id, obj)
obj = container._getOb(object_id)
- obj.manage_afterClone(obj)
+ obj.manage_afterClone(portal.portal_templates)
obj.wl_clearLocks()
# if portal types upgrade, set backup properties
Index: CopySupport.py
===================================================================
--- CopySupport.py (revision 11986)
+++ CopySupport.py (working copy)
@@ -247,7 +247,7 @@
# Call a type based method to reset so properties if necessary
script = self._getTypeBasedMethod('afterClone')
if script is not None and callable(script):
- script()
+ script(item)
# Clear the workflow history
# XXX This need to be tested again
This problem is referenced "here": http://10.8.0.78/nexedi/bug_module/561
Ivan
More information about the Erp5-dev
mailing list