[Zope-DB] Hello!

Jim Penny jpenny@universal-fasteners.com
Fri, 25 Jul 2003 12:28:55 -0400

On Fri, 25 Jul 2003 16:55:52 +0100
Philip Kilner <phil@xfr.co.uk> wrote:

> Hi Jim,
> Jim Penny wrote:
> >>>1)  index_html is ALWAYS a Script (Python) in any of my code from
> >>>the last 18 months.
> >>
> >>OK, so since this is our default "document", Zope will throw it when
> >>we hit our folder and so it controls the logic?
> > 
> > Right.
> > 
> Good - one bit properly understood.
> >>OK, understand that - not sure why the form has: -
> >>
> >>	action="."
> >>
> >>How does that work here - is it calling itself?
> > 
> > Well, kind of.  Think of it as an event loop.  The client receives a
> > form.  He submits it.  Now, what processes the submission?  In this
> > scheme, _the same index_html as was used to generate the form
> > in the first instance is responsible for processing the data_.  That
> > is the "running in place" part of the scheme.  We never leave the
> > folder, so we never have to redirect.
> > 
> Ah...so we've never "left" the index_html script?

Yes (and no).  Remember, there are always at least two different
execution contexts going on (normally on two different computers) - that
of the browser and that of the server.

What is really going on is that the browser is given a bit of HTML to
"execute".  That bit of HTML has a form in it, and the form tells the
server what to execute next (via the action), and what data to execute
against, the request.  

What I am saying is that it is not necessary to go to a new folder to
process every interaction, and that it is indeed a bit counterproductive
in many instances - since you get to the bottom and then have to get the
browser back up the folder tree - either by forcing the user to click a
button that snaps him back up, which slows down and irritates the user,
or by using a redirect, which slightly increases network traffic, and
has other problems.  

So, for as long as the browser stays in this "execution sheaf", we
arrange that every form says "use the current URI to process the form
that this URI generated last time".  "." is the current URI.  Note:  it
can be omitted completely, and still work.  You can use
<form method="post">...</form>.  This will do exactly the same as
<form action="." method="post">...</form>.  I prefer the longer format
as it explicitly tells me what URI will be handling the form when
received, namely, this URI.

> I'm used to seeing either a file name or a script name here - for 
> example, in the ASP code generated by DreamWever I would have the 
> generic MM db "CRUD" scripts...
> > OK, my fault (I like to define context and request as parameters to
> > all Script (Python)s except index_html (where you may not do so, due
> > to the ZPublisher machinery!), as it makes the calling sequence more
> > uniform. make the first line of your script: 
> > 
> > request=context.REQUEST
> > 
> OK - Done that, and it now falls over at the next step: -
> 	NameError: global name 'main_menu_form_pt' is not defined

        Normally main_menu_form_pt will be in the same folder as
index_html, so the container place-holder is preferred.  (less overhead)
> So, I need to understand the syntax in this Pytin Script which would 
> actually call the Page Template...I can see that 'main_menu_form_pt'
> is what is being returned by the script, and that this is the name of
> the PT - but what tells the script it is to throw a template?

Whatever object is returned from index_html is delivered to the browser
automatically by, I think,  ZPublisher.
> >>Is insert_ISBN_sql our ZSQL method here?
> > 
> > Right, the ZSQL method that does an insert.  You will probably also
> > have an update, and a delete method, and certainly one or more
> > select methods.
> > 
> Got it - I can see how that bit should fit togther.
> >>Same question about "method" here as for "action" above - how the
> >>period works? Are these transposed by any chance?
> > 
> > Yeah, transposed.  Hey, this was composed at screen without
> > testing....;-P
> > 
> <grin> At least I demonstrated that I am working at understanding this
> stuff...
> I'm sorry this is turning out so laborious - I do truly appreciate
> your help!
> -- 
> Regards,
> PhilK
> Email: phil@xfr.co.uk / Voicemail & Facsimile: 07092 070518
> "the symbols of the divine show up in our world initially at the trash
> stratum." Philip K Dick