OT Re: [Zope-DB] writing a template to test if the sql worked

Charlie Clark charlie at egenix.com
Thu May 6 11:23:09 EDT 2004

On 2004-05-06 at 13:20:27 [+0200], Philip Kilner wrote:
> Re. ZPT, well all my stuff is "inside" (e.g. in, or called by)
> index_html, which is a ZPT. So, calling "/therapist/add/" causes that
> ZPT to be thrown to render the request. My formulator forms are called
> by a universal "form rendering ZPT", called in turn by the top-level
> ZPT, and the sequence of forms is defined in a TinyTable - as each form
> is validated, the captured data is stashed in the session object, and
> the next form in the sequence is thrown. At the end of the sequence,
> instead of the form-rendering ZPT being called a "result" ZPT is called,
> which calls the script which commits to the RDBMS and tidies up the
> session, then displays the data in the RDBMS as confirmation - or does
> error handling stuff, or whatever.
> All forms submit to ".", which equates - in my misty understanding - to
> "self" - e.g. index_html, which in turn calls the script.

essentially yes "." is the current folder in many file systems so will equate 
to the same URL in a form action.
> So, to apply this to a new process, I only need to define the formulator
> objects, the sequence, and the results script and page - everything else
> is now automated/generic.
> Re. the compartmentalisation, absolutely - each bit is intelligible.

Yes, this is the key. As long as you're happy with it. I'd have to look at 
the source to get the full picture but it sounds reasonable, better in some 
ways than some of the things I've done. I really need to sit down with 
Formulator and see if I can't get my head around it.

> Understood - in the scenario above, I initially set out merely to make
> the formulator stuff generic. However, when I'd done that I was itching
> to get the process /sequence/ out of the controlling script - which is
> otherwise also completely generic.

This is right way of doing things. Using TinyTable or the ZODB makes the 
process itself manageable and flexible.
> Yes - you originally helped us out by describing this approach. However,
> the name space and scope stuff was fatally frustrating - I feel as
> though working down from the ZPT helps me visualise it more readily, as
> if that were somehow more "tangible" if that makes any sense.

Acquisition can be painful. Namespaces and scopes are common gotchas 
> > However, Jim Penny made a very good case for having a PythonScript
> > essentially be the index_html calling ZPTs or other objects as required 
> > this
> > being a good way of preventing unpleasant or unexpected things happening. 
> > I
> > can't find it locally or online, maybe he can repost it.
> > 
> I'd be interested - now I've got it working "my" way, I may have picked
> up enough understanding to figure out the stuff that I couldn't suss
> before...

His approach is, essentially, similar to your own except he puts all the 
flow-control within a PythonScript. This makes a lot of sense for more 
complicated things than simply going through a sequence as you can use nice 
things like "dispatching" within Python. But then again the temptation is 
great to integrate real workflow for this as well.

More information about the Zope-DB mailing list