[Zope-dev] ZPatterns + Skinscript
Joachim Schmitz
js@aixtraware.de
Mon, 30 Oct 2000 20:35:46 +0100 (CET)
Hi Steve,
I did exactly (hopefully) as you sugested, but the dtml-method fails with:
(I moved the SkinScript with first to the top)
Error Type: KeyError
Error Value: movie_link
...
File /usr/local/Zope-2.2.0/lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
(Object: testzclass)
File /usr/local/Zope-2.2.0/lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: theItem="getItem('anyOldThing')")
File /usr/local/Zope-2.2.0/lib/python/DocumentTemplate/DT_With.py, line 146, in render
(Object: theItem)
KeyError: (see above)
what's the best way to debug this ?
On Mon, 30 Oct 2000, Steve Spicklemire wrote:
>
> Hi Joachim,
>
> Hmm.. I would start start really simple here, and then 'work up'
> to the sql query.... Create a default rack with the following
> SkinScript.
>
> WITH ['a','b','c'] COMPUTE movie_link=RESULT[0],movie_title=RESULT[1], zeiten=RESULT[2]
>
> Set the storage for this rack to be a DataSkin derived ZClass loaded by
> accessing attribute 'movie_link'. Then try the following method in the Specialist:
>
> <dtml-var standard_html_header>
> <dtml-let theItem="getItem('anyOldThing')">
> <dtml-with theItem>
> <dtml-var movie_link>
> <dtml-var movie_title>
> <dtml-var zeiten>
>
> </dtml-with>
> </dtml-let>
> <dtml-var standard_html_footer>
>
> If this does what you expect.. then you're getting close. Now change the
> ['a','b','c'] to be a call to your query:
>
> WITH yourQuery(... parameters for your query... ) COMPUTE movie_link, movie_title... etc.
>
> If you get the same errors in the first case.. then your problem has
> nothing to do with SQL.
>
> -steve
>
> >>>>> "Joachim" == Joachim Schmitz <js@aixtraware.de> writes:
>
> Joachim> On Mon, 30 Oct 2000, Steve Spicklemire wrote:
>
> >> Hi Joachim,
> >>
> >> rackList just refers to the racks in the 'racks' tab of the
> >> Specialist. Do you have any racks defined for this Specialist?
> >> The rackList is managed magically with the plug-in-group stuff.
> >>
> Joachim> Yes that's what I found too, but it doesn't work, with
> Joachim> SQL-database and SkinScripts, the setup is described
> Joachim> below:
>
> >> >>>>> "Joachim" == Joachim Schmitz <js@aixtraware.de> writes:
> >>
> Joachim> for debugging I inserted in Specialists.py in getItem:
> >>
> Joachim> return str(self.rackList) <-- inserted for rack in
> Joachim> self.rackList: item = rack.__of__(self).getItem(key) if
> Joachim> item is not None: return item
> >>
> Joachim> this alway returns an empty list, when calling it from
> Joachim> the dtml:
> >>
> Joachim> <dtml-var "getItem(_.int(609))"> returns "[]"
> >>
> Joachim> I tried to follow the magic how this rackList is setup,
> Joachim> but it is to much python-Zen for me.
> >>
> Joachim> On Sun, 29 Oct 2000, Joachim Schmitz wrote:
> >> >> On Sat, 28 Oct 2000, Phillip J. Eby wrote:
> >> >>
> >> >> > At 05:17 PM 10/28/00 +0200, Joachim Schmitz wrote:
> >> >> > >
> >> >> > >select e.event_id as event_id > >,e.zeiten as zeiten > >>
> >> >,v.firma as firma > >,v.tel as tel > >,e.movie_id as movie_id
> >> >> > >,m.movie_title as movie_title > >,m.movie_link as
> >> movie_link >> > >,m.movie_text as movie_text > >,e.datum_von as
> >> datum_von > >> >,e.datum_bis as datum_bis > >from event as e,
> >> veranstalter as >> v, movies as m > >where > >e.event_id =
> >> <dtml-sqlvar e_id >> type=int> > >and e.movie_id = m.movie_id
> >> and e.veran_id = >> v.veran_id > >order by m.movie_title
> >> >> >
> >> >> > Just out of curiosity, why do you have an "order by"
> >> clause, >> if this is > supposed to only return one row? If
> >> more than one >> item is returned by this > query, only the
> >> first will be used >> to supply data to your DataSkin.
> >> >> >
> >> >> that was just left over from an reused query-template, I
> >> forgot >> to take it out.
> >> >>
> >> >> >
> >> >> > >I also added a SkinScript method as a Data Plug-in in the
> >> >> defaultRack like > this
> >> >> > >
> >> >> > >WITH QUERY readEvents(e_id=self.event_id) COMPUTE >>
> >> zeiten,firma,tel > >,movie_id,movie_text,movie_link,movie_title
> >> >> > >,datum_von,datum_bis,zeiten
> >> >> >
> >> >> > Do you have some way of providing self with an "event_id"
> >> >> value? Keep in > mind that when DataSkins are created, they
> >> >> have only an "id" attribute, > nothing else. So unless you
> >> >> have an attribute provider that provides an > "event_id"
> >> value, >> this statement will fail. Perhaps what you actually
> >> mean > is:
> >> >> >
> >> >> > WITH QUERY readEvents(e_id=self.id) COMPUTE > event_id, >
> >> >> zeiten,firma,tel, >
> >> movie_id,movie_text,movie_link,movie_title, >> >
> >> datum_von,datum_bis,zeiten
> >> >> >
> >> >> > Notice that I'm passing self.id to readEvents, and that
> >> I've >> added event_id > to the list of attributes retrieved
> >> from the >> query.
> >> >> >
> >> >> how do I set "self.id" I tried in dtml-method in the >>
> >> event-specialist: There is a event_id 609 in the table:
> >> >>
> >> >> <dtml-var "getItem(_.int(609))"> returns none or <dtml-var
> >> >> "getItem(key=_.int(609))"> returns none
> >> >>
> >> >>
> >> >> >
> >> >> > >under the storage tab I selected for:
> >> >> > >
> >> >> > >Class to use for stored items: ZPatterns:DataSkin and
> >> >> > >
> >> >> > >Objects are: o stored persistently. > > x loaded by >>
> >> accessing attribute: event_id
> >> >> >
> >> >> > This will work fine, if you use the revised SkinScript
> >> above. >> You will > probably want to create a ZClass subclass
> >> of >> DataSkin at some point to use > instead, so that you can
> >> define >> permissions, methods, and so on for your > Event
> >> objects.
> >> >> >
> >> >> >
> >> >>
Mit freundlichen Grüßen
Joachim Schmitz
AixtraWare, Ing. Büro für Internetanwendungen
Hüsgenstr. 33a, D-52457 Aldenhoven
Telefon: +49-2464-8851, FAX: +49-2464-905163
_______________________________________________
Zope-Dev maillist - Zope-Dev@zope.org
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 )