default and lookup methods in TG 2

9 views
Skip to first unread message

Christoph Zwerschke

unread,
Sep 19, 2010, 6:13:04 AM9/19/10
to tg-trunk
After updating one of my apps to the latest TG2.1 dev version, I was
surprised to see deprecations warnings for every call of default()
controller methods.

It seems default() and lookup() have been renamed to _default()
and _lookup().

Why has this been changed? Is there any good reason for that?

Why was this change not been discussed or disclosed on the mailing list?
And why have the docs not been updated?

* the docs still talk about default() nearly everywhere:
http://turbogears.org/2.1/docs/main/Controllers.html
http://turbogears.org/2.1/docs/main/explorequickstart.html
http://turbogears.org/2.1/docs/main/TGControllers.html
(in the second section it's _default() suddenly),
also the wiki20 tutorial in the text and code snippets
* some tests still use default() and lookup()
* even the TGController still has default() and lookup()
in its docstring

This really needs to be fixed before the TG 2.1 release.

-- Christoph

Christoph Zwerschke

unread,
Sep 23, 2010, 7:35:56 AM9/23/10
to TurboGears Trunk
> It seems default() and lookup() have been renamed to _default()
> and _lookup().

Since there was no response so far, I created http://trac.turbogears.org/ticket/2502
from this - maybe you can resolve that during the sprint this weekend.
Unfortunately, I cannot participate due to a family celebration, but
it's good to see TG2 moving forward.

I'm not against changing things, but changes must be accompanied by
proper documentation and tests, and we have this group to communicate
and discuss all larger changes, or API changes.

-- Christoph

Rick Copeland

unread,
Sep 23, 2010, 9:02:01 AM9/23/10
to turbogea...@googlegroups.com
Sorry about the slow response; this was a feature put in in response
to a requirement from sourceforge. The problem was that we were using
lookup() to dispatch on project name, but the project name was in this
case "lookup." It was believed that _default and _lookup would be
less likely to conflict with parts of the path that you actually might
*want*, so those were changed. Hope that helps explain the reasoning
behind this.

-Rick

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

Mark Ramm

unread,
Sep 23, 2010, 10:54:44 AM9/23/10
to turbogea...@googlegroups.com
There was quite a bit of discussion about this at the time, and we decided that it was probably not right to make it impossible (well difficult) to use lookup and default in your urls. 

On Thu, Sep 23, 2010 at 9:02 AM, Rick Copeland <ric...@usa.net> wrote:
Sorry about the slow response; this was a feature put in in response to a requirement from sourceforge.  The problem was that we were using lookup() to dispatch on project name, but the project name was in this case "lookup."  It was believed that _default and _lookup would be less likely to conflict with parts of the path that you actually might *want*, so those were changed.  Hope that helps explain the reasoning behind this.

-Rick


On Sep 23, 2010, at 7:35 AM, Christoph Zwerschke wrote:

It seems default() and lookup() have been renamed to _default()
and _lookup().

Since there was no response so far, I created http://trac.turbogears.org/ticket/2502
from this - maybe you can resolve that during the sprint this weekend.
Unfortunately, I cannot participate due to a family celebration, but
it's good to see TG2 moving forward.

I'm not against changing things, but changes must be accompanied by
proper documentation and tests, and we have this group to communicate
and discuss all larger changes, or API changes.

-- Christoph

--
You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group.
To post to this group, send email to turbogea...@googlegroups.com.

To unsubscribe from this group, send email to turbogears-tru...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en.

--
You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group.
To post to this group, send email to turbogea...@googlegroups.com.

To unsubscribe from this group, send email to turbogears-tru...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en.




--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

Christoph Zwerschke

unread,
Sep 23, 2010, 11:57:32 AM9/23/10
to turbogea...@googlegroups.com
Am 23.09.2010 16:54 schrieb Mark Ramm:
> There was quite a bit of discussion about this at the time, and we
> decided that it was probably not right to make it impossible (well
> difficult) to use lookup and default in your urls.

The default() convention was taken over from CherryPy (TG 1), but I
agree it makes sense to use underscore names for such magic methods to
avoid name conflicts.

My main point was that if we make such changes in the API, the
documentation must be updated accordingly, and it must be also mentioned
in the TG 2.0 -> 2.1 migration notes because it will break old apps. The
reasoning behind the changes should also be mentioned becasue it's so
much easier to accept changes when they are properly documented and you
understand the reasoning behind them.

The excuse "we will add the documentation later" is not a good one
because according to my experience this hardly ever happens, we stick
with outdated docs, and newbies get a bad experience when they try out
the tutorials in the next release. Please always try to keep the docs
and tests in sync with the code.

-- Christoph

Reply all
Reply to author
Forward
0 new messages