Package brisa :: Package core :: Module webserver :: Class Resource
[hide private]
[frames] | no frames]

Class Resource

source code

object --+
         |
        Resource

Represents a resource or a folder on the webserver.

Inheritance from this class should be used when you need special and accessing request attributes.

When a request arrives at a resource, it looks first inside his files and resources. If no handler is found, it asks the get_render() method to return who will render(uri, req, resp) the request - default is self.

Instance Methods [hide private]
 
__init__(self, name)
Constructor for the Resource class.
source code
 
render(self, uri, request, response)
Renders a request.
source code
 
add_static_file(self, file)
Adds a static file to the resource.
source code
 
add_resource(self, resource)
Adds a resource to the resource.
source code
 
application(self, environ, start_response)
WSGI application callback.
source code
 
get_render(self, uri, params)
Returns the default render for the given request, uri and params.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name)
(Constructor)

source code 

Constructor for the Resource class.

Parameters:
  • name (string) - resource name visible on the webserver
Overrides: object.__init__

render(self, uri, request, response)

source code 

Renders a request. Default action on a resource is doing nothing.

Note: should be overriden as needed

add_static_file(self, file)

source code 

Adds a static file to the resource.

Parameters:
  • file (StaticFile) - file to add

Note: if the file name is already present on the tree, it will get overriden

add_resource(self, resource)

source code 

Adds a resource to the resource.

Parameters:
  • resource (Resource) - resource to add

Note: if this resource is already present on the tree, it will get overriden

application(self, environ, start_response)

source code 

WSGI application callback. May not be called directly by the user.

get_render(self, uri, params)

source code 

Returns the default render for the given request, uri and params.

Default render is self.