Discussion:
[Erp5-dev] Relation String Field - using something other than title
Łukasz Nowak
2007-08-06 09:38:21 UTC
Permalink
Hello,

I've got two types: A and B. I want to relate A -> B by category
'category'.

So for type A I've created form which has RelationStringField:

my_category_title

Configured as said on wiki[1].

All works fine. But my type B has also shu_prop property, which is
catalogued. So I created another RelationStringField for A type with:

my_category_shu_prop

And set 'Catalog Index' to shu_prop.

Almost all works great:
* my newly created field sets relation between A and B
* I'm able to narrow searching in shu_prop field by typing some parts
of shu_prop property
* even my_category_title is updated (because it is reading from
object the relating category, isn't it? (or smth similar))

Only thing, which do not work, is that on my_category_shu_prop no text
is shown and so no jump field is available, etc.

How my I gain such behaviour? Shall I patch ERP5Type/Utils.py and
ERP5Type/Accessors/Value.py and create there getter/setter for ShuProp?

I've create script in portal_skins getCategoryShuProp, but it is not
invoked.

Any tips welcome.

Regards,
Luke

[1]http://www.erp5.org/HowToConfigureRelationField
--
?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...''
Jérome Perrin
2007-08-09 08:18:22 UTC
Permalink
Post by Łukasz Nowak
Hello,
I've got two types: A and B. I want to relate A -> B by category
'category'.
my_category_title
Configured as said on wiki[1].
All works fine. But my type B has also shu_prop property, which is
my_category_shu_prop
And set 'Catalog Index' to shu_prop.
* my newly created field sets relation between A and B
* I'm able to narrow searching in shu_prop field by typing some parts
of shu_prop property
* even my_category_title is updated (because it is reading from
object the relating category, isn't it? (or smth similar))
Only thing, which do not work, is that on my_category_shu_prop no text
is shown and so no jump field is available, etc.
How my I gain such behaviour? Shall I patch ERP5Type/Utils.py and
ERP5Type/Accessors/Value.py and create there getter/setter for ShuProp?
Hello,

Yes, a way is to generate category accessors for getCategoryShuProp, but
an easiest way is to use something like 'python:
context.getCategoryValue().getShuProp()' in the 'default' TALES of your
relation field.

( you can add a condition to handle the case where
context.getCategoryValue() is None )

J?rome
Łukasz Nowak
2007-08-09 08:31:03 UTC
Permalink
Hello,

On 2007-08-09, 10:18:22
J?rome Perrin <jerome at nexedi.com> wrote:
(...)
Post by Łukasz Nowak
Post by Łukasz Nowak
How my I gain such behaviour? Shall I patch ERP5Type/Utils.py and
ERP5Type/Accessors/Value.py and create there getter/setter for ShuProp?
Hello,
Yes, a way is to generate category accessors for getCategoryShuProp,
context.getCategoryValue().getShuProp()' in the 'default' TALES of
your relation field.
It was so simple...
Post by Łukasz Nowak
( you can add a condition to handle the case where
context.getCategoryValue() is None )
You mean:

python: context.getCategoryValue() is not None and \
context.getCategoryValue().getShuProp() or ''
?

Is it enough "stable" to put this use case of RLS on wiki[1]?

Thanks,
Luke

[1]http://www.erp5.org/HowToConfigureRelationField
--
?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...''
Jérome Perrin
2007-08-09 08:50:46 UTC
Permalink
Post by Łukasz Nowak
Post by Jérome Perrin
( you can add a condition to handle the case where
context.getCategoryValue() is None )
python: context.getCategoryValue() is not None and \
context.getCategoryValue().getShuProp() or ''
?
Yes, but you better use this syntax, in case getShuProp() evaluates
false (eg. 0):

python: test(context.getCategory(),
context.getCategoryValue().getShuProp(), '')
Post by Łukasz Nowak
Is it enough "stable" to put this use case of RLS on wiki[1]?
Yes

J?rome

Loading...