[Zope-dev] ZPatterns and SQL

Phillip J. Eby pje@telecommunity.com
Mon, 19 Feb 2001 11:31:46 -0500


At 02:59 PM 2/19/01 +0100, Christian Scholz wrote:
>
>So as the item is an instance of my ZClass containing also an company_name
attribute
>it will always return the item and because of that the Rack thinks it's
already there.
>So why is this happening? What do I need to change?

You need to use an attribute which the object has *if and only if* it
exists in the database.  If the class has the attribute defined, all
instances exist, and you can't even load it with SkinScript because
ZPatterns uses __getattr__ to redefine attributes, and that doesn't work if
the attribute already exists in the class.


>When changing the loadAttrib to something else (non existing), the newItem
is working
>but instead getItem is not working anymore as it returns None only..
(somehow the zsql
>method is not even called thus the skinscript seems not to work in that
case (I guess
>because the loadAttrib is not defined in it somewhere)).

Right.  The load attribute has to be one defined in a provider, and which
will end up being "NOT_FOUND" if the object doesn't exist in the table
you're querying.