global variable persistence in a python script (external method)

3 messages Options
Embed this post
Permalink
m.banaouas

global variable persistence in a python script (external method)

Reply Threaded More More options
Print post
Permalink
Hi,
I have an External Method myEM associated to myFunc funtion inside myScript.py module.
myScript.py
------------------
myVar = ''
#
def myFunc(self , req):
   global myVar
   ...
#
I would like to know if the global variable myVar will keep its state (data) between myEM calls.
I gess that there is another way to do that via self.session, but in my case, myVar contains data serving any session (any user); that why I'm look for a persistent solution.
In the same way, is it possible to keep myvar content in zope database ?

thanks
m.banaouas

Re: global variable persistence in a python script (external method)

Reply Threaded More More options
Print post
Permalink
m.banaouas wrote:
Hi,
I have an External Method myEM associated to myFunc funtion inside myScript.py module.
myScript.py
------------------
myVar = ''
#
def myFunc(self , req):
   global myVar
   ...
#
I would like to know if the global variable myVar will keep its state (data) between myEM calls.
I gess that there is another way to do that via self.session, but in my case, myVar contains data serving any session (any user); that why I'm look for a persistent solution.
In the same way, is it possible to keep myvar content in zope database ?

thanks

désolé, je me suis trompé de <<regional forum>>

bonjour,
Est-ce que les variables globales d'un script sont persistantes entre deux appels à une "external method" associée?
exemple:

code:
script myscript.py
------------------
myvar = ''
#
def myfunc(self , req):
   global myvar  
   ...
#

Je sais que c'est possible avec self.session mais dans mon cas myvar (en fait un dict) nécessite un temps de calcul, raison pour laquelle je veux la mettre en cache pour toute utilisation ultérieure (cross-session).
Sinon, est il possible de la transformer en objet zope et profiter de sa persistence naturelle ?
merci
Encolpe DEGOUTE

Re: global variable persistence in a python script (external method)

Reply Threaded More More options
Print post
Permalink
Bonjour,
>
> désolé, je me suis trompé de <<regional forum>>
>
> bonjour,
> Est-ce que les variables globales d'un script sont persistantes entre deux
> appels à une "external method" associée?

Non.

Cordialement,

--
Encolpe DEGOUTE
http://encolpe.degoute.free.fr/
Logiciels libres, hockey sur glace et autres activités cérébrales



_______________________________________________
Plone-FR mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/plone-fr