[Zope3-Users] Help us! Calling a Python Script from ZPT

Paolo Cilmo blackeight_zope at yahoo.it
Tue Nov 1 06:21:14 EST 2005


OK, I perhaps don't have been clear in my previous e-mail. 
I need to write a little site using ZOPE3 as i using ZOPE2.
Really i've also write an application on ZOPE3 by ZMI (the same in ZOPE2). This application insert (by a form) values in a database written in MySQL. Typical use is composed by the following steps:
 
1- a Page Template containing a form;
localhost:8080/Mercatino/iscrizione_form:

<html>

<span 

tal:replace="structure container/header">

</span>

<body>

<h1> Iscrizione </h1>

<form action="../iscrizione/iscrizione_html" method="post">

<table width="100%">

<tr>

<td> Nome:</td>

<td> <input type="text" name="nome" size=20></td>

</tr>

<tr>

<td> Cognome:</td>

<td> <input type="text" name="cognome" size=20></td>

</tr>

<tr>

<td> E-mail:</td>

<td> <input type="text" name="email" size=20></td>

</tr>

<tr>

<td> Telefono:</td>

<td> <input type="text" name="tel" size=20></td>

</tr>

<tr>

<td> User:</td>

<td> <input type="text" name="user" size=20></td>

</tr>

<tr>

<td> Password:</td>

<td> <input type="text" name="password" size=10></td>

</tr>

<td colspan=2>

<input type="submit" value="Invia">

</td>

</table>

</form>

</body>

</html> 

 

2- Previous form call a new ZPT, iscrizione_html in localhost:8080/Mercatino/iscrizione_html. 


<html>

<span 

tal:replace="structure context/../header">

</span>

<body>

<p tal:content="context/zope:title"></p>

<span tal:condition="request/nome | nothing">

<span tal:condition="request/cognome | nothing">

<span tal:condition="request/email | nothing">

<span tal:condition="request/tel | nothing">

<span tal:condition="request/user | nothing">

<span tal:condition="request/password | nothing">

<p tal:define="global nome request/form/nome"></p>

<p tal:define="global cognome request/form/cognome"></p>

<p tal:define="global email request/form/email"></p>

<p tal:define="global tel request/form/tel"></p>

<p tal:define="global user request/form/user"></p>

<p tal:define="global password request/form/password"></p>

<span tal:define="sql_conn string:utility_db">

<span tal:repeat="a sql: INSERT INTO utenti VALUES ('${user}', '${password}')">

</span>

<span tal:repeat="b sql: INSERT INTO anagrafica VALUES ('${user}', '${nome}', '${cognome}', '${email}', '${tel}')">

</span>

<h2>Inserimento effettuato</h2>

<h2>Benvenuto <b tal:content="nome">nome</b> <b tal:content="cognome">cognome</b>!<br /> Sei identificato come <b tal:content="user">user</b> </h2>

</span>

</span>

</span>

</span>

</span>

</span>

</span>

<span tal:condition="not:request/nome | nothing">

<h3>Non hai inserito il nome</h3>

</span>

<span tal:condition="not:request/cognome | nothing">

<h3>Non hai inserito il cognome</h3>

</span>

<span tal:condition="not:request/tel| nothing">

<h3>Non hai inserito il telefono</h3>

</span>

<span tal:condition="not:request/email | nothing">

<h3>Non hai inserito la mail</h3>

</span>

<span tal:condition="not:request/user | nothing">

<h3>Non hai inserito la user</h3>

</span>

<span tal:condition="not:request/password | nothing">

<h3>Non hai inserito la password</h3>

</span>

 

<a href=../../iscrizione_form><button>Torna all'inserimento</button></a>

<br/><br/>

<a href=../../index.html><button>Torna alla home</button></a>

</body>

</html> 
This ZPT use the package sql expr (but i don't like presentation and logic in the same object...) for use a query. I use "sqlexpr" because i don't know how pass parameter to a ZSQL script (passing parameter to a ZSQL in ZOPE2 work perfectly, but in the damned ZOPE3 NO!!!). How i can pass parameters?
 
3- THE REAL PROBLEM IS:
In ZOPE2, if i want to use a PYTHON code, i insert a Python(script) into a folder and i call the script by using a ZPT (tal:repeat for example). In ZOPE2, NO PROBLEM but.....
In ZOPE3, I can't insert a Python script by the ZMI, but i need to write a package (__init__.py, python class, ZCML etc...). I need a lot of examples for:
   a: write a package for my using  and not like examples on zope.org
   b: write the ZPT that call the package
   c: acquisition doesn't work like ZOPE2
 
Now I HOPE that i've been clear.
Thanks and sorry for my VERY VERY bad English

Jean-Marc Orliaguet <jmo at ita.chalmers.se> ha scritto: 
Wade Leftwich wrote:

> Stephan Richter wrote:
>
>>
>>
>> Why not have those templates on the file system? Is there a need for
>> users to modify those templates?
>
>
> Yes, users with the job description "web producers", which is to say
> people who can do HTML and a bit of scripting, but who do not get
> access to the file system. Kind of like the Zope 2 model. We even use
> acquisition.
>
> Also, it seemed to me unwieldy to put 50 directories in the filesystem
> to contain the templates for all the sites. But because of my
> experience with Zope 2, I assumed TTW was the best way to customize
> the application for each site, and I guess I should re-examine that
> assumption.
>
Hi!
there is indeed such a category of users, i.e. somewhere between
filesystem developers and application users. There will be support for
this kind of TTW editing in cpsskins (cf Custom Portlet), but it will be
purely limited to "simple" presentation logic.

cf. http://www.z3lab.org/sections/front-page/design-features/custom-portlet

the difference with the Zope2 model I think is that "web producers" are
not going to be ZPT programmers, but more like "site composers" with the
ability to do minimal TTW template editing such as shown in the animation.

/JM

		
---------------------------------
Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20051101/df103244/attachment.htm


More information about the Zope3-users mailing list