Re: how do we get psp style tags working in cheetah
"R. Tyler Ballance" <[email protected]> Thu, 17 Dec 2009 14:29:52 -0800
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 17 Dec 2009, [email protected] wrote: > is there anyway to not do self.getVar('me') > and access as me > > as doing self.getVar kills the purpose of elegant psp style Short answer: no. Longer answer: nooooo (just kidding). The problem is the "searchList" is maintained in a separate member variable; to prevent name collisions elements in the searchList are *not* assigned as attributes of the template class itself. While I personally feel that there is no such thing as "elegant psp style" if you want the PSP block to look a bit cleaner, you could assign a local veriable "me" with self.getVar() and then work with it from there, i.e.: <% me = self.getVar('me') tmpsave = False if me.health<0: me.health = 10 tmpsave = True if me.bucks<=0: me.bucks=100 tmpsave = True if tmpsave:me.save() %> Hope that helps Cheers, -R. Tyler Ballance -------------------------------------- Jabber: [email protected] GitHub: http://github.com/rtyler Twitter: http://twitter.com/agentdero Blog: http://unethicalblogger.com > On Wed, Dec 16, 2009 at 4:37 PM, R. Tyler Ballance <[email protected]>wrote: > > > > > On Wed, 16 Dec 2009, [email protected] wrote: > > > > > *This doesnt work* > > > <% > > > tmpsave = False > > > if me.health<0: > > > me.health = 10 > > > tmpsave = True > > > if me.bucks<=0: > > > me.bucks=100 > > > tmpsave = True > > > if tmpsave:me.save() > > > > > > %> > > > > > > *error global variable me not found* > > > > I'm assuming "me" is coming from the searchList, in which case you'd likely > > want to use `self.getVar('me')` in your PSP block ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc
(application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAksqsN8ACgkQFCbH3D9R4W+aywCfWbBOyu8BdJXhpNrnmVq/90vw Pw4AoLJ5eX1gTvN3F+GUkBomZ4sQkQGw =f2S3 -----END PGP SIGNATURE-----