Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #205 (closed enhancement: fixed)

Opened 13 years ago

Last modified 12 years ago

Allow conditional parameters in std.url with None

Reported by: exogen@… Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TurboGears Version: 0.8
Severity: minor Keywords:
Cc:

Description

It would be nice if parameters given to std.url with a value of None were excluded from the generated address. Right now conditionally including parameters in the keyword arguments or dictionary takes more code than it needs to.

Attachments

std.url.diff Download (263 bytes) - added by Simon Belak <simon.belak@…> 13 years ago.
Changed list comprehension in url() to filter None values.

Change History

Changed 13 years ago by Simon Belak <simon.belak@…>

Changed list comprehension in url() to filter None values.

comment:1 Changed 13 years ago by kevin

unfortunately, since TurboGears 0.9 is Python 2.3 compatible, we can't use generator expressions, so that patch won't work. we can just do the same thing the "old fashioned way".

comment:2 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

done in [397]

comment:3 Changed 13 years ago by Luca <luca@…>

Python 2.3 support list comprehension, so you can do:

args = ["%s=%s" % (key, urllib.quote(str(value)))
        for key, value in tgparams.items() if value is not None]

without problems...

Note: See TracTickets for help on using tickets.