Re: urlconf, strings vs. callables

2007-07-11 Thread [EMAIL PROTECTED]
> Just an idea: decorators for strings could also be implemented. > > url(r'regex', 'project.app.views.myview', decorator=login_required) > > Pistahh -1 What happens when you need multiple stacked decorators? Decorators which require arguments (auth_required) which might be complex would mean mov

Re: urlconf, strings vs. callables

2007-07-11 Thread Szekeres Istvan
James Bennett wrote: > On the other hand, importing the functions and using them directly > opens up some interesting possibilities -- you can apply decorators > like 'login_required' to them right there in the URLConf, which adds > another layer of configurability that isn't possible when referen

Re: urlconf, strings vs. callables

2007-07-11 Thread Gábor Farkas
Malcolm Tredinnick wrote: > On Tue, 2007-07-10 at 09:20 +0200, Gábor Farkas wrote: >> hi, > >> i'm always using the "pythonic" way (import the view function, and give >> it to the urlconf), and assumed that this is the recommended way. >> >> but what always worried me is that you still have to e

Re: urlconf, strings vs. callables

2007-07-10 Thread Malcolm Tredinnick
On Tue, 2007-07-10 at 09:20 +0200, Gábor Farkas wrote: > hi, > > when specifying view-functions in the urlconfs, you can either specify > them by their name as a string, or by referencing them "pythonically" > (importing them, and giving the urlconf the callable). > > which is the "preferred"

Re: urlconf, strings vs. callables

2007-07-10 Thread Malcolm Tredinnick
On Tue, 2007-07-10 at 08:39 -0400, Sean Patrick Hogan wrote: > The "pythonic" way is a new addition to Django if I'm not mistaken. > > I personally prefer calling by string because (I'm assuming here) it > doesn't load the function unless it needs to. Bad assumption. The first time you access t

Re: urlconf, strings vs. callables

2007-07-10 Thread Chris Heisel
I'd also be interested in the memory usage of strings vs. importing the functions directly. At work, we tend to use the string method when it's an undecorated view function, and the pythonic way when we're going to decorate them: usually caching, but sometimes login_required, etc. The mixing and

Re: urlconf, strings vs. callables

2007-07-10 Thread Sean Patrick Hogan
That's a good question and one I don't know the answer to. But here's one thing to keep in mind. Let's say that introspectively looking up a function is 4x more costly. If I have 8 entries in my URLConf going to different functions, calling by string is 2x faster. Plus, there's the issue of mem

Re: urlconf, strings vs. callables

2007-07-10 Thread Collin Grady
On Jul 10, 6:20 am, Carl Karsten <[EMAIL PROTECTED]> wrote: > apply decorators? do tell... > > (sorry to turn this into a d-user post...) > > Ideally I would like to apply it to this whole tree: > > (r'^eventcal/', include('eventcal.urls')), You can apply it to specific views, not to an in

Re: urlconf, strings vs. callables

2007-07-10 Thread Kevin Menard
On 7/10/07, Sean Patrick Hogan <[EMAIL PROTECTED]> wrote: > The "pythonic" way is a new addition to Django if I'm not mistaken. > > I personally prefer calling by string because (I'm assuming here) it doesn't > load the function unless it needs to. So, if I have a URLConf that > references 8 view

Re: urlconf, strings vs. callables

2007-07-10 Thread Sean Patrick Hogan
Yeah, I've used the caching decorators in my URLConf for generic views that way. I think it's good to support both ways and I don't think either is going away, but someone more familiar with development should probably comment on that. Sean. On 7/10/07, James Bennett <[EMAIL PROTECTED]> wrote: >

Re: urlconf, strings vs. callables

2007-07-10 Thread Carl Karsten
James Bennett wrote: > On 7/10/07, Sean Patrick Hogan <[EMAIL PROTECTED]> wrote: >> The "pythonic" way is a new addition to Django if I'm not mistaken. > > Yes, it was added between the 0.95 and 0.96 releases. > >> I personally prefer calling by string because (I'm assuming here) it doesn't >> l

Re: urlconf, strings vs. callables

2007-07-10 Thread James Bennett
On 7/10/07, Sean Patrick Hogan <[EMAIL PROTECTED]> wrote: > The "pythonic" way is a new addition to Django if I'm not mistaken. Yes, it was added between the 0.95 and 0.96 releases. > I personally prefer calling by string because (I'm assuming here) it doesn't > load the function unless it needs

Re: urlconf, strings vs. callables

2007-07-10 Thread Sean Patrick Hogan
The "pythonic" way is a new addition to Django if I'm not mistaken. I personally prefer calling by string because (I'm assuming here) it doesn't load the function unless it needs to. So, if I have a URLConf that references 8 view functions, it only imports the one for the correct URL if I call by

urlconf, strings vs. callables

2007-07-10 Thread Gábor Farkas
hi, when specifying view-functions in the urlconfs, you can either specify them by their name as a string, or by referencing them "pythonically" (importing them, and giving the urlconf the callable). which is the "preferred" way? i'm always using the "pythonic" way (import the view function,