4.19.1Class Service

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_classClass of the (x)html element that the skin should expose when rendering this item.
css_idID of the (x)html element that the skin should expose when rendering this item.
levelMinimum user authorization level needed to use this service at all.
skinSkin name.
Methods
addCSSResAdds a javascript cascade style sheet directly in the text of the headings.
addJsResAdds a javascript resource for this service directly in the text of the headings.
allowedCheck if the current user is allowed to access this service.
bindBind the variables through the variable binders.
checkAllowedCheck if the current user is allowed to access this service.
configureConfigures the service.
finalizeCalled at termination.
getVariablesCheck variables
loadResourceLoads a resource file.
perform_renderExecute rendering.
renderAsk Nest system to prepare to render ourselves at this point.
renderSkinLoads a required skin file, sending it configuration data.
runAction performed by the service before rendering.
startupHook called when the service is loaded.
varNameReturn the name full of a variable contained in this class.

Properties

css_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.

css_id

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.

level

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

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.

Methods

addCSSRes

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 /res directory) to be verbatim copied on the page headers through the Nest.headings call.

addJsRes

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 /res directory) to be verbatim copied on the page headers through the Nest.headings call.

allowed

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

Bind the variables through the variable binders.

bind( listener )
listener a function to call back if the variables are session variables and change.

checkAllowed

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.

configure

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.

finalize

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.

getVariables

Check variables

getVariables()

loadResource

Loads a resource file.

loadResource( res )
res The resource file to be loaded (complete path as a string).
ReturnThe binary data in the file (in a string).
Raise
IoError on I/O error while getting the data.
NestError in case the resource cannot be found

perform_render

Execute rendering.

perform_render()
ReturnPre-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.

render

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.

renderSkin

Loads a required skin file, sending it configuration data.

renderSkin( callable )

run

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.

startup

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.

varName

Return the name full of a variable contained in this class.

varName( var )
Made with http://www.falconpl.org