Thanks a lot! It works now.

On Jan 23, 4:37 am, Jason Brower <[email protected]> wrote:
> Ok here is what I see as the problem.
> What you are doing is setting variable as 0 every time you start a webpage.
> Every time you start a webpage this entire file is look over as if it
> was never seen before. Doing so is a great thing but you have to take
> the approch differently knowing this.
> For example here...
> variable = 0
> session.variable = variable
> this resets it to 0 at every load.
> What you should do is something like this because you have data that
> needs to be checked first...
> if not session.variable:
>      session.variable = 0
>
> This then checks if you have any data there (if it doesn't it returns None)
> Place that at the beginning of your file where you have variable = 0 and
> see if that is more of what you expected.
> ---
> Best Regards,
> Jason Brower
>
> On 01/23/2011 05:15 AM, Rick wrote:
>
>
>
>
>
>
>
> > Here is some code from the controller file:
> > ************************
> > variable = 0
>
> > def index()
> >    some operations with the variable...
>
> > def minorvar():
> >          variable-=1
> >          redirect(URL('index'))
> > ************************
> > I also tried with this code, but the variable isn't changed after
> > redirecting it to the index-function:
> > ************************
> > variable = 0
> > session. variable = variable
>
> > def index()
> >         variable=session. variable
> >    some operations with the variable...
>
> > def minorvar():
> >          session.variable-=1
> >          redirect(URL('index'))
> > ************************
>
> > On Jan 23, 3:13 am, Jason Brower<[email protected]>  wrote:
> >> I would recommend that you use session.variable if that's what you want
> >> to do.
> >> Could we see the controller for the page before?  I wonder if there is a
> >> way we could put the action in there to make your code a bit cleaner.
> >> BR,
> >> JB
>
> >> On 01/23/2011 01:04 AM, Rick wrote:
>
> >>> Thanks for the replies. I wrote a special def for the operation:
> >>> def minorvar():
> >>>     variable-=1
> >>>     redirect(URL('index'))
> >>> ...but I get an error that says that:
> >>> local variable 'variable' referenced before assignment
> >>> ...even though I've defined the variable as global at the beginning of
> >>> the controller file.
> >>> On Jan 22, 9:19 pm, Jason Brower<[email protected]>    wrote:
> >>>> Yup... I think you should do that in the controller before you pass it.
> >>>> It's a two second job so not hard to do.
> >>>> That and session.variable=-1 is well... -1 it should be variable-=1.
> >>>> On the other had, you may be going for -1 :P and you may be using a
> >>>> special loop or something that needs to change as the page is formated.  
> >>>> Always exceptions when you have to print from the top down and build the
> >>>> page before sending it to the client. :D
> >>>> BR,
> >>>> Jason
> >>>> On 01/22/2011 02:53 PM, b0j3 wrote:
> >>>>> On 22 jan., 11:47, Rick<[email protected]>      wrote:
> >>>>>> Hi,
> >>>>>> My problem is that I want to make a {{=A...}} tag that also changes
> >>>>>> the value of the variable session.variable, and I don't know how to do
> >>>>>> this. I tried with:
> >>>>>> {{=A(("[<      ]"), session.variable=-1,  _href=URL('function'))}}
> >>>>>> ...but it didn't work.
> >>>>> Hi.
> >>>>> I'm not sure if that is a good way to program. Some would say, that
> >>>>> you shouldn't change variable in the view so I don't think (I might be
> >>>>> wrong, though), that it could work like that.
> >>>>> What would you like to achieve?
> >>>>> B.

Reply via email to