Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 8 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
25 README.rst
@@ -2,16 +2,24 @@
Django XML-RPC
==============
-django_xmlrpc offers a means by which a Django developer can expose their views (or indeed any other function) using XML-RPC.
+**Django_xmlrpc** offers a means by which a Django developer can expose their
+views (or indeed any other function) using XML-RPC.
-This is a fork of the version hosted at : https://code.launchpad.net/~aartemenko/django-xmlrpc/svetlyak40wt compatible with Django > 1.1.
+This is a fork of the version hosted at :
+https://code.launchpad.net/~aartemenko/django-xmlrpc/svetlyak40wt
+compatible with Django >= 1.4 and Python >= 2.5.
+
+If you want to use **django_xmlrpc** for an older version of Django or Python,
+please use an old release.
.. contents::
Installation
============
-You could retrieve the last sources from http://github.com/Fantomas42/django-xmlrpc and run the installation script ::
+You could retrieve the last sources from
+http://github.com/Fantomas42/django-xmlrpc and run the installation script
+::
$> python setup.py install
@@ -22,15 +30,16 @@ or use pip ::
Usage
=====
-Register **django_xmlrpc** in your INSTALLED_APPS section of your project' settings.
+Register **django_xmlrpc** in your INSTALLED_APPS section of your project'
+settings.
-Then register methods you want to handle like this in your project' settings. ::
+Then register methods you want to handle like this in your project'
+settings. ::
>>> XMLRPC_METHODS = (('path.to.your.method', 'Method name'),
... ('path.to.your.othermethod', 'Other Method name'),)
-Finally we need to register the url of the XML-RPC server.
-Insert something like this in your project's urls.py: ::
+Finally we need to register the url of the XML-RPC server. Insert something
+like this in your project's urls.py: ::
>>> url(r'^xmlrpc/$', 'django_xmlrpc.views.handle_xmlrpc', name='xmlrpc'),
-
View
2  django_xmlrpc/__init__.py
@@ -40,5 +40,3 @@
"""
VERSION = (0, 1, 5)
__version__ = '.'.join(map(str, VERSION))
-
-from django_xmlrpc.views import xmlrpcdispatcher
View
8 django_xmlrpc/decorators.py
@@ -60,7 +60,7 @@ class AuthenticationFailedException(Fault):
"""
def __init__(self):
Fault.__init__(self, AUTHENTICATION_FAILED_CODE,
- _('Username and/or password is incorrect'))
+ _('Username and/or password is incorrect'))
class PermissionDeniedException(Fault):
@@ -99,7 +99,7 @@ def _xmlrpc_func(func):
func._xmlrpc_signature = {
'returns': returns,
'args': args
- }
+ }
return func
return _xmlrpc_func
@@ -165,8 +165,8 @@ def __authenticated_call(username, password, *args):
__authenticated_call.__doc__ = func.__doc__ + \
"\nNote: Authentication is required."""
if perm:
- __authenticated_call.__doc__ += ' this function requires ' \
- + '"%s" permission.' % perm
+ __authenticated_call.__doc__ += (' this function requires '
+ '"%s" permission.' % perm)
return __authenticated_call
View
8 django_xmlrpc/dispatcher.py
@@ -44,12 +44,6 @@
except ImportError: # Python 2
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
-from django.conf import settings
-
-
-# If we need to debug, now we know
-DEBUG = hasattr(settings, 'XMLRPC_DEBUG') and settings.XMLRPC_DEBUG
-
class DjangoXMLRPCDispatcher(SimpleXMLRPCDispatcher):
"""A simple XML-RPC dispatcher for Django.
@@ -76,6 +70,6 @@ def system_methodSignature(self, method):
sig = {
'returns': 'string',
'args': ['string' for arg in getargspec(func)[0]],
- }
+ }
return [sig['returns']] + sig['args']
View
63 django_xmlrpc/views.py
@@ -39,39 +39,23 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
-import sys
+from logging import getLogger
from collections import Callable
-import django
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.core.exceptions import ImproperlyConfigured
-from django.http import HttpResponse, HttpResponseServerError
+from django.http import HttpResponse
+from django.http import HttpResponseServerError
+from django.views.decorators.csrf import csrf_exempt
-try:
- from django.views.decorators.csrf import csrf_exempt
-except ImportError:
- from django.contrib.csrf.middleware import csrf_exempt
-
-from django_xmlrpc.dispatcher import DjangoXMLRPCDispatcher
from django_xmlrpc.decorators import xmlrpc_func
+from django_xmlrpc.dispatcher import DjangoXMLRPCDispatcher
-# We create a local DEBUG variable from the data in settings.
-DEBUG = hasattr(settings, 'XMLRPC_DEBUG') and settings.XMLRPC_DEBUG
-
-# Declare xmlrpcdispatcher correctly depending on our python version
-if sys.version_info[:3] >= (2, 5,):
- xmlrpcdispatcher = DjangoXMLRPCDispatcher(allow_none=False, encoding=None)
-else:
- xmlrpcdispatcher = DjangoXMLRPCDispatcher()
-
-
-def request_datas(request):
- if django.VERSION[1] > 3:
- return request.body
- return request.raw_post_data
+logger = getLogger('xmlrpc')
+xmlrpcdispatcher = DjangoXMLRPCDispatcher(allow_none=False, encoding=None)
@xmlrpc_func(returns='string', args=['string'])
@@ -89,14 +73,12 @@ def handle_xmlrpc(request):
GET request, nothing will happen (we only accept POST requests)
"""
if request.method == "POST":
- if DEBUG:
- print(request_datas(request))
+ logger.info(request.body)
try:
response = HttpResponse(content_type='text/xml')
response.write(
- xmlrpcdispatcher._marshaled_dispatch(request_datas(request)))
- if DEBUG:
- print(response)
+ xmlrpcdispatcher._marshaled_dispatch(request.body))
+ logger.debug(response)
return response
except:
return HttpResponseServerError()
@@ -116,15 +98,7 @@ def handle_xmlrpc(request):
method_list.append((method, sig, method_help))
- if hasattr(settings, 'XMLRPC_GET_TEMPLATE'):
- # This behaviour is deprecated
- if settings.DEBUG:
- print("Use of settings.XMLRPC_GET_TEMPLATE is deprecated " \
- + "Please update your code to use django_xmlrpc/templates")
- template = settings.XMLRPC_GET_TEMPLATE
- else:
- template = 'xmlrpc_get.html'
- return render_to_response(template, {'methods': method_list},
+ return render_to_response('xmlrpc_get.html', {'methods': method_list},
context_instance=RequestContext(request))
@@ -143,18 +117,21 @@ def handle_xmlrpc(request):
try:
mod = __import__(module, globals(), locals(), [attr])
except ImportError as ex:
- raise ImproperlyConfigured("Error registering XML-RPC method: " \
- + "module %s can't be imported" % module)
+ raise ImproperlyConfigured(
+ "Error registering XML-RPC method: "
+ "module %s can't be imported" % module)
try:
func = getattr(mod, attr)
except AttributeError:
- raise ImproperlyConfigured('Error registering XML-RPC method: ' \
- + 'module %s doesn\'t define a method "%s"' % (module, attr))
+ raise ImproperlyConfigured(
+ 'Error registering XML-RPC method: '
+ 'module %s doesn\'t define a method "%s"' % (module, attr))
if not isinstance(func, Callable):
- raise ImproperlyConfigured('Error registering XML-RPC method: ' \
- + '"%s" is not callable in module %s' % (attr, module))
+ raise ImproperlyConfigured(
+ 'Error registering XML-RPC method: '
+ '"%s" is not callable in module %s' % (attr, module))
xmlrpcdispatcher.register_function(func, name)
View
31 setup.py
@@ -2,31 +2,34 @@
from setuptools import setup
from setuptools import find_packages
-setup(name = 'django-xmlrpc',
- version = '0.1.5',
+import django_xmlrpc
- description = 'XML-RPC Server App for the Django framework.',
+
+setup(name='django-xmlrpc',
+ version=django_xmlrpc.__version__,
+
+ description='XML-RPC Server App for the Django framework.',
long_description=open(os.path.join('README.rst')).read(),
- keywords = 'django, service, xmlrpc',
+ keywords='django, service, xmlrpc',
- author = 'Graham Binns',
- author_email = 'graham.binns@gmail.com',
- maintainer = 'Fantomas42',
- maintainer_email = 'fantomas42@gmail.com',
- url = 'http://github.com/Fantomas42/django-xmlrpc',
+ author='Graham Binns',
+ author_email='graham.binns@gmail.com',
+ maintainer='Fantomas42',
+ maintainer_email='fantomas42@gmail.com',
+ url='https://github.com/Fantomas42/django-xmlrpc',
- packages = find_packages(),
+ packages=find_packages(),
classifiers=[
'Framework :: Django',
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Programming Language :: Python',
+ 'Programming Language :: Python 3',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
- 'Topic :: Software Development :: Libraries :: Python Modules',],
+ 'Topic :: Software Development :: Libraries :: Python Modules'],
- license = 'New BSD License',
- include_package_data = True,
+ license='New BSD License',
+ include_package_data=True,
zip_safe=False
)
-

No commit comments for this range

Something went wrong with that request. Please try again.