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

Discussion in 'Python' started by Andy Leszczynski, Oct 12, 2005.

  1. Andy Leszczynski, Oct 12, 2005
    #1
    1. Advertising

  2. Andy Leszczynski wrote:

    > 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>
     
    Fredrik Lundh, Oct 12, 2005
    #2
    1. Advertising

  3. 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
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
    Frank Zappa
     
    Sybren Stuvel, Oct 12, 2005
    #3
  4. Sybren Stuvel wrote:
    > 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


    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.
     
    Andy Leszczynski, Oct 13, 2005
    #4
  5. Andy Leszczynski wrote:

    > 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.

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
    Men and women, women and men. It will never work.
    -- Erica Jong
     
    Erik Max Francis, Oct 13, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    383
    Yu-Xi Lim
    Mar 28, 2006
  2. Replies:
    43
    Views:
    1,023
    paron
    Sep 1, 2006
  3. rick

    turbogears app deployment

    rick, Dec 24, 2006, in forum: Python
    Replies:
    0
    Views:
    340
  4. Silas Snider
    Replies:
    5
    Views:
    517
  5. bdb112
    Replies:
    45
    Views:
    1,348
    jazbees
    Apr 29, 2009
Loading...

Share This Page