[Erp5-dev] own getTitle
bartek
bartek at erp5.pl
Fri Mar 28 13:21:06 CET 2008
Jérome Perrin wrote:
> 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.
Ha - I didn't know it. Why it is not in HowToUsePropertySheets? ;)
Actually, it adds a big question mark to XMLObject_type_based_title -
since this way one can achieve the same result, with probably much less
overhead (no redundant script lookups etc).
B
>
> 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
> _______________________________________________
> Erp5-dev mailing list
> Erp5-dev at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-dev
>
--
"feelings affect productivity. (...) unhappy people write worse
software, and less of it."
Karl Fogel, "Producing Open Source Software"
More information about the Erp5-dev
mailing list