Coder Social home page Coder Social logo

django-xmlrpc's Introduction

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.

This is a fork of the original version made by Svetlyak40wt compatible with Django >= 1.8 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

You could retrieve the last sources from http://github.com/Fantomas42/django-xmlrpc and run the installation script

$ python setup.py install

or use pip

$ pip install -e git://github.com/Fantomas42/django-xmlrpc.git#egg=django-xmlrpc

Register django_xmlrpc in your INSTALLED_APPS section of your project' settings.

There are two ways to register methods that you want to handle:

In your project's settings.

XMLRPC_METHODS = (('path.to.your.method', 'Method name'),
                  ('path.to.your.othermethod', 'Other Method name'),)

In a file called xmlrpc.py in your application directory.

XMLRPC_METHODS = (('path.to.your.method', 'Method name'),
                  ('path.to.your.othermethod', 'Other Method name'),)

A registered method should look like this:

from django_xmlrpc.decorators import xmlrpc_func

@xmlrpc_func(returns='string', args=['string'])
def test_xmlrpc(text):
    """Simply returns the args passed to it as a string"""
    return "Here's a response! %s" % str(text)

Finally we need to register the url of the XML-RPC server. Insert something like this in your project's urls.py:

from django_xmlrpc.views import handle_xmlrpc

url(r'^xmlrpc/$', handle_xmlrpc, name='xmlrpc'),

django-xmlrpc's People

Contributors

fantomas42 avatar rubeon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-xmlrpc's Issues

Package is not installable due to missing README.rst

Your setup.py includes:

long_description=open(os.path.join('README.rst')).read(),

which is fine, except the README.rst file needs to be in your MANIFEST.in file. The current package fails on install with:

IOError: [Errno 2] No such file or directory: 'README.rst'

Copyright status for code?

Thank you very much for this useful piece of code. I notice from setup.py the license is set to MIT, but there is no license text included in the repository and no copyright header in the code files themselves. Would you be willing to add such headers and the exact license text assigned to this piece of code?

views.handle_xmlrpc: TypeError: context must be a dict rather than RequestContext

I hit this error when trying to use django-xmlrpc on Django 1.11.2:

Internal Server Error: /xmlrpc/
Traceback (most recent call last):
  File "/path/to/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/path/to/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/path/to/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/path/to/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/path/to/lib/python2.7/site-packages/django_xmlrpc/views.py", line 99, in handle_xmlrpc
    RequestContext(request, {'methods': method_list}))
  File "/path/to/lib/python2.7/site-packages/django/shortcuts.py", line 21, in render_to_response
    content = loader.render_to_string(template_name, context, using=using)
  File "/path/to/lib/python2.7/site-packages/django/template/loader.py", line 68, in render_to_string
    return template.render(context, request)
  File "/path/to/lib/python2.7/site-packages/django/template/backends/django.py", line 64, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "/path/to/lib/python2.7/site-packages/django/template/context.py", line 287, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than RequestContext.

According to the Django docs, the context argument of django.template.loader.render_to_string() (and, by extension, django.shortcuts.render_to_response) should be a dict.

I'm preparing a PR now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.