diff --git a/docs/conf.py b/docs/conf.py
index 459e163..3a4e1ae 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -217,18 +217,17 @@ man_pages = [
# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'http://docs.python.org/': None}
+intersphinx_mapping = {
+ 'pyramid': ('http://docs.pylonsproject.org/projects/pyramid/1.0', None),
+ 'formalchemy': ('../../formalchemy/docs/_build/html/', None),
+ }
html_theme = 'nature'
rstctl_exclude = ['fa.jquery.app', 'fa.jquery.pylons']
-try:
- import rstctl
- extensions.append('rstctl.sphinx')
-except ImportError:
- pass
-else:
- del rstctl
+import rstctl
+extensions.append('rstctl.sphinx')
+del rstctl
from os import path
pkg_dir = path.abspath(__file__).split('/docs')[0]
diff --git a/pyramid_formalchemy/actions.py b/pyramid_formalchemy/actions.py
index 5d5a86e..0081f01 100644
--- a/pyramid_formalchemy/actions.py
+++ b/pyramid_formalchemy/actions.py
@@ -80,7 +80,7 @@ def action(name=None):
class Action(object):
"""A model action is used to add some action in model views. The content
- and alt parameters should be a ``TranslationString``::
+ and alt parameters should be a :py:class:`pyramid.i18n.TranslationString`::
>>> from webob import Request
>>> request = Request.blank('/')
@@ -167,21 +167,41 @@ class Input(Action):
>>> from webob import Request
>>> request = Request.blank('/')
>>> action = Input('myaction',
- ... value=_('Click here'))
+ ... content=_('Click here'))
Rendering::
>>> action.render(request)
- u''
+ u''
"""
- body = u''
+ body = u''
+
+ def update(self):
+ if 'type' not in self.attrs:
+ self.attrs['type'] = repr('submit')
+
+class Option(Action):
+ """An action rendered as a select option::
+
+ >>> from webob import Request
+ >>> request = Request.blank('/')
+ >>> action = Option('myaction',
+ ... value='request.application_url',
+ ... content=_('Click here'))
+
+ Rendering::
+
+ >>> action.render(request)
+ u''
+
+ """
+
+ body = u''
def update(self):
if 'value' not in self.attrs:
- self.attrs['value'] = repr(self.id.title())
- if 'type' not in self.attrs:
- self.attrs['type'] = repr('submit')
+ self.attrs['value'] = self.rcontext.get('value', self)
class UIButton(Action):
"""An action rendered as an jquery.ui aware link::
@@ -223,7 +243,7 @@ class UIButton(Action):
self.attrs['href'] = repr('#')
class Actions(list):
- """A action list::
+ """A action list. Can contain :class:`pyramid_formalchemy.actions.Action` or a dotted name::
>>> actions = Actions('pyramid_formalchemy.actions.delete',
... Link('link1', content=_('A link'), attrs={'href':'request.application_url'}))
@@ -240,6 +260,14 @@ class Actions(list):
Delete
A link
+
+ You can add actions::
+
+ >>> new_actions = Actions('pyramid_formalchemy.actions.new') + actions
+ >>> new_actions
+ [, , ]
+ >>> isinstance(new_actions, Actions)
+ True
"""
tag = u''
@@ -250,6 +278,10 @@ class Actions(list):
def render(self, request, **kwargs):
return u'\n'.join([a.render(request, **kwargs) for a in self])
+ def __add__(self, other):
+ actions = list(self)+list(other)
+ return self.__class__(*actions)
+
class Languages(Actions):
diff --git a/pyramid_formalchemy/i18n.py b/pyramid_formalchemy/i18n.py
index 630b336..0a45e6a 100644
--- a/pyramid_formalchemy/i18n.py
+++ b/pyramid_formalchemy/i18n.py
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
-__doc__ = """Model translation.
-"""
-
-
from pyramid.i18n import TranslationStringFactory
from pyramid.i18n import TranslationString
from pyramid.i18n import get_localizer