~jnaous/rpc4django/urlgroups

« back to all changes in this revision

Viewing changes to rpc4django/utils.py

  • Committer: Jad Naous
  • Date: 2010-11-20 07:43:51 UTC
  • Revision ID: jnaous@jadsm-20101120074351-u40j1micda55hzqd
Implement isolation across URLs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''
 
2
Created on Jun 9, 2010
 
3
 
 
4
@author: jnaous
 
5
'''
 
6
from django.conf.urls.defaults import url
 
7
 
 
8
def rpc_url(regex, kwargs=None, name=None, prefix='',
 
9
            use_name_for_dispatch=True):
 
10
    """
 
11
    Wrapper around C{django.conf.urls.defaults.url} to add the C{name} parameter
 
12
    to C{kwargs} as "url_name", and to automatically assign the C{view}.
 
13
    C{use_name_for_dispatch} controls whether or not to add C{name} to C{kwargs}
 
14
    """
 
15
    if name != None and use_name_for_dispatch:
 
16
        if kwargs == None:
 
17
            kwargs = {}
 
18
        kwargs["url_name"] = name
 
19
    view = "rpc4django.views.serve_rpc_request"
 
20
    return url(regex, view, kwargs, name, prefix)