[Zope] passing method names into a python script?

Paz paz@chello.nl
Fri, 6 Jul 2001 22:19:20 +0200


Hi Keven,

This is more for your humour than applied use. When I started with Zope a
year ago, I made this ugly, clunky, retarded ZSQL method that would read
tables using a template call:

<dtml-in "select(select='id', as='l1id', sfrom='lgenre1', where='',
operand='', equals='', orderby='id', dir='desc')" size=1 orphan=0>

The ZSQL:
<dtml-call "REQUEST.set('validate', -1)">
<dtml-in "(_.str(select), _.str(as), _.str(sfrom), _.str(where),
_.str(operand), _.str(orderby), _.str(equals), _.str(dir))">
   <dtml-let a=sequence-item>
      <dtml-in "('create', 'drop', 'alter', 'rename', 'optimize', 'backup',
'restore', 'repair', 'delete', 'truncate', 'replace', 'update', 'kill',
'grant', 'revoke', 'set', 'lock')">
   <dtml-let b=sequence-item>
         <dtml-if "_.string.find(_.string.lower(a), b)!=-1">
             <dtml-call "REQUEST.set('validate', 0)">
         <dtml-else>
             <dtml-call "REQUEST.set('validate', 1)">
         </dtml-if>
   </dtml-let>
      </dtml-in>
   </dtml-let>
</dtml-in>
<dtml-if "REQUEST['validate']==1">
   select <dtml-var select> <dtml-if "as">as <dtml-var as></dtml-if> from
<dtml-var sfrom> <dtml-if "where">where <dtml-var where> <dtml-if
"operand"><dtml-var operand><dtml-if "equals"><dtml-var
equals></dtml-if></dtml-if></dtml-if> <dtml-if "orderby">order by <dtml-var
orderby> <dtml-if "dir"><dtml-var dir></dtml-if></dtml-if>
<dtml-elif "REQUEST['validate']==0">
   <dtml-call "REQUEST.set('state', 'ERROR')">
<dtml-elif "REQUEST['validate']==-1">
   <dtml-call "REQUEST.set('action', 'view')">
<dtml-else>
   <dtml-call "REQUEST.set('state', 'ERROR')">
</dtml-if>


I laugh very hard when I look at this, but if you can write the script, you
could very well model it after this. Its fairly secure that you can at least
be prevented from changing records.

Cheers,
Paz

-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Kevin
L
Sent: Friday, July 06, 2001 9:44 PM
To: zope@zope.org
Subject: [Zope] passing method names into a python script?


I want to pass the name of a Z SQL Method into a python script,
then execute that method and iterate over the results. Is this
possible?


My app uses a lot of dropdowns populated from database tables.
Rather than rewriting the code for each one, I'd like to create
one python script that takes a z sql method as a parameter, then
executes it and spits out the html for the dropdown. Every Z SQL
Method would return the same column names (id & value). Has this
been done before?

thanks

-Kevin

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

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