From a774a07c2b38d0680e31bb59c97e328ecb7c7bb1 Mon Sep 17 00:00:00 2001 From: Fergal Walsh Date: Wed, 30 Oct 2013 23:16:35 +0200 Subject: [PATCH] Initial commit --- .gitignore | 6 ++++++ MANIFEST.in | 1 + README.md | 20 ++++++++++++++++++++ djpico/__init__.py | 9 +++++++++ djpico/urls.py | 7 +++++++ djpico/views.py | 21 +++++++++++++++++++++ setup.py | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100755 djpico/__init__.py create mode 100755 djpico/urls.py create mode 100755 djpico/views.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1276bf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +*.pyc +.DS_Store +MANIFEST + +dist/* diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..bb3ec5f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..512b570 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ + +1. `pip install django-pico` + + +2. Add "djpico" to your INSTALLED_APPS setting like this: +``` + INSTALLED_APPS = ( + ... + 'djpico', + ) +``` + + +3. Include the polls URLconf in your project urls.py like this:: + + `url(r'^pico/', include('djpico.urls')),` + + + +See [Pico](https://github.com/fergalwalsh/pico/) for more information. \ No newline at end of file diff --git a/djpico/__init__.py b/djpico/__init__.py new file mode 100755 index 0000000..0d18551 --- /dev/null +++ b/djpico/__init__.py @@ -0,0 +1,9 @@ +""" +django-pico is a wrapper for the pico web application framework. + +Copyright (c) 2013, Fergal Walsh. +License: BSD +""" + +__author__ = 'Fergal Walsh' +__version__ = '0.0.1' diff --git a/djpico/urls.py b/djpico/urls.py new file mode 100755 index 0000000..8072329 --- /dev/null +++ b/djpico/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import patterns, url + +urlpatterns = patterns( + '', + url(r'pico.js|client.js', 'djpico.views.picojs', name='picojs'), + url(r'^.*$', 'djpico.views.index', name='index'), +) diff --git a/djpico/views.py b/djpico/views.py new file mode 100755 index 0000000..097b5ad --- /dev/null +++ b/djpico/views.py @@ -0,0 +1,21 @@ +import pico.server +from django.http import HttpResponse +from django.views.decorators.csrf import csrf_exempt + + +@csrf_exempt +def index(request): + params = {} + params.update(request.GET.dict()) + params.update(request.POST.dict()) + path = '/' + request.path.split('/pico/')[-1] + pico_response = pico.server.handle_api_v2(path, params) + response = HttpResponse(pico_response.output) + for key, header in pico_response.headers: + response[key] = header + return response + + +def picojs(request): + f = open(pico.server.pico_path + 'client.js') + return HttpResponse(f.read(), mimetype='application/javascript') diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..13e786a --- /dev/null +++ b/setup.py @@ -0,0 +1,38 @@ +import os +from setuptools import setup + +import djpico + +README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read() + +# allow setup.py to be run from any path +os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) + +version = djpico.__version__ + +setup( + name='django-pico', + version='0.0.1', + packages=['djpico'], + install_requires=['pico >= 1.2.1', 'django'], + include_package_data=True, + license='BSD License', + description='A Django wrapper for the Pico web app framework', + long_description=README, + url='http://github.com/fergalwalsh/django-pico', + download_url='https://github.com/fergalwalsh/django-pico/tarball/%s' % version, + author='Fergal Walsh', + author_email='fergalwalsh@gmail.com', + classifiers=[ + 'Environment :: Web Environment', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + ], +)