TurboGears /.-ed, >new == True< or >new == "True"<

F

Fredrik Lundh

Andy said:
watch this:
http://www.turbogears.org.nyud.net:8090/docs/wiki20/20MinuteWiki.mov

or read this:
http://www.turbogears.org.nyud.net:8090/docs/wiki2 0/page4.html

should not it be:

2 def save(self, pagename, data, submit, new):
3 hub.begin()
4 if new == True:
5 page = Page(pagename=pagename, data=data)
6 else:
7 page = Page.byPagename(pagename)
8 page.data = data

instead of:

4 if new == "True":

from page 5:

http://www.turbogears.org.nyud.net:8090/docs/wiki20/page5.html

Converting incoming arguments

Something that's a little ugly in that save method is the
'if new == "True"'. Wouldn't it be nicer to just use the
more pythonic 'if new'? Piece of cake... we just need to
use a validator. /.../

</F>
 
S

Sybren Stuvel

Andy Leszczynski enlightened us with:
should not it be:

2 def save(self, pagename, data, submit, new):
3 hub.begin()
4 if new == True:
5 page = Page(pagename=pagename, data=data)
6 else:
7 page = Page.byPagename(pagename)
8 page.data = data

instead of:

4 if new == "True":

No it should not. The values passed to the function are the strings
passed by the GET request, hence all strings. There are methods of
dealing with this - read the rest of the documentation.

Sybren
 
A

Andy Leszczynski

Sybren said:
Andy Leszczynski enlightened us with:



No it should not. The values passed to the function are the strings
passed by the GET request, hence all strings. There are methods of
dealing with this - read the rest of the documentation.

Sybren

So how does it correspond to other piece of the code:

2 def notfound(self, pagename):
3 return dict(pagename=pagename, data="", new=True)

new is a boolean here?

A.
 
E

Erik Max Francis

Andy said:
So how does it correspond to other piece of the code:

2 def notfound(self, pagename):
3 return dict(pagename=pagename, data="", new=True)

new is a boolean here?

It comes through as a CGI query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top