The problem is that global works but only within a single request.
Global variables are not persistent between one http request and
another. The mechanism to keep variable presistent is sessions:
def func1():
session.a=request.vars.id1
def func2():
print session.a
On Jun 24, 7:54 am, ilovesss2004 <[email protected]> wrote:
> Hi,
> I try to use global variable in a controller.
>
> global a
> a=5
>
> def index():
> return dict()
>
> def func1():
> global a
> a=request.vars.id1
>
> def func2():
> global a
> print a
>
> The html page call func1 first and change the value of the global
> variable "a" to 8. But when html page call func2 afterwards, the value
> of the global variable "a" printed out is still 5.
>
> Can anyone tell me why this happens and how to make variable in a
> controller global?
>
> Thanks alot.