Collection of useful function decorators
The package contains function decorators that help implementing repetitive tasks. It is mostly oriented towards Zope development.
Change History
0.2 (2007-09-05)
Fixed problem with methods not being passed parameters from the query string. When a view method was called directly using an URL the parameters from the query string were lost when a view method was decorated. The decorators now push back the query parameters into the method call.
0.1 (2007-08-31)
First public release.
Detailed Documentation
browser module
This module provides decorators that are useful with Zope 3 browser views (also usable in Zope 2).
JSON decorator
The JSON decorator uses simplejson to encode the return value of the decorated function as JSON.
>>> from hexagonit.decorators.browser import json>>> @json ... def json_callback(): ... """JSON callback method.""" ... return {'bool' : (True, False) } >>> json_callback() '{"bool": [true, false]}'
Any keyword arguments passed to the decorator will be passed on to the simplejson.dumps function.
>>> @json(sort_keys=True, ensure_ascii=False)
... def json_callback():
... """JSON callback method."""
... return {'foo' : None, 'bool' : (True, False), 'ints' : [1,2,3]}
>>> json_callback()
u'{"bool": [true, false], "foo": null, "ints": [1, 2, 3]}'
HTTP cache disabling decorator
The nocache decorator is used for Zope 3 views and sets the appropriate HTTP headers to disable caching for the results of the decorated method.
>>> from hexagonit.decorators.browser import nocache
We’ll demonstrate the use of the decorator with a dummy view object.
>>> class Dummy(object):pass >>> class BrowserView(object): ... """Dummy view class that fakes the ``request`` object.""" ... def __init__(self): ... self.request = Dummy() ... self.request.response = Dummy() ... self.headers = [] ... self.request.response.setHeader = lambda header,value: self.headers.append('%s: %s' % (header, value)) ... ... @nocache ... def ajax_callback(self): ... print '\n'.join(self.headers)>>> view = BrowserView() >>> view.ajax_callback() Pragma: no-cache Expires: Sat, 1 Jan 2000 00:00:00 GMT Cache-Control: no-cache, must-revalidate
It is also possible to use both the json decorator and the nocache decorator at the same time.
Download
Metadata
Release files for hexagonit.decorators 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hexagonit.decorators-0.2.tar.gz | 4.4 kB | Without provenance | Details for hexagonit.decorators-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hexagonit.decorators-0.2-py2.4.egg | Legacy Egg format | - | - | Details for hexagonit.decorators-0.2-py2.4.egg |
Total release size: 13.2 kB
Release files / hexagonit.decorators-0.2.tar.gz
| Download URL | hexagonit.decorators-0.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f291f4feda092f8d2502dc6b19add3c93b5f7a4f4f966ccfe134bd434439727
|
|
BLAKE2b-256 checksum How to use checksums |
c563c99c7d0eee2bd063b861ac54a1f2149d28a4be307d04d9ec357dd86a145d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / hexagonit.decorators-0.2-py2.4.egg
| Download URL | hexagonit.decorators-0.2-py2.4.egg |
|---|---|
| Size | 8.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
7bb9e293647b43800141d74c27f502253d73c0377ca147170b7d4a334867b628
|
|
BLAKE2b-256 checksum How to use checksums |
7706083285b913febe076ce46193e6acea04f356fda1652b8d3c39f53237e35a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for hexagonit.decorators 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.