Skip to content

Commit

Permalink
Update docstring of .configure methods to use them in documentation r…
Browse files Browse the repository at this point in the history
…eference for options
  • Loading branch information
amol- committed Sep 29, 2014
1 parent 5a94e42 commit abafa75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
31 changes: 17 additions & 14 deletions tg/flash.py
Expand Up @@ -60,7 +60,22 @@ class TGFlash(GlobalConfigurable):
javascript object which exposes ``.payload()`` and ``.render()`` methods that can
be used to get current message and render it from javascript.
Some options are available to configure the flash message behavior:
For a complete list of options supported by Flash objects see :meth:`.TGFlash.configure`.
"""

CONFIG_NAMESPACE = 'flash.'
CONFIG_OPTIONS = {'template': converters.astemplate,
'js_template': converters.astemplate}

def __init__(self, **options):
self.configure(**options)

def configure(self, cookie_name="webflash", default_status="ok",
template=DEFAULT_FLASH_TEMPLATE,
js_call='webflash.render()',
js_template=DEFAULT_JSFLASH_TEMPLATE):
"""Flash messages can be configured through :class:`.AppConfig` (``app_cfg.base_config``)
using the following options:
- ``flash.cookie_name`` -> Name of the cookie used to store flash messages
- ``flash.default_status`` -> Default message status if not specified (``ok`` by default)
Expand All @@ -77,19 +92,7 @@ class TGFlash(GlobalConfigurable):
already displayed messages. The template will receive: ``$container_id``,
``$cookie_name``, ``$js_call`` variables.
"""

CONFIG_NAMESPACE = 'flash.'
CONFIG_OPTIONS = {'template': converters.astemplate,
'js_template': converters.astemplate}

def __init__(self, **options):
self.configure(**options)

def configure(self, cookie_name="webflash", default_status="ok",
template=DEFAULT_FLASH_TEMPLATE,
js_call='webflash.render()',
js_template=DEFAULT_JSFLASH_TEMPLATE):
"""
self.default_status = default_status
self.cookie_name = cookie_name
self.static_template = template
Expand Down
9 changes: 5 additions & 4 deletions tg/jsonify.py
Expand Up @@ -75,11 +75,12 @@ def __init__(self, **kwargs):
super(JSONEncoder, self).__init__(**kwargs)

def configure(self, isodates=False, custom_encoders=None, **kwargs):
"""Configures the JSONEncoder.
"""JSON encoder can be configured through :class:`.AppConfig` (``app_cfg.base_config``)
using the following options:
This is used to specify if dates should be encoded in ISO8601 format
and to register ``custom_encoders``. This is automatically called
by ``__init__`` and :class:`.AppConfig`.
- ``json.isodates`` -> encode dates using ISO8601 format
- ``json.custom_encoders`` -> List of tuples ``(type, encode_func)`` to register
custom encoders for specific types.
"""
self._isodates = isodates
Expand Down

0 comments on commit abafa75

Please sign in to comment.