Discussion:
[Erp5-dev] own getTitle
Tomasz Brzezina
2008-03-25 14:50:06 UTC
Permalink
I need to mask getTitle for my own portal_type - in the same way like
getTitle in Person - How to?
--
Tomasz Brzezina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080325/81881ea2/attachment.bin>
bartek
2008-03-25 14:58:56 UTC
Permalink
Post by Tomasz Brzezina
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.

Bartek
Post by Tomasz Brzezina
------------------------------------------------------------------------
_______________________________________________
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"
Jérome Perrin
2008-03-28 12:04:13 UTC
Permalink
Post by bartek
Post by Tomasz Brzezina
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
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
bartek
2008-03-28 12:21:06 UTC
Permalink
Post by Jérome Perrin
Post by bartek
Post by Tomasz Brzezina
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
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
_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
Post by Jérome Perrin
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"
Jérome Perrin
2008-03-28 12:51:42 UTC
Permalink
Post by bartek
Post by Jérome Perrin
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? ;)
I'll add it to this page.
Post by bartek
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).
getTypeBasedMethod has been optimized a bit, but it's still slower than
just calling an accessor, I guess XMLObject_type_based_title patch makes
indexing slower.

The general problem with override is that it can only be used once per
property, if two propertysheets wants to override the same accessor, the
behaviour will be undefined (because it depends on accessors generation
order). It's better to avoid using override on stock propertysheets, so
that properties can still be overriden by customisation propertysheets
if needed.

J?rome
Tomasz Brzezina
2008-03-28 13:22:08 UTC
Permalink
Post by Jérome Perrin
_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.
It not works.... Maybe there should be ?
'acquisition_base_category' : ('object',),
'acquisition_portal_type' : Expression('python: []'),
--
Tomasz Brzezina

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080328/f3469b81/attachment.bin>
Tomasz Brzezina
2008-03-28 14:31:17 UTC
Permalink
Post by Jérome Perrin
Post by bartek
Post by Tomasz Brzezina
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
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
_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.
Well - the only way to push it to work is change acquisition_mask_value to 0
Post by Jérome Perrin
_properties = (
{ 'id' : 'title',
'type' : 'string',
'default' : '',
'acquisition_base_category' : (),
'acquisition_portal_type' : (),
'acquisition_mask_value' : 0,
'acquisition_accessor_id' : 'getTitle',
'alt_accessor_id' : ('Base_getFunkyTitle', ),
'mode' : 'w' },
)
also works correctly - so is override really necessary?
And I saw somewhere that if 'acquisition_mask_value' is equal 0, the
getTitle everytime executes Base_getFunkyTitle. I need to create Title
once, and change it only when some fields are changed. How to?
--
Tomasz Brzezina

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080328/ca0a4704/attachment.bin>
Tomasz Brzezina
2008-03-28 15:45:45 UTC
Permalink
Post by Tomasz Brzezina
I need to mask getTitle for my own portal_type - in the same way like
getTitle in Person - How to?
I wonder if there's other solution

how to attach script to save button -

In my case Title can be changed only if some fields are changed AND
SAVED. So maybe instead of changing getter the better option is to set
value of title everytime when user saves changes
--
Tomasz Brzezina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080328/40d580db/attachment.bin>
Łukasz Nowak
2008-03-28 15:53:27 UTC
Permalink
Hello,

On 2008-03-28, 16:45:45
Post by Tomasz Brzezina
Post by Tomasz Brzezina
I need to mask getTitle for my own portal_type - in the same way
like getTitle in Person - How to?
I wonder if there's other solution
how to attach script to save button -
In my case Title can be changed only if some fields are changed AND
SAVED. So maybe instead of changing getter the better option is to
set value of title everytime when user saves changes
For this you shall use interaction workflow, AFAIK.

http://www.erp5.org/HowToUseAndDefineInteractionWorkflows

Solution provided below is good for "static" title - that on, which
wouldn't change on object lifetime.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Tomasz Brzezina
2008-03-31 10:23:55 UTC
Permalink
Post by Łukasz Nowak
For this you shall use interaction workflow, AFAIK.
http://www.erp5.org/HowToUseAndDefineInteractionWorkflows
Solution provided below is good for "static" title - that on, which
wouldn't change on object lifetime.
Where the hell is Interactions tab?
(...)
So now we have to define interaction for our portal types. Go to
Interactions tab, and create PurchaseOrder_titleSetInteraction. Edit it,
and for set fields to:

* Filter : Purchase Order
* Trigger Method Id(s) : edit _edit _setDestinationValue
_setDestinationSectionValue _setSourceValue _setSourceSectionValue order
plan confirm cancel
* Script (after) : PurchaseOrder_titleSetter
--
Tomasz Brzezina

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080331/57e050da/attachment.bin>
Jacek Medrzycki
2008-03-31 10:29:15 UTC
Permalink
Post by Tomasz Brzezina
Post by Łukasz Nowak
For this you shall use interaction workflow, AFAIK.
http://www.erp5.org/HowToUseAndDefineInteractionWorkflows
Solution provided below is good for "static" title - that on, which
wouldn't change on object lifetime.
Where the hell is Interactions tab?
If you don't see Interactions tab, you are probably watching "normal"
workflow definition. Interaction workflows are different kind of stuff.

J.
Tomasz Brzezina
2008-03-31 10:38:09 UTC
Permalink
Post by Jacek Medrzycki
Post by Tomasz Brzezina
Post by Łukasz Nowak
For this you shall use interaction workflow, AFAIK.
http://www.erp5.org/HowToUseAndDefineInteractionWorkflows
Solution provided below is good for "static" title - that on, which
wouldn't change on object lifetime.
Where the hell is Interactions tab?
If you don't see Interactions tab, you are probably watching "normal"
workflow definition. Interaction workflows are different kind of stuff.
ARGHHHH...

It should be written:
Go to Interactions tab *in your interaction workflow definition*, and
create PurchaseOrder_titleSetInteraction

Many thanks ;D
--
Tomasz Brzezina

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080331/805d15e7/attachment.bin>
Łukasz Nowak
2008-03-31 15:44:46 UTC
Permalink
Hello,

On 2008-03-31, 12:38:09
Tomasz Brzezina <tomasz at brzezina.pl> wrote:

(...)
Post by Tomasz Brzezina
Post by Jacek Medrzycki
Post by Tomasz Brzezina
Where the hell is Interactions tab?
If you don't see Interactions tab, you are probably watching
"normal" workflow definition. Interaction workflows are different
kind of stuff.
ARGHHHH...
Go to Interactions tab *in your interaction workflow definition*, and
create PurchaseOrder_titleSetInteraction
Many thanks ;D
Feel free to update wiki/make it more readable. :)

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Tomasz Brzezina
2008-03-31 11:03:51 UTC
Permalink
Well - next problem ....

Go to Interactions tab, and create PurchaseOrder_titleSetInteraction.
Edit it, and for set fields to:

* Filter : Purchase Order
* Trigger Method Id(s) : edit _edit _setDestinationValue
_setDestinationSectionValue _setSourceValue _setSourceSectionValue order
plan confirm cancel
* Script (after) : PurchaseOrder_titleSetter

the listbox Script(after) is has only one option: (None)

what i missed?
--
Tomasz Brzezina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080331/0f910ba1/attachment.bin>
Jacek Medrzycki
2008-03-31 11:26:47 UTC
Permalink
Post by Tomasz Brzezina
the listbox Script(after) is has only one option: (None)
what i missed?
'Script(after)' list displays only scripts defined on Scripts tab of the
workflow. You should create script first and then set interaction.
Post by Tomasz Brzezina
------------------------------------------------------------------------
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-dev
Tomasz Brzezina
2008-03-31 12:50:10 UTC
Permalink
Post by Jacek Medrzycki
Post by Tomasz Brzezina
the listbox Script(after) is has only one option: (None)
what i missed?
'Script(after)' list displays only scripts defined on Scripts tab of the
workflow. You should create script first and then set interaction.
THERE? I made it in portal_skins.... Now OF COURSE it works!

Sometimes its very hard to find something.
--
Tomasz Brzezina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080331/3ead9fa4/attachment.bin>
Loading...