bug for controller methods with three optional parameters

View: New views
6 Messages — Rating Filter:   Alert me  

bug for controller methods with three optional parameters

by Robert Forkel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hi,
just found a bug in tg 2.1a2:
when a controller method has 3 optional parameters, like


    @expose('bug.templates.about')
    def about(self, arg1=None, arg2=None, arg3=None, **kwargs):
        """Handle the 'about' page."""
        return dict(page='about')

(in  a newly quickstarted project)
Dispatcher._remove_argspec_params_from_params throws an error. Below
is a patch for the problem. I think the required and optional
variables have not been computed correctly from argspec.

(tg2bug)robert@forkel02:~/projects/tg2bug/test
10:49:30$ diff -u ../../wals_tg2/lib/python2.5/site-packages/
TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py  ../lib/
python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/
dispatcher.py
--- ../../wals_tg2/lib/python2.5/site-packages/TurboGears2-2.1a2-
py2.5.egg/tg/controllers/dispatcher.py        2009-11-05
10:49:28.000000000 +0100
+++ ../lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/
controllers/dispatcher.py    2009-11-05 10:19:18.000000000 +0100
@@ -130,8 +130,8 @@
         required_vars = argvars
         optional_vars = []
         if argvals:
-            required_vars = argvars[:-len(argvals)]
-            optional_vars = argvars[-len(argvals):]
+            required_vars = argvars[:len(argvals)-1]
+            optional_vars = argvars[len(argvals)-1:]

         # make a copy of the params so that we don't modify the
existing one
         params=params.copy()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bug for controller methods with three optional parameters

by Robert Forkel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


sorry, got old and new file reversed in the patch. should have been:

10:57:56$ diff -u
../lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py
   ../../wals_tg2/lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py
--- ../lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py
   2009-11-05 10:19:18.000000000 +0100
+++ ../../wals_tg2/lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py
       2009-11-05 10:49:28.000000000 +0100
@@ -130,8 +130,8 @@
         required_vars = argvars
         optional_vars = []
         if argvals:
-            required_vars = argvars[:len(argvals)-1]
-            optional_vars = argvars[len(argvals)-1:]
+            required_vars = argvars[:-len(argvals)]
+            optional_vars = argvars[-len(argvals):]

         # make a copy of the params so that we don't modify the existing one
         params=params.copy()


On Thu, Nov 5, 2009 at 10:53 AM, Robert Forkel <xrotwang@...> wrote:

>
> hi,
> just found a bug in tg 2.1a2:
> when a controller method has 3 optional parameters, like
>
>
>    @expose('bug.templates.about')
>    def about(self, arg1=None, arg2=None, arg3=None, **kwargs):
>        """Handle the 'about' page."""
>        return dict(page='about')
>
> (in  a newly quickstarted project)
> Dispatcher._remove_argspec_params_from_params throws an error. Below
> is a patch for the problem. I think the required and optional
> variables have not been computed correctly from argspec.
>
> (tg2bug)robert@forkel02:~/projects/tg2bug/test
> 10:49:30$ diff -u ../../wals_tg2/lib/python2.5/site-packages/
> TurboGears2-2.1a2-py2.5.egg/tg/controllers/dispatcher.py  ../lib/
> python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/controllers/
> dispatcher.py
> --- ../../wals_tg2/lib/python2.5/site-packages/TurboGears2-2.1a2-
> py2.5.egg/tg/controllers/dispatcher.py        2009-11-05
> 10:49:28.000000000 +0100
> +++ ../lib/python2.5/site-packages/TurboGears2-2.1a2-py2.5.egg/tg/
> controllers/dispatcher.py    2009-11-05 10:19:18.000000000 +0100
> @@ -130,8 +130,8 @@
>         required_vars = argvars
>         optional_vars = []
>         if argvals:
> -            required_vars = argvars[:-len(argvals)]
> -            optional_vars = argvars[-len(argvals):]
> +            required_vars = argvars[:len(argvals)-1]
> +            optional_vars = argvars[len(argvals)-1:]
>
>         # make a copy of the params so that we don't modify the
> existing one
>         params=params.copy()
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bug for controller methods with three optional parameters

by Christoph Zwerschke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Robert Forkel schrieb:
> Below is a patch for the problem. I think the required and optional
> variables have not been computed correctly from argspec.

Thanks, but you should really enter such patches into our trac,
otherwise they get overlooked and lost too easily.

-- Christoph

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bug for controller methods with three optional parameters

by Robert Forkel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


done:
http://trac.turbogears.org/ticket/2401

On Thu, Nov 5, 2009 at 11:13 AM, Christoph Zwerschke <cito@...> wrote:

>
> Robert Forkel schrieb:
>> Below is a patch for the problem. I think the required and optional
>> variables have not been computed correctly from argspec.
>
> Thanks, but you should really enter such patches into our trac,
> otherwise they get overlooked and lost too easily.
>
> -- Christoph
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bug for controller methods with three optional parameters

by Pipoun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Nov 5, 11:38 am, Robert Forkel <xrotw...@...> wrote:
> done:http://trac.turbogears.org/ticket/2401

Is it the same issue than this ticket?
http://trac.turbogears.org/ticket/2398

>
> On Thu, Nov 5, 2009 at 11:13 AM, Christoph Zwerschke <c...@...> wrote:
>
> > Robert Forkel schrieb:
> >> Below is a patch for the problem. I think the required and optional
> >> variables have not been computed correctly from argspec.
>
> > Thanks, but you should really enter such patches into our trac,
> > otherwise they get overlooked and lost too easily.
>
> > -- Christoph
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bug for controller methods with three optional parameters

by Robert Forkel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


i've seen this ticket. could be the same issue. you might want to try my patch.

On Thu, Nov 5, 2009 at 12:08 PM, pipoun <pipoun@...> wrote:

>
>
> On Nov 5, 11:38 am, Robert Forkel <xrotw...@...> wrote:
>> done:http://trac.turbogears.org/ticket/2401
>
> Is it the same issue than this ticket?
> http://trac.turbogears.org/ticket/2398
>
>>
>> On Thu, Nov 5, 2009 at 11:13 AM, Christoph Zwerschke <c...@...> wrote:
>>
>> > Robert Forkel schrieb:
>> >> Below is a patch for the problem. I think the required and optional
>> >> variables have not been computed correctly from argspec.
>>
>> > Thanks, but you should really enter such patches into our trac,
>> > otherwise they get overlooked and lost too easily.
>>
>> > -- Christoph
>>
>>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---