[ZPatterns] Rack.getItem returning attributeless objects (ZPatterns newbie)

Phillip Crumpler [email protected]
Fri, 6 Jul 2001 13:50:35 +1000


> From: Steve Spicklemire [mailto:[email protected]]
>
> Phillip Crumpler wrote:
> >
> > I tried what you suggested - still no banana :-(  So, I tried
> an example so
> > simple even I would have trouble getting it wrong.
> >
> > The rack has a single SQL query, SQL_get:
> >   SELECT name FROM dskins WHERE dskin_id=<dtml-sqlvar dskin_id
> type="int">
> > The table has two columns, dskin_id int and name text.
> > The rack has a single skinscript method, with one line:
> >   WITH QUERY SQL_get(dskin_id=self.id) COMPUTE name
> > The load attribute of the rack is 'name'. The rack stores a
> zclass that is
> > derived from DataSkin, with an index_html method added, nothing else.
> >
> > Still, getItem with a non existent dskin_id will return an
> object. Is this
> > supposed to happen?
> >
>
> Is 'name' in a propertysheet of the ZClass? If so.. it won't
> work! Try this:

Nope, the ZClass has no propertysheets at all, I'm just trying to get
something simple going. Is a propertysheet necessary? After I sent this mail
I changed 'name' to 'thename' just in case it was used anywhere, or an
existing property of the dataskin, but it made no difference.

>
> SELECT name, dskin_id FROM dskins WHERE <dtml-sqltest dskin_id type="int">
>
> set the 'attribute to load' to 'dskin_id'. Make sure that dskin_id is
> *not* in any propertysheet of the ZClass.
>
> -steve

Success! But I don't see why! 'thename' and 'dskin_id' are both coming from
skinscript via SQL_get - they both come from the same query and are listed
in the same skinscript declaration. If the load attribute is set to dskin_id
then getItem('non existent id') returns None, and if set to 'thename' it
will return a class instance with no attrs. The only difference I can see is
that one is an integer and the other a string, could this make a difference?
Beats me...

Thanks for the help Steve and Phillip, I'm sure you'll hear from me again ;)

Cheers,

Phillip Crumpler