Re: [Zope-dev] ZPatterns and SQL

2001-02-19 Thread Christian Scholz

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 [EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] ZPatterns and SQL

2001-02-19 Thread Phillip J. Eby

At 05:29 PM 2/19/01 +0100, Christian Scholz wrote:
 
 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? ;-)

You can't do this with a load attribute, because a default value will
exist.  The easiest way to deal with this is simply to have a seperate
attribute name just for loading, or use an attribute that isn't on a
property sheet.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] ZPatterns and SQL

2001-02-19 Thread Christian Scholz

Hi!

 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? ;-)
 
 You can't do this with a load attribute, because a default value will
 exist.  The easiest way to deal with this is simply to have a seperate
 attribute name just for loading, or use an attribute that isn't on a
 property sheet.

Ok, I now removed customer_id (which won't be set anyway as this is the
id set by the database automatically) from the propertysheet and used
this as loading attribute. Seems to work now :)
(though I am still confused a little, as I tried one non-existing
attribute and it didn't work. But this one also was not defined inside
the SkinScript and the database).

But it's working now, so it's ok :)

Thanks again!

Christian

-- 
COM.lounge  http://comlounge.net/
communication  design [EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] ZPatterns and SQL

2001-02-19 Thread Phillip J. Eby

At 05:50 PM 2/19/01 +0100, Christian Scholz wrote:

(though I am still confused a little, as I tried one non-existing
attribute and it didn't work. But this one also was not defined inside
the SkinScript and the database).

As I said, the attribute must exist if and only if the row is in the
database.  Thus, it must *not* exist on the propertysheet, and it *must*
exist in your SkinScript.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )