On Tue, Apr 08, 2008 at 09:26:16AM -0700, dave wrote:
> 1. My controller index function sets some class variables. (eg.
> self.myvar )
> 2. It then renders a template.
> 3. The template html loads some javascript in the standard html way
> ( eg. <script type="text/javascript" src="my javascript.js"></
> script> )
> 4. The page is loaded and all is happy.
> 5. On a certain action, the javascript get's called and I'd like to
> point back to my controller object.. calling a different function.
> But it seems that it creates a new instance of the class because the
> 'self.myvar' no longer exists.
>
> .
> Any help greatly appreciated.
> Here's a bit different way of explaining it
>
> class WbController(BaseController):
> def index(self):
> # get some info from the urlr
> self.myvar = "some info here"
> # pass that info to the template.
> return render('/foo.mako')
>
> def foo(self):
> # foo get's called by the javascript that is loaded in the
> template..
> # but self.myvar doesn't exist !!!??
Your class variables are not saved between HTTP requests. If you want
data to persist you either need to save it in into a database (hint:
model) or into the session (cookie based session).
Cheers
Christoph
--
[EMAIL PROTECTED] www.workaround.org JID: [EMAIL PROTECTED]
gpg key: 79CC6586 fingerprint: 9B26F48E6F2B0A3F7E33E6B7095E77C579CC6586
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---