On Sat, 2006-08-26 at 10:34 +0000, skink wrote:
> Hi,
> 
> I'm relatively new to django and maybe my question is stupid, but...
> 
> Is it possible to map in urls.py some url not to function in views.py
> (which has first argument with HttpRequest) but to some class methot?
> In that case each instance of such class would be created when session
> starts and for subsequnt calls would be served as self ?
> 
> I know, I know that HttpRequest has session member and I can use it.
> But maybe it would be good idea to have such url ==> class.method
> mapping.

Can you explain the use case for this a bit more?

I am wondering what you want to do that cannot be done by just creating
the class instance at import time and then calling the method (since you
can now put direct function and method references in URLConf calls). For
example,

        my_class = MyClass(...)
        
        urlpatterns = patterns('',
        ('foo/$', my_class.some_method),
    )

The ability to put function references (and not just strings) inside
patterns(...) is something that was only added recently (after 0.95), so
you will need to be running a recent subversion checkout to use this.

I'm not sure that creating the class instance at call time (instead of
import time) gains you a lot that you cannot do otherwise. But I'd be
interested to hear what I've overlooked.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to