[Erp5-dev] own getTitle

Jérome Perrin jerome at nexedi.com
Fri Mar 28 13:04:13 CET 2008


bartek a écrit :
> Tomasz Brzezina wrote:
>> I need to mask getTitle for my own portal_type - in the same way like 
>> getTitle in Person - How to?
> 
> There is in the experimental repository a patch called 
> XMLObject_type_based_title - see here:
> 
> http://svn.erp5.org/experimental/Experimental/patches/XMLObject_type_based_title.py?view=markup
> 
> It does exactly what you need - allows you to customize title generation 
> per portal type by creating appropriately named scripts. However, AFAIK 
> Nexedi saw some serious flaws in it, so it is not certain if it will 
> ever make its way to the core, or maybe it'll be reimplemented.
> 

Hello,

It's also possible to do this in a property sheet using a trick similar 
to the Object_getSizeColourReference example in 
http://www.erp5.org/HowToUsePropertySheets

Use a property sheet like this one:

class FunkyTitle:

     _properties = (
         {   'id'          : 'title',
             'type'        : 'string',
             'default'     : '',
             'acquisition_base_category'     : (),
             'acquisition_portal_type'       : (),
             'acquisition_copy_value'        : 0,
             'acquisition_mask_value'        : 1,
             'acquisition_depends'           : None,
             'acquisition_accessor_id'       : 'getTitle',
             'acquisition_depends'           : None,
             'alt_accessor_id'               : ('Base_getFunkyTitle', ),
             'override'    : 1,
             'mode'        : 'w' },

     )

What's important is the "override : 1", this will override the default 
getTitle accessor.

I think this approach won't work if XMLObject_type_based_title patch is 
applied, because the patch sets a getTitle method on the class, and only 
dynamic accessors can be replaced.

Jérome



More information about the Erp5-dev mailing list