[Zope] Questions re: REQUEST, external methods; newbie stupidity at play

Jim Penny jpenny@universal-fasteners.com
Thu, 17 Jul 2003 15:09:53 -0400


On Thu, 17 Jul 2003 14:52:24 -0500
John Ziniti <jziniti@speakeasy.org> wrote:

> Bryan White wrote:
> 
> > I have actually begun to lament that I chose to go with Zope on this
> > 
> > particular project (don't get me wrong - I am a near-religous Zope 
> > advocate) - this project is not about content management in the
> > least, it's a big beast of a SQL / XML monster. Zope oddities have
> > been more in my way than they have been helpful. Again, I am
> > perfectly willing to believe that I am simply doing things WRONG.
> > The only big win I get from Zope on this project so far is
> > users/roles, and not having to code that stuff.
> >
> Me too.  The security model of Zope is one of its great
> features.  Maybe I am missing something.   I've gone
> through the line of posts, but  I still don't understand why
> you can't do the entire thing in on External Method.
> 
> This lets you do all the work in Python, and avoid the
> idiosyncracies of REQUEST.set; but you still get REQUEST
> when you need it -- to get data *from* the client and
> to return the
> results.
> 
> Or maybe I am missing something crucial?  Is it the ZSQL
> calls that "require" goign back and forth from EMs to DTML?
> 
> JZ

You can work in DTML, ZPT, Script python, or external methods.  Any do
fine.  If you work in pythonic methods, then you are making some
trade-offs.  You have to understand the result-set returned by ZSQL.
See http://www.zope.org/Members/spinwing/ZSQL_Results.

You are responsible for digging out name to column references yourself.
There are two basic ways of doing it -- hardwiring it, and this
(script python syntax, which I would prefer to external methods
wherever possible):

res=container.my_sql_query(parameter1=value1, p2=v2, ...)
names=res.names()
n2i={}
for i in range(len(names)):
  n2i[names[i]]=i

Then you can refer to the i'th row with column name foo as

res[i][n2i['foo']]

You can also mix models and pass the request in as the parameter to the
query.  I would discourage that.  If you want to go this route, be
explicit, and give actual parameters.

Jim Penny

> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
> 
>