Libraries anvil net Context

class Context
extends anvil.lang.object
The Context holds information about the request, response, session, and user.

Methods

Session createSession()
Creates and returns a new session.
Throws AccessDenied -  If security policy denies this operation

Citizen getCitizen(string username, string credentials)
Citizen getCitizen(string username)
Gets, and authenticates, specified user.
Parameters username -  Username
credentials -  Credentials
Returns citizen, or null if authentication failed
Throws AccessDenied -  If security policy denies this operation

string getLinkUrl()
Returns the full URI to the current script.
string getLinkUrl(string name, string value)
One name-value pair.
string getLinkUrl(string name1, string value1, string name2, string value2 [, ...])
Many name-value pairs.
string getLinkUrl(array params)
Takes name-value pairs from array.
Returns an URL that can be used for creating events. For example: <a href=${context.getLinkUrl("click","true")}>click</a> Returns, for example "/$hsyukrxkrxjemljuhaow/components/test/index.nvl?root_foo.click=true"
Parameters name -  name of event
value -  value of event
params -  array of event names and values
Returns an URL that can be used for creating events

Session getOrCreateSession(string id)
Returns the specified session from container, or creates new one with given id.
Throws AccessDenied -  If security policy denies this operation

Realm getRealm()
Realm getRealm(string realmName)
Returns the authentication realm used.
Throws AccessDenied -  If security policy denies this operation

string getResource()
If dispatcher is set for zone, returns the extra part after zone's path. Returned value always starts with slash (/).

Session getSession(string id)
Returns the specified session from container, or null if it didn't exist
Throws AccessDenied -  If security policy denies this operation

Citizen getTribe(string name)
Gets named tribe from current realm, if any.
Parameters name -  Tribe name
Returns tribe, or null if no tribe with given name were found
Throws AccessDenied -  If security policy denies this operation

Configurable getZone()
Returns the zone that received this request.
Throws AccessDenied -  If security policy denies this operation

Context setCitizen(Citizen citizen)
Sets the citizen for current session
Throws AccessDenied -  If security policy denies this operation

Context setResource(string resource)
Sets the pointed resource.


Attributes

Session self.session
Session for the request, if enabled.

Citizen self.citizen
Authorized user, if enabled.

Request self.request
HTTP request.

Response self.response
HTTP response.

object self.parameter
Named parameters from request.


References

object self[parameter]
Named parameters from request.