bbangert / beaker (http://beaker.groovie.org/)
Beaker Official Mirror
Clone this repository (size: 427.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/bbangert/beaker/
| commit 352: | 8265f71bfb7d |
| parent 351: | cc9f5bc7e247 |
| branch: | trunk |
Update docs to reflect session options and new cache decorators.
Changed (Δ862 bytes):
raw changeset »
beaker/docs/caching.rst (19 lines added, 0 lines removed)
beaker/docs/modules/session.rst (1 lines added, 1 lines removed)
beaker/session.py (2 lines added, 0 lines removed)
Up to file-list beaker/docs/caching.rst:
| … | … | @@ -219,6 +219,20 @@ Assuming a ``long_term`` and ``short_ter |
219 |
219 |
|
220 |
220 |
results = get_results('gophers') |
221 |
221 |
|
222 |
Or using the :func:`beaker.cache.cache_region` decorator:: |
|
223 |
||
224 |
@cache_region('short_term', 'my_search_func') |
|
225 |
def get_results(search_param): |
|
226 |
# do something to retrieve data |
|
227 |
data = get_data(search_param) |
|
228 |
return data |
|
229 |
||
230 |
results = get_results('gophers') |
|
231 |
||
232 |
The only difference with the :func:`beaker.cache.cache_region` decorator is |
|
233 |
that the cache does not need to be configured when its used. This allows one |
|
234 |
to decorate functions in a module before the Beaker cache is configured. |
|
235 |
||
222 |
236 |
Invalidating |
223 |
237 |
------------ |
224 |
238 |
|
| … | … | @@ -229,6 +243,11 @@ the 'gophers' result that the prior exam |
229 |
243 |
|
230 |
244 |
cache.region_invalidate(get_results, None, 'my_search_func', 'gophers') |
231 |
245 |
|
246 |
Or when using the :func:`beaker.cache.cache_region` decorator, the |
|
247 |
:func:`beaker.cache.region_invalidate` function should be used:: |
|
248 |
||
249 |
region_invalidate(get_results, None, 'my_search_func', 'gophers') |
|
250 |
||
232 |
251 |
.. note:: |
233 |
252 |
Both the arguments used to specify the additional namespace info to the |
234 |
253 |
cache decorator **and** the arguments sent to the function need to be |
Up to file-list beaker/docs/modules/session.rst:
| … | … | @@ -11,6 +11,6 @@ Module Contents |
11 |
11 |
.. autoclass:: Session |
12 |
12 |
:members: save, revert, lock, unlock, delete, invalidate |
13 |
13 |
.. autoclass:: SessionObject |
14 |
:members: persist |
|
14 |
:members: persist, get_by_id, accessed |
|
15 |
15 |
.. autoclass:: SignedCookie |
16 |
16 |
Up to file-list beaker/session.py:
| … | … | @@ -581,6 +581,7 @@ class SessionObject(object): |
581 |
581 |
return self._session().has_key(key) |
582 |
582 |
|
583 |
583 |
def get_by_id(self, id): |
584 |
"""Loads a session given a session ID""" |
|
584 |
585 |
params = self.__dict__['_params'] |
585 |
586 |
session = Session({}, use_cookies=False, id=id, **params) |
586 |
587 |
if session.is_new: |
| … | … | @@ -615,4 +616,5 @@ class SessionObject(object): |
615 |
616 |
return self.__dict__.get('_dirty', False) |
616 |
617 |
|
617 |
618 |
def accessed(self): |
619 |
"""Returns whether or not the session has been accessed""" |
|
618 |
620 |
return self.__dict__['_sess'] is not None |
