Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fergal Walsh authored and Fergal Walsh committed Oct 30, 2013
0 parents commit a774a07
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

*.pyc
.DS_Store
MANIFEST

dist/*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions djpico/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
7 changes: 7 additions & 0 deletions djpico/urls.py
Original file line number Diff line number Diff line change
@@ -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'),
)
21 changes: 21 additions & 0 deletions djpico/views.py
Original file line number Diff line number Diff line change
@@ -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')
38 changes: 38 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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='[email protected]',
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',
],
)

0 comments on commit a774a07

Please sign in to comment.