New in version 1.1.0.
Control in MVC – Base Controller and helpers like function-to-URL conversion.
Returns the root controller.
| Return type: | Controller |
|---|
Available controllers as a list, incuding the root.
| Returns: | List of controller instances in an undefined order. |
|---|---|
| Return type: | list |
Name of an exposed node.
| Parameters: |
|
|---|---|
| Returns: | The name of node or None if node is not exposed. Note that this function returns the empty string (“”) if node is the root controller. |
| Return type: | string |
Returns the canonical exposed URI of a node.
If node is a controller or a __call__, the uri always ends in a slash. Otherwise it never ends in a slash.
| Parameters: |
|
|---|---|
| Return type: | string |
Returns the canonical path to node.
| Parameters: |
|
|---|---|
| Return type: | list |
Returns the template uri for node.
| Parameters: |
|
|---|---|
| Return type: | list |
Return the class on which method was originally defined.
>>> from smisk.mvc.control import method_origin
>>> class Animal(object):
>>> def name(self):
>>> pass
>>>
>>> class Fish(Animal):
>>> def color(self):
>>> pass
>>>
>>> o = Fish()
>>> print method_origin(o.name)
<class '__main__.Animal'>
>>> print method_origin(o.color)
<class '__main__.Fish'>
| Parameters: |
|
|---|---|
| Returns: | Class on which method was originally defined or None if no parent could be deduced. |
| Return type: | object |
Return True if node defined on class cls is visible.
| Parameters: |
|
|---|---|
| Return type: | bool |
The base controller from which the controller tree is grown.
To grow a controller tree, you need to set a root first. This is done by defining a subclass of Controller with the special name ‘root’ (case-insensitive).
Here is a very simple, but valid, controller tree:
class root(Controller):
def hello(self):
return {'message': 'Hello'}
Returns the canonical name of this controller.
| Return type: | string |
|---|
Returns the canonical path to this controller.
| Returns: | path as token list or None if no path to this controller. |
|---|---|
| Return type: | list |
Returns the canonical URI for this controller.
| Return type: | string |
|---|
List available character sets.
| Parameters: |
|
|---|---|
| Returns: | Character sets keyed by name |
List available methods.
| Parameters: |
|
|---|---|
| Returns: | Methods keyed by URI |
List available content serializers.
| Parameters: |
|
|---|---|
| Returns: | Serializers keyed by name |
Returns a dictionary of available special methods, keyed by exposed name.
| See: | enable_reflection |
|---|---|
| Return type: | list |