[Zope] New user - couple of questions
Jose Soares
jose@sferacarta.com
Wed, 06 Dec 2000 15:01:43 +0100
--------------A7E2BBEF4E697DC3321A5F87
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Paolo Quaglia wrote:
> Hi to all,I'm a new Zope user/developer ... Zope has impressed me
> very much!Ihave a couple of questions.I want to build a new intranet
> site for my company using Zope, but:1. How can I import and use Python
> modules For example I want to use the function sleep(secs) that
> resides in the time module.I wrote this code: import time def
> hello(self):
> sleep(10)
> return "I'm Back!!"
>
>
>
>
> Better if you write this function like this:
> import time
> def hello(self):
> time.sleep(10)
> return "I'm Back!!"
>
> 1. give it a name, say pippo.py
> 2. then go back to your zope and add an External Method
> 3. put id=pluto
> 4. function name=hello
> 5. python module=pippo
> 6. save it
>
> If you want to try it create a DTML Document for example and put in it
> the the following command:
> <dtml-var pluto>
> and then view the DTML Document,
> after a while i.e. 10 secs you will see the message: I'm Back!!
>
> but when I call the external method bounded with the hello function
> an error occours!!1st. Have I to install the time module? - if yes
> where can I found it and where can I install it?2nd. How do I have to
> call the sleep function?2. I want to build an application that use the
> database transection to update rows.I use SQL server that support DB
> transactions.where can I build SQL transactions with Zope? do I have
> to build a ZSQL method with multiple SQL calls? .. for example:...
> If I am not mistaken,
> zope works all the time in transaction mode, then you don't need to
> expecify
> transactions at all.
>
>
> begin transaction <dtml-var sql_delimiter> update t_cliente set
> primaetichinterna = 'mia' <dtml-var sql_delimiter> commit....Am I sure
> that the transaction will work (if another user use the same method at
> the same time)?How can I test if a transaction has been committed or
> aborted?Thanks VERY MUCH in advancePaolo QuagliaSitek Spa Italy Paolo
> Quaglia
> Information Technology Coordinator
> Sitek S.p.A.
> paolo@sitek.it
Ciao
José Soares - Italy
--------------A7E2BBEF4E697DC3321A5F87
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<p>Paolo Quaglia wrote:
<blockquote TYPE=CITE> <span class=948180210-06122000><font face="Arial"><font size=-1>Hi
to all,</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>I'm
a new Zope user/developer ... Zope has impressed me very much!</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>Ihave
a couple of questions.</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>I
want to build a new intranet site for my company using Zope, but:</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>1.
How can I import and use Python modules </font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>For
example I want to use the function <i>sleep(secs) </i>that resides in the
<b>time</b> module.</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>I
wrote this code:</font></font></span> <font face="Arial"><font size=-1>import
time</font></font> <font face="Arial"><font size=-1>def hello(self):</font></font>
<br><font face="Arial"><font size=-1> sleep(10)</font></font>
<br><font face="Arial"><font size=-1> return "I'm Back!!"</font></font>
<br><font face="Arial"><font size=-1></font></font>
<br><font face="Arial"><font size=-1></font></font>
<br><font face="Arial"><font size=-1></font></font> <font face="Arial"><font size=-1></font></font>
<p><font face="Arial"><font size=-1>Better if you write this function like
this:</font></font>
<br><font face="Arial"><font size=-1>import time</font></font>
<br><font face="Arial"><font size=-1>def hello(self):</font></font>
<br><font face="Arial"><font size=-1> time.sleep(10)</font></font>
<br><font face="Arial"><font size=-1> return
"I'm Back!!"</font></font><font face="Arial"><font size=-1></font></font>
<p><font face="Arial"><font size=-1>1. give it a name, say pippo.py</font></font>
<br><font face="Arial"><font size=-1>2. then go back to your zope and add
an External Method</font></font>
<br><font face="Arial"><font size=-1>3. put id=pluto</font></font>
<br><font face="Arial"><font size=-1>4. function name=hello</font></font>
<br><font face="Arial"><font size=-1>5. python module=pippo</font></font>
<br><font face="Arial"><font size=-1>6. save it</font></font><font face="Arial"><font size=-1></font></font>
<p><font face="Arial"><font size=-1>If you want to try it create a DTML
Document for example and put in it the the following command:</font></font>
<br><font face="Arial"><font size=-1><dtml-var pluto></font></font>
<br><font face="Arial"><font size=-1>and then view the DTML Document,</font></font>
<br><font face="Arial"><font size=-1>after a while i.e. 10 secs you will
see the message: I'm Back!!</font></font>
<br><font face="Arial"><font size=-1></font></font>
<br><font face="Arial"><font size=-1></font></font> <span class=948180210-06122000><font face="Arial"><font size=-1>but
when I call the external method bounded with the hello function an error
occours!!</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>1st.
Have I to install the time module?</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>
- if yes where can I found it and where can I install it?</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>2nd.
How do I have to call the sleep function?</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>2.
I want to build an application that use the database transection to update
rows.</font></font></span><span class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>I
use SQL server that support DB transactions.</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>where
can I build SQL transactions with Zope? </font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>do
I have to build a ZSQL method with multiple SQL calls? .. for example:</font></font></span><span
class=948180210-06122000></span><span
class=948180210-06122000><font face="Arial"><font size=-1>...</font></font></span>
<br>If I am not mistaken,
<br>zope works all the time in transaction mode, then you don't need to
expecify
<br>transactions at all.
<br>
<p><span class=948180210-06122000><font face="Arial"><font size=-1>begin
transaction</font></font></span> <span class=948180210-06122000><font face="Arial"><font size=-1><dtml-var
sql_delimiter></font></font></span> <span class=948180210-06122000><font face="Arial"><font size=-1>update
t_cliente set primaetichinterna = 'mia'</font></font></span> <span class=948180210-06122000><font face="Arial"><font size=-1><dtml-var
sql_delimiter></font></font></span> <span
class=948180210-06122000><font face="Arial"><font size=-1>commit</font></font></span><span
class=948180210-06122000><font face="Arial"><font size=-1>....</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>Am
I sure that the transaction will work (if another user use the same method
at the same time)?</font></font></span><span class=948180210-06122000><font face="Arial"><font size=-1>How
can I test if a transaction has been committed or aborted?</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>Thanks
VERY MUCH in advance</font></font></span><span
class=948180210-06122000></span><span class=948180210-06122000><font face="Arial"><font size=-1>Paolo
Quaglia</font></font></span><font face="Arial"><font size=-1>Sitek Spa
Italy</font></font> <span
class=948180210-06122000></span><span
class=948180210-06122000></span><font face="Arial"><font size=-1>Paolo
Quaglia</font></font>
<br><font face="Arial"><font size=-1>Information Technology Coordinator</font></font>
<br><font face="Arial"><font size=-1>Sitek S.p.A.</font></font>
<br><font face="Arial"><font size=-1>paolo@sitek.it</font></font> </blockquote>
Ciao
<br>José Soares - Italy
<br> </html>
--------------A7E2BBEF4E697DC3321A5F87--