[Zope-dev] ZPatterns and SQL
Christian Scholz
cs@comlounge.net
Mon, 19 Feb 2001 17:29:42 +0100
Hi!
> >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.
So I shouldn't define it inside the ZClass propertysheet?
Do I understand this right?
(I remember having problems when using properties not defined in a
sheet somewhere.. or am I mistaken completely somehow? ;-)
> >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.
I will experiment a little with this information. Hope it helps :)
Thanks!
-- christian
--
COM.lounge http://comlounge.net/
communication & design info@comlounge.net