diff --git a/apex/__init__.py b/apex/__init__.py index eee3fdb..d0375de 100755 --- a/apex/__init__.py +++ b/apex/__init__.py @@ -30,6 +30,14 @@ from apex.views import register from apex.views import reset_password +""" + Allows flash messages to be called as: +:: + from apex import flash + +""" +from apex.lib.flash import flash + def includeme(config): settings = config.registry.settings diff --git a/apex/lib/form.py b/apex/lib/form.py index 30c994d..1c8f823 100755 --- a/apex/lib/form.py +++ b/apex/lib/form.py @@ -4,6 +4,7 @@ from wtforms import validators from pyramid.renderers import render +from pyramid.threadlocal import get_current_registry class ExtendedForm(Form): """ Base Model used to wrap WTForms for local use @@ -42,9 +43,14 @@ def validate(self): def render(self, **kwargs): action = kwargs.pop('action', '') submit_text = kwargs.pop('submit_text', 'Submit') - template = kwargs.pop('template', 'tableform') + template = kwargs.pop('template', False) - return render('apex:templates/forms/%s.mako' % template, { + if not template: + settings = get_current_registry().settings + template = settings.get('apex.form_template', \ + 'apex:templates/forms/tableform.mako') + + return render(template, { 'form': self, 'action': action, 'submit_text': submit_text, diff --git a/docs/source/options.rst b/docs/source/options.rst index 7cfa796..c520f17 100644 --- a/docs/source/options.rst +++ b/docs/source/options.rst @@ -41,6 +41,10 @@ apex.provider_exclude = openid apex.apex_template = project:templates/auth.mako OPTIONAL, an optional template for rendering the authentication forms +apex.form_template = project:templates/form.mako + OPTIONAL, an optional template for changing the default template used when + rendering forms + apex.register_form_class = project.models.form_name OPTIONAL, requires DOTTED notation, specifies overloaded form for registration