This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
Pythonic web.py
===========

Making `web.py` request handling more pythonic.


```python

import lessweb

def hello(ctx, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'

urls = ('GET', '/(.*)', hello)

app = lessweb.application(urls, locals())

```

All those magical web.* are now available in context variable.

```python

def hello(ctx):
user_data = ctx.input(color=[])
if 'color' not in ctx.cookies and not user_data.color:
ctx.setcookies('color', 'blue')
return 'Hello, from ' + ctx.env.get('REMOTE_HOST') or ctx.ip

urls = ('GET', '/', hello)
import lessweb
app = lessweb.application(urls, locals())

```

Only a part of web.py request handling has been masked with `less.web`. Rest of them are required to
do what they did already.

```python
import web
import lessweb

def redirect_to_referer(ctx):
referer = ctx.env.get('HTTP_REFERER', 'http://webpy.org')
raise web.seeother(referer)

urls = ('GET', '/', redirect_to_referer)
app = lessweb.application(urls, locals())
```
It's implemented as a tiny pythonic wrapper around `web.py` request handling.

The idea is to allow all request/response manipulation through `ctx`(context) of the handler function rather than module(`web`) level functions. `ctx` is basically `web.ctx` of `web.py`, which is already used to set and access request context. It also wraps other module level functionality of `web.py` such as `header`, `input`, `cookies`, `sessions` to yield a more pythonic interface.

To use sessions you have to configure session store in config as follows.

```python
web.config.sessionstore = web.session.DiskStore('sessions') # for disk store, other stores can be used similarly.
```
Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
lessweb.py-0.1.1.tar.gz (2.0 kB) Copy SHA256 Checksum SHA256 Source Oct 2, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting