[Zope-dev] ZPatterns + Skinscript

Steve Spicklemire steve@spvi.com
Mon, 30 Oct 2000 11:47:47 -0500 (EST)


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.
    >> >> > 
    >> >> > 
    >> >> 

    Joachim> Mit freundlichen Grüßen

    Joachim> Joachim Schmitz

          
    Joachim> AixtraWare, Ing. Büro für Internetanwendungen
    Joachim> Hüsgenstr. 33a, D-52457 Aldenhoven Telefon:
    Joachim> +49-2464-8851, FAX: +49-2464-905163