Main Nest modular component.
Class Service( [instance] ) from \ NestModule(( instance))
instance | A string representing a specific name for this service. |
If the instance is not specificed the service is "instanceless" (or nameless).
Properties | |
css_class | Class of the (x)html element that the skin should expose when rendering this item. |
css_id | ID of the (x)html element that the skin should expose when rendering this item. |
level | Minimum user authorization level needed to use this service at all. |
skin | Skin name. |
Methods | |
addCSSRes | Adds a javascript cascade style sheet directly in the text of the headings. |
addJsRes | Adds a javascript resource for this service directly in the text of the headings. |
allowed | Check if the current user is allowed to access this service. |
bind | Bind the variables through the variable binders. |
checkAllowed | Check if the current user is allowed to access this service. |
configure | Configures the service. |
finalize | Called at termination. |
getVariables | Check variables |
loadResource | Loads a resource file. |
perform_render | Execute rendering. |
render | Ask Nest system to prepare to render ourselves at this point. |
renderSkin | Loads a required skin file, sending it configuration data. |
run | Action performed by the service before rendering. |
startup | Hook called when the service is loaded. |
varName | Return the name full of a variable contained in this class. |
Class of the (x)html element that the skin should expose when rendering this item.
Many skins will want to know the class value to put on the topmost html item they render, so that CSS and javascripts can easily address the element.
ID of the (x)html element that the skin should expose when rendering this item.
Many skins will want to know the ID value to put on the topmost html item they render, so that CSS and javascripts can easily address the element.
The default is that of making the this value == to the instance name, and where absent, to the service name, but it can be overridden in configuration.
Minimum user authorization level needed to use this service at all.
When the Nest.auth_level variable is higher (less privileged) than this value, the service won't be run nor rendered.
Skin name.
Set to a logical skin name or to a callable function.
If left undefined, and the service render step is required, the value will be defaulted to "skin", and the relative skin will be searched in the service path, but no warning will be raised if the default skin file is not found.
If a skin is explicitly required and the SkinBinder can't find it, then an error will be raised.
The skin function will be typically called with two parameters: the variables bound in the service and the instance of this service. However, this is a general convention that doesn't need to be respected by the service-skin pairs, if some different communication between them is required.
Bound variables are sent to the skin in a blessed dictionary (pseudo-object) where each key is the name of the Service variable, and the value is the bound variable value.
Adds a javascript cascade style sheet directly in the text of the headings.
addCSSRes( res )
res | The resource to be called. |
This will make the text of the given CSS file (in
Adds a javascript resource for this service directly in the text of the headings.
addJsRes( res )
res | The resource to be called. |
This will make the text of the given javascript file (in
Check if the current user is allowed to access this service.
allowed()
Skins and other variable element should check for this value before performing any operation or displaying any data.
See also: Service.
Bind the variables through the variable binders.
bind( listener )
listener | a function to call back if the variables are session variables and change. |
Check if the current user is allowed to access this service.
checkAllowed()
Differently from Service.allowed, it also logs an error message if the service is not allowed. As such, is slower, and should be used sparsely.
Configures the service.
configure( config )
config | A dictionary containing configuration key/value pairs. |
In this phase, the service structure is still incomplete, and data providers may be missing.
This means that variables meant to be broadcast shouldn't be set here. Use the bind process, that happens later on.
The default implementation just stores the config parameter in the NestModule.configuration property. This is where configuration binders will check for this value.
Called at termination.
finalize()
This method is called after all the rendering are perfomed and the page output is sent to the remote user. Normally, it shouln't generate any output, unless critical errors are detected and cannot be handled locally.
Check variables
getVariables()
Loads a resource file.
loadResource( res )
res | The resource file to be loaded (complete path as a string). | ||||
Return | The binary data in the file (in a string). | ||||
Raise |
|
Execute rendering.
perform_render()
Return | Pre-formatted XHTML text to output directly on the final page. |
This callback is called if the service previously registered through @ Service.render, and is invoked directly by Nest at page output completion.
The default function loads the skin given in _skin_file, if present.
Implementors may override this if this simple behavior is not enough, or if the service rendering is simple enough not to require skin files.
This method should return "" if nothing is to be rendered.
Ask Nest system to prepare to render ourselves at this point.
render()
This sends a request to Nest to insert the output of the Service here.
Loads a required skin file, sending it configuration data.
renderSkin( callable )
Action performed by the service before rendering.
run()
This method is always called after the whole of the page has been loaded, and all the services are readied and started up.
Hook called when the service is loaded.
startup()
After the service is loaded and configured by Nest, it gets a chance to punch in and perform some essential operations before Nest can proceed with the rest of the page.
Return the name full of a variable contained in this class.
varName( var )