<a id="webpy-framework"></a>

# Webpy Framework

[Webpy](http://webpy.org/) framework is easy to setup, once that [python-social-auth](https://github.com/python-social-auth) is installed
or accessible in the `PYTHONPATH`, just add the needed configurations to make
it run.

<a id="dependencies"></a>

## Dependencies

The Webpy app depends on [sqlalchemy](http://www.sqlalchemy.org/), there’s no support for others
ORMs yet but pull-requests are welcome.

<a id="installing"></a>

## Installing

From [pypi](http://pypi.python.org/pypi/social-auth-app-webpy/):

```default
$ pip install social-auth-app-webpy
```

<a id="configuration"></a>

## Configuration

Add the needed settings into `web.config` store. Settings are prefixed with
`SOCIAL_AUTH_` but there’s a helper for it:

```default
from social_core.utils import setting_name

web.config[setting_name('USER_MODEL')] = 'models.User'
web.config[setting_name('LOGIN_REDIRECT_URL')] = '/done/'
web.config[setting_name('AUTHENTICATION_BACKENDS')] = (
    'social_core.backends.google.GoogleOAuth2',
    ...
)
```

Add all the settings needed for the app (check [Configuration]() section for
details).

<a id="urls"></a>

## URLs

Add the social application into URLs:

```default
from social_webpy import app as social_app

urls = (
    ...
    '', social_app.app_social
    ...
)
```

<a id="session"></a>

## Session

[python-social-auth](https://github.com/python-social-auth) depends on sessions storage to keep some essential values,
usually redirects and `state` parameters used to validate authentication
process on OAuth providers.

The Webpy built-in app expects the session reference to be available under
`web.web_session` so ensure it’s available there.

<a id="user-model"></a>

## User model

Like the other apps, the User model must be defined on settings since
a reference to it is kept on `UserSocialAuth` instance. Define like this:

```default
web.config[setting_name('USER_MODEL')] = 'models.User'
```

Where the value is the import path to the User model used on your project.
