#1389: tg_error mangling *arg and **kw
--------------------------------+-------------------------------------------
 Reporter:  ldng                |        Owner:  chrisz      
     Type:  defect              |       Status:  closed      
 Priority:  normal              |    Milestone:  1.0.x bugfix
Component:  TurboGears          |      Version:  1.0.2       
 Severity:  normal              |   Resolution:  invalid     
 Keywords:  needs confirmation  |  
--------------------------------+-------------------------------------------
Changes (by chrisz):

  * status:  new => closed
  * resolution:  => invalid

Comment:

 I don't think this is a bug, but a misunderstanding of how Python `*args`
 work. If you define your method with
 {{{
 def create(self, tg_error=None, *args, **kw)
 }}}
 and then call `/create/45`, this is translated to `create(45)` and this
 will result in `tg_error=45` and `args=[]`. You probably thought that args
 should be `[45]` but this is not the way how it works. To solve this,
 define your method like this:
 {{{
 def create(self, id=None, tg_error=None)
 }}}
 And then instead of checking for `len(args)==1` and using `args[0]`, check
 for `id is not None` and then use `id`.

-- 
Ticket URL: <http://trac.turbogears.org/ticket/1389#comment:7>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to