Package s3 :: Module s3rest :: Class S3Method
[frames] | no frames]

Class S3Method

source code

object --+
         |
        S3Method

REST Method Handler Base Class

Method handler classes should inherit from this class and implement the apply_method() method.


Note: instances of subclasses don't have any of the instance attributes available until they actually get invoked from a request - i.e. apply_method() should never be called directly.

Instance Methods
 
__call__(self, r, method=None, widget_id=None, **attr)
Entry point for the REST interface
source code
 
apply_method(self, r, **attr)
Stub, to be implemented in subclass.
source code
 
widget(self, r, method=None, widget_id=None, visible=True, **attr)
Stub, to be implemented in subclass.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
crud_string(tablename, name)
Get a CRUD info string for interactive pages
source code
Properties

Inherited from object: __class__

Method Details

__call__(self, r, method=None, widget_id=None, **attr)
(Call operator)

source code 

Entry point for the REST interface

Parameters:
  • r - the S3Request
  • method - the method established by the REST interface
  • widget_id - widget ID
  • attr - dict of parameters for the method handler
Returns:
output object to send to the view

apply_method(self, r, **attr)

source code 

Stub, to be implemented in subclass. This method is used to get the results as a standalone page.

Parameters:
  • r - the S3Request
  • attr - dictionary of parameters for the method handler
Returns:
output object to send to the view

widget(self, r, method=None, widget_id=None, visible=True, **attr)

source code 

Stub, to be implemented in subclass. This method is used by other method handlers to embed this method as widget.

Parameters:
  • r - the S3Request
  • method - the URL method
  • widget_id - the widget ID
  • visible - whether the widget is initially visible
  • attr - dictionary of parameters for the method handler
Returns:
output

Note:

For "html" format, the widget method must return an XML component that can be embedded in a DIV. If a dict is returned, it will be rendered against the view template of the calling method - the view template selected by the widget method will be ignored.

For other formats, the data returned by the widget method will be rendered against the view template selected by the widget method. If no view template is set, the data will be returned as-is.

The widget must use the widget_id as HTML id for the element providing the Ajax-update hook and this element must be visible together with the widget.

The widget must include the widget_id as ?w=<widget_id> in the URL query of the Ajax-update call, and Ajax-calls should not use "html" format.

If visible==False, then the widget will initially be hidden, so it can be rendered empty and Ajax-load its data layer upon a separate refresh call. Otherwise, the widget should receive its data layer immediately. Widgets can ignore this parameter if delayed loading of the data layer is not all([possible, useful, supported]).

crud_string(tablename, name)
Static Method

source code 

Get a CRUD info string for interactive pages

Parameters:
  • tablename - the table name
  • name - the name of the CRUD string