File modulename.patch of Package python-django-json-rpc

Index: django-json-rpc-0.1/README
===================================================================
--- django-json-rpc-0.1.orig/README	2009-08-20 11:39:07.000000000 -0300
+++ django-json-rpc-0.1/README	2009-08-20 14:58:14.000000000 -0300
@@ -10,7 +10,7 @@ The basic API:
 
   ### myproj/myapp/views.py
   
-  from jsonrpc import jsonrpc_method
+  from django_json_rpc import jsonrpc_method
   
   @jsonrpc_method('myapp.sayHello')
   def whats_the_time(request, name='Lester'):
@@ -23,7 +23,7 @@ The basic API:
   
   ### myproj/urls.py
   
-  from jsonrpc import jsonrpc_site
+  from django_json_rpc import jsonrpc_site
   import myproj.myapp.views # you must import the views that need connected
   
   urls += patterns('', (r'^json/', jsonrpc_site.dispatch))
@@ -31,7 +31,7 @@ The basic API:
 
 To test your service:
   
-  >>> from jsonrpc.proxy import ServiceProxy
+  >>> from django_json_rpc.proxy import ServiceProxy
   
   >>> s = ServiceProxy('http://localhost:8080/json/')
   
Index: django-json-rpc-0.1/django_json_rpc/__init__.py
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ django-json-rpc-0.1/django_json_rpc/__init__.py	2009-08-20 14:58:39.000000000 -0300
@@ -0,0 +1,28 @@
+from functools import wraps
+from django_json_rpc.site import jsonrpc_site
+
+def jsonrpc_method(name, authenticated=False):
+  def decorator(func):
+    func.json_method = name
+    if authenticated:
+      from django.contrib.auth.models import User, check_password
+      @wraps(func)
+      def _func(request, *args, **kwargs):
+        try:
+          creds = args[:2]
+          user = User.objects.get(username=args[0])
+          if not check_password(args[1], user.password):
+            raise Exception('JSON-RPC: invalid login credentials')
+        except IndexError:
+          raise Exception('JSON-RPC: authenticated methods require '
+                          'at least [username, password] arguments')
+        except User.DoesNotExist:
+          raise Exception('JSON-RPC: username not found')
+        else:
+          request.user = user
+          return func(request, *args[2:], **kwargs)
+    else:
+      _func = func
+    jsonrpc_site.register(name, _func)
+    return _func
+  return decorator
\ No newline at end of file
Index: django-json-rpc-0.1/django_json_rpc/proxy.py
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ django-json-rpc-0.1/django_json_rpc/proxy.py	2009-08-20 14:58:14.000000000 -0300
@@ -0,0 +1,19 @@
+import urllib
+from json import dumps, loads
+        
+class ServiceProxy(object):
+  def __init__(self, service_url, service_name=None):
+    self.__service_url = service_url
+    self.__service_name = service_name
+
+  def __getattr__(self, name):
+    if self.__service_name != None:
+      name = "%s.%s" % (self.__service_name, name)
+    return ServiceProxy(self.__service_url, name)
+
+  def __call__(self, *args):
+    return loads(urllib.urlopen(self.__service_url,
+                                dumps({
+                                  "method": self.__service_name,
+                                  'params': args,
+                                  'id': 'jsonrpc'})).read())
\ No newline at end of file
Index: django-json-rpc-0.1/django_json_rpc/site.py
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ django-json-rpc-0.1/django_json_rpc/site.py	2009-08-20 14:58:14.000000000 -0300
@@ -0,0 +1,60 @@
+import sys
+import traceback
+from types import NoneType
+from django.http import HttpResponse
+try:
+  import json
+except (ImportError, NameError):
+  from django.utils import simplejson as json
+
+class JSONRPCSite(object):
+  def __init__(self):
+    self.urls = {}
+  
+  @property
+  def root(self):
+    return [(r'^json/%s/' % k, v) for k, v in self.urls.iteritems()]
+  
+  def register(self, name, method):
+    print name, method
+    self.urls[unicode(name)] = method
+  
+  def dispatch(self, request):
+    response = {'error': None, 'result': None}
+    try:
+      if not request.method.lower() == 'post':
+        raise Exception('JSON-RPC: requests most be POST')
+      try:
+        D = json.loads(request.raw_post_data)
+        print D, self.urls
+      except:
+        raise Exception('JSON-RPC: request poorly formed JSON')
+      if 'method' not in D or 'params' not in D:
+        raise Exception('JSON-RPC: request requires str:"method" and list:"params"')
+      if D['method'] not in self.urls:
+        raise Exception('JSON-RPC: method not found. Available methods: %s' % (
+                        '\n'.join(self.urls.keys())))
+      
+      R = self.urls[str(D['method'])](request, *list(D['params']))
+      
+      assert sum(map(lambda e: isinstance(R, e), 
+        (dict, str, unicode, int, long, list, set, NoneType, bool))), \
+        "Return type not supported"
+      
+      response['result'] = R
+      response['id'] = D['id'] if 'id' in D else None
+      
+    except KeyboardInterrupt:
+      raise
+    except Exception, e:
+      error = {
+        'name': str(e.__class__.__name__), #str(sys.exc_info()[0]),
+        'message': str(e),
+        'stack': traceback.format_exc(),
+        'executable': sys.executable}
+      response['error'] = error
+      
+    return HttpResponse(json.dumps(response), content_type='application/javascript')
+
+
+jsonrpc_site = JSONRPCSite()
Index: django-json-rpc-0.1/jsonrpc/__init__.py
===================================================================
--- django-json-rpc-0.1.orig/jsonrpc/__init__.py	2009-08-20 11:39:07.000000000 -0300
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,28 +0,0 @@
-from functools import wraps
-from jsonrpc.site import jsonrpc_site
-
-def jsonrpc_method(name, authenticated=False):
-  def decorator(func):
-    func.json_method = name
-    if authenticated:
-      from django.contrib.auth.models import User, check_password
-      @wraps(func)
-      def _func(request, *args, **kwargs):
-        try:
-          creds = args[:2]
-          user = User.objects.get(username=args[0])
-          if not check_password(args[1], user.password):
-            raise Exception('JSON-RPC: invalid login credentials')
-        except IndexError:
-          raise Exception('JSON-RPC: authenticated methods require '
-                          'at least [username, password] arguments')
-        except User.DoesNotExist:
-          raise Exception('JSON-RPC: username not found')
-        else:
-          request.user = user
-          return func(request, *args[2:], **kwargs)
-    else:
-      _func = func
-    jsonrpc_site.register(name, _func)
-    return _func
-  return decorator
\ No newline at end of file
Index: django-json-rpc-0.1/jsonrpc/proxy.py
===================================================================
--- django-json-rpc-0.1.orig/jsonrpc/proxy.py	2009-08-20 11:39:07.000000000 -0300
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-import urllib
-from json import dumps, loads
-        
-class ServiceProxy(object):
-  def __init__(self, service_url, service_name=None):
-    self.__service_url = service_url
-    self.__service_name = service_name
-
-  def __getattr__(self, name):
-    if self.__service_name != None:
-      name = "%s.%s" % (self.__service_name, name)
-    return ServiceProxy(self.__service_url, name)
-
-  def __call__(self, *args):
-    return loads(urllib.urlopen(self.__service_url,
-                                dumps({
-                                  "method": self.__service_name,
-                                  'params': args,
-                                  'id': 'jsonrpc'})).read())
\ No newline at end of file
Index: django-json-rpc-0.1/jsonrpc/site.py
===================================================================
--- django-json-rpc-0.1.orig/jsonrpc/site.py	2009-08-20 11:39:07.000000000 -0300
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-import sys
-import traceback
-from types import NoneType
-from django.http import HttpResponse
-try:
-  import json
-except (ImportError, NameError):
-  from django.utils import simplejson as json
-
-class JSONRPCSite(object):
-  def __init__(self):
-    self.urls = {}
-  
-  @property
-  def root(self):
-    return [(r'^json/%s/' % k, v) for k, v in self.urls.iteritems()]
-  
-  def register(self, name, method):
-    print name, method
-    self.urls[unicode(name)] = method
-  
-  def dispatch(self, request):
-    response = {'error': None, 'result': None}
-    try:
-      if not request.method.lower() == 'post':
-        raise Exception('JSON-RPC: requests most be POST')
-      try:
-        D = json.loads(request.raw_post_data)
-        print D, self.urls
-      except:
-        raise Exception('JSON-RPC: request poorly formed JSON')
-      if 'method' not in D or 'params' not in D:
-        raise Exception('JSON-RPC: request requires str:"method" and list:"params"')
-      if D['method'] not in self.urls:
-        raise Exception('JSON-RPC: method not found. Available methods: %s' % (
-                        '\n'.join(self.urls.keys())))
-      
-      R = self.urls[str(D['method'])](request, *list(D['params']))
-      
-      assert sum(map(lambda e: isinstance(R, e), 
-        (dict, str, unicode, int, long, list, set, NoneType, bool))), \
-        "Return type not supported"
-      
-      response['result'] = R
-      response['id'] = D['id'] if 'id' in D else None
-      
-    except KeyboardInterrupt:
-      raise
-    except Exception, e:
-      error = {
-        'name': str(e.__class__.__name__), #str(sys.exc_info()[0]),
-        'message': str(e),
-        'stack': traceback.format_exc(),
-        'executable': sys.executable}
-      response['error'] = error
-      
-    return HttpResponse(json.dumps(response), content_type='application/javascript')
-
-
-jsonrpc_site = JSONRPCSite()
Index: django-json-rpc-0.1/setup.py
===================================================================
--- django-json-rpc-0.1.orig/setup.py	2009-08-20 11:39:07.000000000 -0300
+++ django-json-rpc-0.1/setup.py	2009-08-20 14:58:14.000000000 -0300
@@ -22,4 +22,4 @@ setup(
     'Operating System :: OS Independent',
     'Programming Language :: Python',
     'Topic :: Software Development :: Libraries :: Python Modules'],
-  packages=['jsonrpc'])
\ No newline at end of file
+  packages=['django_json_rpc'])
\ No newline at end of file
openSUSE Build Service is sponsored by