Discussion:
[Erp5-dev] date/time properites' constraint check
Mikolaj Antoszkiewicz
2008-05-16 10:11:45 UTC
Permalink
Hello,

When using PropertyExistence constraint class I noticed that when date
properties fail the constraint check it always returns the
'message_no_such_property' type of message.

It looks like that, because hasProperty tester always returns False, if
the date/time property is unset, just like it was non-existent property.

Maybe it's a matter of treating the date properties differently here.
But in such a generic class I guess it's not good to test for property's
type.

Any ideas?

Mikolaj
Mikolaj Antoszkiewicz
2008-05-16 10:28:54 UTC
Permalink
Post by Mikolaj Antoszkiewicz
Hello,
When using PropertyExistence constraint class I noticed that when date
properties fail the constraint check it always returns the
'message_no_such_property' type of message.
It looks like that, because hasProperty tester always returns False, if
the date/time property is unset, just like it was non-existent property.
What I somehow missed in the last post is that all other properties
behave similarly.
But for them the attached patch solves the problem (typo corrections
included)
- instead of hasProperty, I propose using getProperty with additional
parameter.

Mikolaj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PropertyExistence.py.patch
Type: text/x-patch
Size: 1245 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080516/bda6e0a6/attachment.bin>
Jérome Perrin
2008-05-19 11:12:37 UTC
Permalink
Hello,
Post by Mikolaj Antoszkiewicz
Post by Mikolaj Antoszkiewicz
Hello,
When using PropertyExistence constraint class I noticed that when date
properties fail the constraint check it always returns the
'message_no_such_property' type of message.
It looks like that, because hasProperty tester always returns False, if
the date/time property is unset, just like it was non-existent property.
What I somehow missed in the last post is that all other properties
behave similarly.
But for them the attached patch solves the problem (typo corrections
included)
For now, I'll commit those typos fixs, thanks.
Post by Mikolaj Antoszkiewicz
- instead of hasProperty, I propose using getProperty with additional
parameter.
According to Jean-Paul's message, the message associated with
hasProperty returning False here was wrong. As far as I know, there's no
easy way to know if a property is associated to this document or not,
but afterall does this constraint needs to make a difference wether the
property is not associated to this type (this would be the programmer's
mistake) or the property is not set by the user ?
What about changing this constraint to only check if the property has
been set by the user ?

J?rome

Jean-Paul Smets
2008-05-16 14:44:21 UTC
Permalink
hasProperty returns False in 2 cases
- the property does not exist in the schema defined by propertysheets
- the property exists in the schema defined by propertysheets but was never defined

Regards,

JPS.
Post by Mikolaj Antoszkiewicz
Hello,
When using PropertyExistence constraint class I noticed that when date
properties fail the constraint check it always returns the
'message_no_such_property' type of message.
It looks like that, because hasProperty tester always returns False, if
the date/time property is unset, just like it was non-existent property.
Maybe it's a matter of treating the date properties differently here.
But in such a generic class I guess it's not good to test for property's
type.
Any ideas?
Mikolaj
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-dev
--
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 62 05 76 14
ERP5 Enterprise: Free / Open Source ERP for Critical Applications
http://www.erp5.com
ERP5 Express: Hosted Open Source ERP for small companies
http://www.myerp5.com
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
Loading...