PylonsTemplates: extra Paster templates for Pylons apps

PylonsTemplates gives you additional paster templates for Pylons applications. (Right now, there is one.)

Once the PylonsTemplates module is installed, you can create new Pylons projects like this:

paster create -t [templatename] [projectname]

pylons_repoze_what

Based on the default Pylons paster template, the pylons_repoze_what template implements a working authorization system based on repoze.what and repoze.what-quickstart. (Authentication by repoze.who is automatically set up as well.) The template generates:

Quick example of repoze.what-pylons usage

Once you have created your project using paster create -t pylons_repoze_what, you will probably want to start protecting controllers or actions. Read the repoze.what-pylons documentation, linked below, for the full scoop. But here's a quick example ot get you started.

from repoze.what.predicates import has_permission
from repoze.what.plugins.pylonshq import ActionProtector

class HelloWorldController(BaseController):
    @ActionProtector(has_permission('be_cool'))
    def index(self):
        return 'Hello World'

Links

Feedback

Please direct all suggestions or responses to Jason Stitt at js@jasonstitt.com.

Share this content

Comments

Avatar picture for kenboo I tried it, and the paster serve didn't start.
myapp/config/middleware.py passes logging.INFO to setup_sql_auth() of repoze.what.plugins.__init__.py
The setup_sql_auth expects string if not None but logging.INFO is actually an integer.

log_level = who_args.get('log_level', None)
if log_level is None:
log_level = logging.INFO
else:
log_level = _LEVELS[log_level.lower()]
who_args['log_level'] = log_level

I commented out the last 3 lines
Avatar picture for kenboo I had not read the issue tracker at github. I appreciate if you'd update the egg at PyPi.
Avatar picture for Tonjae E. Thank you for PylonsTemplates

I have two problems.
1. capital project name at import block in auth.py. It seems trivial problem :)
2. log_level value is not string at CUSTOM MIDDLEWARE HERE "if asbool(full_stack):" section in middleware.py . My project started after changing INFO to 'INFO'. Is it right?
Avatar picture for Jason Stitt Sorry about the lack of PyPi update! I put the latest version up there.

I don't quite understand the capital project name problem. I think I remember that 'paster create' does not support capitals, and I don't think I can fix that.

Post Comment

All comments are personally reviewed and must be:

  • On-topic
  • Courteous
  • Not self-linking or spam
(Optional. This is your one self-link.)