I define a web-accessible resource.
I serve 2 main purposes; one is to provide a standard representation for
what HTTP specification calls an entity , and the other is to provide an
abstract directory structure for URL retrieval.
Methods
|
|
|
|
__init__
|
__init__ ( self )
Initialize.
|
|
delEntity
|
delEntity ( self, name )
|
|
getChild
|
getChild (
self,
path,
request,
)
Retrieve a child resource from me.
Arguments:
path: a string, describing the child
request: a twisted.web.server.Request specifying meta-information
about the request that is being made for this child.
- Implement this to create dynamic resource generation
- resources which
are always available may be registered with self.putChild().
This will not be called if the class-level variable isLeaf is set in
your subclass; instead, the postpath attribute of the request will be
left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by bar has isLeaf set to true, then
the getChild call will never be made on it.
|
|
getChildForRequest
|
getChildForRequest ( self, request )
(internal) Get a child of mine dependant on a particular request.
This will be called on me as a top-level resource of a site in order to
retrieve my appropriate child or grandchild to display.
|
|
getChildWithDefault
|
getChildWithDefault (
self,
path,
request,
)
(internal) Retrieve a static or dynamically generated child resource from me.
Arguments are similiar to getChild.
This will check to see if I have a pre-registered child resource of the
given name, and call getChild if I do not.
|
|
getDynamicEntity
|
getDynamicEntity (
self,
name,
request,
)
|
|
getStaticEntity
|
getStaticEntity ( self, name )
|
|
listDynamicEntities
|
listDynamicEntities ( self, request )
|
|
listDynamicNames
|
listDynamicNames ( self )
|
|
listStaticEntities
|
listStaticEntities ( self )
|
|
listStaticNames
|
listStaticNames ( self )
|
|
putChild
|
putChild (
self,
path,
child,
)
Register a child with me.
|
|
reallyPutEntity
|
reallyPutEntity (
self,
name,
entity,
)
|
|
render
|
render ( self, request )
Render a given resource.
This must be implemented in all subclasses of Resource.
The return value of this method will be the rendered page, unless the
return value is twisted.web.server.NOT_DONE_YET, in which case it is
this class's responsability to write the results to
request.write(data), then call request.finish().
Exceptions
|
|
NotImplementedError("%s called" % str( self.__class__.__name__ ) )
|
|
|