Package bw :: Module hermes :: Class service
[frames] | no frames]

Class service

object --+
         |
        service

This decorator enables a function to return different formats based on the extension in the url.

The return value of the function is converted using the callable specified in kwargs. The response object's content-type header will also be modified.

Example:

       C{@hermes.service(xml=hermes.write_xml, json=hermes.write_json, pdf=pypdf.write_pdf)}
       def foo(self):
               ...

If the request was [..]/foo.xml, the return value of foo will be passed to write_xml If the request was [..]/foo.json, the return value of foo will be passed to write_json If the request was [..]/foo.pdf, the return value of foo will be passed to write_pdf

By default, xml, json, rdf and csv are defined which all accept a list of Ideas.

Instance Methods
 
__init__(self, **verbs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__call__(self, func)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, **verbs)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)