| |
- __builtin__.dict(__builtin__.object)
-
- web.wof.Session
- __builtin__.list(__builtin__.object)
-
- web.wof.Path
- spug.web.cgi.CGIRequest
-
- web.wof.Request
- spug.web.htmlo.XDoc(spug.web.htmlo.HTML)
-
- web.wof.DocWrapper
- spug.web.htmlo.XNull(spug.web.htmlo.HTMLElement)
-
- web.wof.NullElemlet
- web.wof.XMLElemlet
-
- web.wof.XMLDocWrapper
- web.wof.AccessManager
-
- web.wof.NullAccessManager
- web.wof.Dependency
-
- web.wof.ClassDependency
- web.wof.FileDependency
- web.wof.XMLElemletFactory
-
- web.wof.XMLDocWrapperFactory
- web.wof.Node
-
- web.wof.FileNode
-
- web.wof.CSSNode
- web.wof.HTMLNode
- web.wof.JpegNode
- web.wof.PNGNode
- web.wof.TextNode
- web.wof.NMLNode
- web.wof.NullNode
- web.wof.ParentNode
-
- web.wof.Directory
- web.wof.PythonScript
- web.wof.ProtectedNode
- web.wof.PythonFunc
- web.wof.NodeContext
- web.wof.PCGIClientHandler
- web.wof.Response
-
- web.wof.CachedResponse
- web.wof.SessionManager
class AccessManager |
|
Basic interface for determining access levels. |
|
Methods defined here:
- hasAccess(self, request, priviliege)
- Returns true if the client has the privilege.
Must be implemented by derived classes.
parms:
request::
[@Request]
privilege::
[string] privilege name
|
class CSSNode(FileNode) |
|
Node to represent a CSS file. |
|
- Method resolution order:
- CSSNode
- FileNode
- Node
Methods defined here:
- getContentType(self, request)
Methods inherited from FileNode:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class Dependency |
|
Abstract interface for dependents - these are anything that have
timestamps. |
|
Methods defined here:
- getTimestamp(self, request)
- Returns the timestamp of the dependent.
Must be implemented by derived classes.
parms:
request: [@Request]
|
class Directory(ParentNode) |
|
A node that corresponds to an actual directory in the file system. |
|
- Method resolution order:
- Directory
- ParentNode
- Node
Methods defined here:
- getDependentsTimestamp(self, request)
Methods inherited from ParentNode:
- __init__(self, **properties)
- addChild(self, name, node)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Overrides @Node.buildCache() to build children.
- deleteAllChildren(self)
- Deletes all children of the node.
- deleteChild(self, name)
- Removes a specific child. Raises a *KeyError* if the child does not
exist.
parms:
name::
[string] child name
- emitPage(self, request, response)
- getAllChildren(self)
- Returns an unordered list of child objects
(list<tuple<string, @Node>>).
- getCachePath(self, request)
- Overrides the @Node.getCachePath() to construct the cache path
from the name of a file within the directory.
- getChild(self, name)
- getNodeAtPath(self, path, parentContext=None, name='')
- Overrides @Node.getNodeAtPath() to actually implement the recursive
path searching.
- getOrderedChildren(self)
- Returns a list of child names and objects (tuple<string, @Node>)
ordered by the "natural order" of the parent node. By default,
this is alphabetical.
- getPage(self, request, response)
- isStatic(self, request)
- setPageNode(self, node)
- Sets the "page node": @getPage() requests will be delegated
to this node if it has been defined.
*Deprecated* - use @setPagePath() instead.
- setPagePath(self, path)
- Sets the path that @getPage() requests will be delegated to - this
allows a ParentNode to display something other than the default
directory index.
Methods inherited from Node:
- __getitem__(self, property)
- __setitem__(self, property, val)
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class DocWrapper(spug.web.htmlo.XDoc) |
|
Document wrapper. This encapsulates the representation of outer page
information so that clients can focus on providing the central
page content. |
|
- Method resolution order:
- DocWrapper
- spug.web.htmlo.XDoc
- spug.web.htmlo.HTML
- spug.web.htmlo.HTMLElement
- spug.web.xmlo.Element
Methods defined here:
- __init__(self, request)
- getDependentsTimestamp(self, request)
- Returns the timestamp of the oldest dependent.
parms:
request: [@Request]
- setParcel(self, parcel)
- Sets the parcel (the central content) of the document.
parms:
parcel::
[@spug.htmlo.HTMLElement]
- setTitle(self, title)
- Sets the page title.
parms:
title::
[string] page title
Methods inherited from spug.web.htmlo.HTMLElement:
- formatTo(self, output, indentContent=0, indent=2, xhtml=0)
- Overrides @spug.web.xml.Element.formatTo() to provide an XHTML
parameter.
parms:
output::
[file.write] output stream
indentContent::
[boolean] if true, multiline content is indented.
indent::
[int] number of characters to indent children
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
- populate(self, valueDict)
- Populates this element and all nested elements from the value
dictionary.
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
The value of the element is set using the @set() method. This
is what is generally overriden to vary the way control values are
defined.
- set(self, value)
- Sets the value of an element in the manner prescribed for the
element. This is really only relevant for form controls. The base
class version of this just sets the "value" attribute. Derived
classes should override as appropriate.
- writeTo(self, output, xhtml=0)
- Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
parms:
output::
[file.write]
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
Methods inherited from spug.web.xmlo.Element:
- __delitem__(self, accessor)
- __getitem__(self, accessor)
- Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
parms:
accessor::
[string or tuple<string, string> or int] If this is a string
or tuple, returns the associated attribute. If it is an
integer, returns the associated content item.
If this is a single string, returns the value of an attribute
in the global namespace. If it is a tuple of two strings,
the first string is a namespace URI.
If this is an integer, returns the value of a child element.
Interspersed text is ignored.
- __len__(self)
- Returns the number of content nodes in the element.
- __nonzero__(self)
- Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
- __setitem__(self, accessor, value)
- append(self, val)
- Appends a new element or text string to the contents of the element.
parms:
val::
[string or @Element]
- copy(self)
- Returns a deep copy of the element.
- deleteItem(self, index)
- Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#". However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
- get(self, attr, default=None)
- getActualNamespace(self)
- Returns the actual namespace of the element name. The "actual
namespace" is the specified namespace if there is one,
it is the default namespace if there was no specified namespace.
- getAllChildren(self)
- Returns all child elements (list<@Element>). This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
- getChild(self, namespace, name)
- Returns the first child with the given name. Returns None if no
such child exists.
parms:
namespace::
[string] namespace URI
name::
[string]
- getChildren(self, namespace, name)
- Returns all children with the given name.
parms:
namespace::
[string] namespace URI
name::
[name]
- getDefaultNamespace(self)
- Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
- getFullName(self)
- Returns the namespace and name of the of the element
(tuple<string, string>). Note that the namespace is the
/specified namespace/, not the /actual namespace/.
- getName(self)
- Returns the simple unqualified name of the element.
- getNamespace(self, prefix)
- Returns the namespace URI for the given prefix. Returns None
if no such prefix is defined.
parms:
prefix::
[string] namespace prefix
- getParent(self)
- Returns the parent object (actually, a proxy to the parent object),
*None* if there is no parent.
- getPrefix(self, uri)
- Returns the namespace prefix for the given URI. Returns
None if no prefix is found for this URI.
parms:
uri::
[string] namespace URI to find the prefix for
- getValue(self)
- Returns the value of the element as one big string. This will
raise a ValueError if the element contains nested child elements.
- hasChildren(self)
- Returns true if the element has child elements.
- hasContents(self)
- Returns true if the element has contents (children or character
data).
- has_key(self, attr)
- Returns true if the element has the given attribute.
parms:
attr::
[string or tuple<string, string>] attribute to check for.
- index(self, item)
- Returns the index of the item within the contents list (an integer).
parms:
item::
[string or @Element]
- insert(self, index, val)
- iterate(self, explorer)
- Selectively iterates over the tree using the given explorer in
a depth-first traversal.
parms:
explorer::
[callable<any>] This object will be called for the node.
The value it returns indicates how the iteration proceeds.
The following return values are allowed:
EXPAND::
Iterate over the children of the node.
CONTINUE::
Do not iterate over the children of the node, continue
iteration with the next node in the parent's child list.
ABORT::
Abort iteration.
- setName = __setName(self, name)
- Sets the full name of the element.
parms:
name::
[tuple<string, string> or string] Either an unqualified name or
a tuple of namespace URI and local name.
- setValue = __setValue(self, newValue)
- Deletes all current contens of the element, and replaces it with
the new value.
parms:
newValue::
[string]
- setdefault(self, attr, default)
- strip(self, stripContent=0)
- Strips all "unnecessary" whitespace from the element and all nested
elements. Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation,
this is usually just for formatting.
parms:
stripContent::
[boolean] if true, indicates that indentation of content
elements (nodes with no nested children
- stripEmptyContents(self)
- If the element contents consists of nothing but whitespace, deletes
all contents. Otherwise makes no changes to the element.
Returns true if contents were removed, false if not.
This can used to "clean out" whitespace content after removing a
child element.
Data and other attributes inherited from spug.web.xmlo.Element:
- ABORT = 3
- CONTINUE = 2
- EXPAND = 1
|
class FileNode(Node) |
|
This is the base class for nodes representing files that are served in
their source form with no translation. |
|
Methods defined here:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getContentType(self, request)
- Returns the node's "content-type" field.
Must be implemented by derived class.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class HTMLNode(FileNode) |
|
Node to represent a plain HTML page (which can be copied directly to
the cache with no processing). |
|
- Method resolution order:
- HTMLNode
- FileNode
- Node
Methods defined here:
- getContentType(self, request)
Methods inherited from FileNode:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class JpegNode(FileNode) |
|
Node to represent a JPEG image. |
|
- Method resolution order:
- JpegNode
- FileNode
- Node
Methods defined here:
- getContentType(self, request)
Methods inherited from FileNode:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class NMLNode(Node) |
|
Node for NML documents.
Properties:
wrapper::
Standard document wrapper object.
wrapperPath::
[string] path to an HTML wrapper file (will probably replace this
with a more generic notion of a wrapper). |
|
Methods defined here:
- emitPage(self, request, response)
- getDependentsTimestamp(self, request)
- getNMLText(self, request)
- Returns the NML TextBlock for the document. This loads it from the
source path by default, but can be overriden by derived classes.
- isStatic(self, request)
Data and other attributes defined here:
- HTMLWrapperFile = <class web.wof.HTMLWrapperFile at 0x83a4e6c>
- Another hack to wrap the old-style HTML wrapper files.
- NMLWriter = <class web.wof.NMLWriter at 0x83a4e3c>
- WOFHTMLFormatter = <class web.wof.WOFHTMLFormatter at 0x83a4e0c>
- Specializes the NML @HTMLFormatter class to override link resolution.
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPage(self, request, response)
- Gets the content of the page identified in the request and
writes it into the response. If the request is for a static
page, the cache is refreshed and the response is written from the
cache. If not, @emitPage() is called directly and is expected
to write a page of content type specified by the @getContentType()
method.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class Node |
|
This class represents a node in the URL tree. Every node will
return an associated piece of data. |
|
Methods defined here:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPage(self, request, response)
- Writes the page. Should not attempt to set content type or other
response headers on the response: this must be done in @getPage().
Must be implemented by derived classes.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getDependentsTimestamp(self, request)
- Returns the timestamp of the newest dependent (float).
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the
current page node.
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPage(self, request, response)
- Gets the content of the page identified in the request and
writes it into the response. If the request is for a static
page, the cache is refreshed and the response is written from the
cache. If not, @emitPage() is called directly and is expected
to write a page of content type specified by the @getContentType()
method.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- isStatic(self, request)
- Returns true if the node is "static" in the context of the given
request - if its construction does not vary based on its parameters.
Must be implemented by derived classes.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class NodeContext |
|
This class tracks the ancestry of a @Node in the context of a request. |
|
Methods defined here:
- __getitem__(self, property)
- Gets the value of a property recursively, searching first the node,
then the immediate parent, then the grandparent, etc. If no parent
defines a value for the property, a *KeyError* is raised.
- __init__(self, node, name, parent=None)
- parms:
node::
[@Node] the node that this context is the context for
name::
[string] the name of the node in this context
parent::
[@NodeContext] parent context
- get(self, property, defaultValue=None)
- Gets the value of a property recursively, returns the /defaultValue/
if the property is not defined.
parms:
property::
[string] property name
defaultValue::
[any] value to return if property is not defined
- getCachePath(self)
- Returns the recursively evaluated "cache path" - the directory
that the node page should be cached in.
If any node in the ancestry chain has a "cachePath" property,
it is used as the base path for all child nodes. The root node
must have this property, or a *KeyError* will be raised.
- getNode(self)
- Returns the associated @Node instance.
- getParent(self)
- Returns the parent node context or *None* if there is no
parent node (@NodeContext or None).
- getPath(self)
- Returns the path traveled to get to the the node (@Path).
For the root node, this returns an empty list.
- getPathString(self)
- Returns the path traveled to get to this node as a string, complete
with leading "`/`".
- getPathToLocalRoot(self, treeName)
- Returns the segment of the path to the local root of the named
tree. (@Path)
parms:
treeName::
[string] name of the local root to search for in the
ancestry. If this value is '.cur', the current node will
always be returned.
- has_key(self, property)
- Returns true if the property is defined, false if not.
parms:
property::
[string] property name
|
class NullElemlet(spug.web.htmlo.XNull) |
|
A "null element" factory - suitable for use in cases where elemlet
property expansion is requested but the property is not defined. |
|
- Method resolution order:
- NullElemlet
- spug.web.htmlo.XNull
- spug.web.htmlo.HTMLElement
- spug.web.xmlo.Element
Methods defined here:
- __init__(self, request)
Methods inherited from spug.web.htmlo.HTMLElement:
- formatTo(self, output, indentContent=0, indent=2, xhtml=0)
- Overrides @spug.web.xml.Element.formatTo() to provide an XHTML
parameter.
parms:
output::
[file.write] output stream
indentContent::
[boolean] if true, multiline content is indented.
indent::
[int] number of characters to indent children
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
- populate(self, valueDict)
- Populates this element and all nested elements from the value
dictionary.
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
The value of the element is set using the @set() method. This
is what is generally overriden to vary the way control values are
defined.
- set(self, value)
- Sets the value of an element in the manner prescribed for the
element. This is really only relevant for form controls. The base
class version of this just sets the "value" attribute. Derived
classes should override as appropriate.
- writeTo(self, output, xhtml=0)
- Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
parms:
output::
[file.write]
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
Methods inherited from spug.web.xmlo.Element:
- __delitem__(self, accessor)
- __getitem__(self, accessor)
- Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
parms:
accessor::
[string or tuple<string, string> or int] If this is a string
or tuple, returns the associated attribute. If it is an
integer, returns the associated content item.
If this is a single string, returns the value of an attribute
in the global namespace. If it is a tuple of two strings,
the first string is a namespace URI.
If this is an integer, returns the value of a child element.
Interspersed text is ignored.
- __len__(self)
- Returns the number of content nodes in the element.
- __nonzero__(self)
- Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
- __setitem__(self, accessor, value)
- append(self, val)
- Appends a new element or text string to the contents of the element.
parms:
val::
[string or @Element]
- copy(self)
- Returns a deep copy of the element.
- deleteItem(self, index)
- Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#". However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
- get(self, attr, default=None)
- getActualNamespace(self)
- Returns the actual namespace of the element name. The "actual
namespace" is the specified namespace if there is one,
it is the default namespace if there was no specified namespace.
- getAllChildren(self)
- Returns all child elements (list<@Element>). This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
- getChild(self, namespace, name)
- Returns the first child with the given name. Returns None if no
such child exists.
parms:
namespace::
[string] namespace URI
name::
[string]
- getChildren(self, namespace, name)
- Returns all children with the given name.
parms:
namespace::
[string] namespace URI
name::
[name]
- getDefaultNamespace(self)
- Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
- getFullName(self)
- Returns the namespace and name of the of the element
(tuple<string, string>). Note that the namespace is the
/specified namespace/, not the /actual namespace/.
- getName(self)
- Returns the simple unqualified name of the element.
- getNamespace(self, prefix)
- Returns the namespace URI for the given prefix. Returns None
if no such prefix is defined.
parms:
prefix::
[string] namespace prefix
- getParent(self)
- Returns the parent object (actually, a proxy to the parent object),
*None* if there is no parent.
- getPrefix(self, uri)
- Returns the namespace prefix for the given URI. Returns
None if no prefix is found for this URI.
parms:
uri::
[string] namespace URI to find the prefix for
- getValue(self)
- Returns the value of the element as one big string. This will
raise a ValueError if the element contains nested child elements.
- hasChildren(self)
- Returns true if the element has child elements.
- hasContents(self)
- Returns true if the element has contents (children or character
data).
- has_key(self, attr)
- Returns true if the element has the given attribute.
parms:
attr::
[string or tuple<string, string>] attribute to check for.
- index(self, item)
- Returns the index of the item within the contents list (an integer).
parms:
item::
[string or @Element]
- insert(self, index, val)
- iterate(self, explorer)
- Selectively iterates over the tree using the given explorer in
a depth-first traversal.
parms:
explorer::
[callable<any>] This object will be called for the node.
The value it returns indicates how the iteration proceeds.
The following return values are allowed:
EXPAND::
Iterate over the children of the node.
CONTINUE::
Do not iterate over the children of the node, continue
iteration with the next node in the parent's child list.
ABORT::
Abort iteration.
- setName = __setName(self, name)
- Sets the full name of the element.
parms:
name::
[tuple<string, string> or string] Either an unqualified name or
a tuple of namespace URI and local name.
- setValue = __setValue(self, newValue)
- Deletes all current contens of the element, and replaces it with
the new value.
parms:
newValue::
[string]
- setdefault(self, attr, default)
- strip(self, stripContent=0)
- Strips all "unnecessary" whitespace from the element and all nested
elements. Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation,
this is usually just for formatting.
parms:
stripContent::
[boolean] if true, indicates that indentation of content
elements (nodes with no nested children
- stripEmptyContents(self)
- If the element contents consists of nothing but whitespace, deletes
all contents. Otherwise makes no changes to the element.
Returns true if contents were removed, false if not.
This can used to "clean out" whitespace content after removing a
child element.
Data and other attributes inherited from spug.web.xmlo.Element:
- ABORT = 3
- CONTINUE = 2
- EXPAND = 1
|
class NullNode(Node) |
|
This is the "Page not found" node.
Properties:
title::
[string] Page title. Defaults to "Page not found".
parcel::
[@spug.web.htmlo.HTMLElement] page contents. Defaults to
a message with /title/ as a level 1 header, followed by the text
"The requested URL does not exist.".
wrapper::
[@DocWrapper] the wrapper elemlet. |
|
Methods defined here:
- emitPage(self, request, response)
- getContentType(self, request)
- isStatic(self, request)
- Implements @Node.isStatic()
Always returns false, so we don't go littering the cache with pages
that were not found.
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getDependentsTimestamp(self, request)
- Returns the timestamp of the newest dependent (float).
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the
current page node.
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPage(self, request, response)
- Gets the content of the page identified in the request and
writes it into the response. If the request is for a static
page, the cache is refreshed and the response is written from the
cache. If not, @emitPage() is called directly and is expected
to write a page of content type specified by the @getContentType()
method.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class PNGNode(FileNode) |
|
Node to represent a PNG image. |
|
- Method resolution order:
- PNGNode
- FileNode
- Node
Methods defined here:
- getContentType(self, request)
Methods inherited from FileNode:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class ParentNode(Node) |
|
A node with named child nodes.
Properties:
wrapper::
[callable<@Request>] Factory to create the @DocWrapper for
the outer page. |
|
Methods defined here:
- __init__(self, **properties)
- addChild(self, name, node)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Overrides @Node.buildCache() to build children.
- deleteAllChildren(self)
- Deletes all children of the node.
- deleteChild(self, name)
- Removes a specific child. Raises a *KeyError* if the child does not
exist.
parms:
name::
[string] child name
- emitPage(self, request, response)
- getAllChildren(self)
- Returns an unordered list of child objects
(list<tuple<string, @Node>>).
- getCachePath(self, request)
- Overrides the @Node.getCachePath() to construct the cache path
from the name of a file within the directory.
- getChild(self, name)
- getDependentsTimestamp(self, request)
- getNodeAtPath(self, path, parentContext=None, name='')
- Overrides @Node.getNodeAtPath() to actually implement the recursive
path searching.
- getOrderedChildren(self)
- Returns a list of child names and objects (tuple<string, @Node>)
ordered by the "natural order" of the parent node. By default,
this is alphabetical.
- getPage(self, request, response)
- isStatic(self, request)
- setPageNode(self, node)
- Sets the "page node": @getPage() requests will be delegated
to this node if it has been defined.
*Deprecated* - use @setPagePath() instead.
- setPagePath(self, path)
- Sets the path that @getPage() requests will be delegated to - this
allows a ParentNode to display something other than the default
directory index.
Methods inherited from Node:
- __getitem__(self, property)
- __setitem__(self, property, val)
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class Path(__builtin__.list) |
|
Represents a URL path. Overrides *list* so that the string
representation is a slash separated path. |
|
- Method resolution order:
- Path
- __builtin__.list
- __builtin__.object
Methods defined here:
- __add__(self, other)
- __getitem__(self, key)
- Overrides slice access to return a @Path instance.
- __getslice__(self, start, end)
- __mul__(self, multiplier)
- __rmul__(self, multiplier)
- __str__(self)
- asAccessPath(self, request)
- Returns the "access path" (path used to access the resource
exterally, will add the appropriate extensions in static context) for
the "internal path" represented by *self*. Returns a @Path instance.
parms:
request::
[@Request]
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from __builtin__.list:
- __contains__(...)
- x.__contains__(y) <==> y in x
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __iadd__(...)
- x.__iadd__(y) <==> x+=y
- __imul__(...)
- x.__imul__(y) <==> x*=y
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __reversed__(...)
- L.__reversed__() -- return a reverse iterator over the list
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- append(...)
- L.append(object) -- append object to end
- count(...)
- L.count(value) -> integer -- return number of occurrences of value
- extend(...)
- L.extend(iterable) -- extend list by appending elements from the iterable
- index(...)
- L.index(value, [start, [stop]]) -> integer -- return first index of value
- insert(...)
- L.insert(index, object) -- insert object before index
- pop(...)
- L.pop([index]) -> item -- remove and return item at index (default last)
- remove(...)
- L.remove(value) -- remove first occurrence of value
- reverse(...)
- L.reverse() -- reverse *IN PLACE*
- sort(...)
- L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1
Data and other attributes inherited from __builtin__.list:
- __new__ = <built-in method __new__ of type object at 0x8144f60>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class ProtectedNode(Node) |
|
A node with access protection.
Each *ProtectedNode* has an associated implementation node, which
does all of the actual node display. The *ProtectedNode* simply
manages the access protection for the implementation node.
Properties:
imp::
[@Node] implementation node.
accessDenied::
[@Node] access denied node. Defaults to @NullNode.
privilege::
[string] privilege name. Defaults to "access".
accessManager::
[@AccessManager] object used to verify privilege. Defaults to
@NullAccessManager. |
|
Methods defined here:
- getPage(self, request, response)
- isStatic(self, request)
- Overrides @Node.isStatic(). Protected nodes can not be static.
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPage(self, request, response)
- Writes the page. Should not attempt to set content type or other
response headers on the response: this must be done in @getPage().
Must be implemented by derived classes.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getDependentsTimestamp(self, request)
- Returns the timestamp of the newest dependent (float).
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the
current page node.
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class PythonFunc(Node) |
|
A node that corresponds to a python function.
The function must accept three parameters:
manager::
[any] this parameter exists for backwards compatibility
and is passed in as *None*.
request::
[@Request]
response::
[@Response]
Properties:
func::
[callable<any, @Request, @Response>] python function to call. |
|
Methods defined here:
- getPage(self, request, response)
- Implements @Node.getPage()
- isStatic(self, request)
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPage(self, request, response)
- Writes the page. Should not attempt to set content type or other
response headers on the response: this must be done in @getPage().
Must be implemented by derived classes.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getDependentsTimestamp(self, request)
- Returns the timestamp of the newest dependent (float).
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the
current page node.
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class PythonScript(ParentNode) |
|
A node that corresponds to a python script. Child nodes are public
names (i.e. names not beginning with underscore) in the script's
namespace, unless a "spugwebIndex" variable is defined.
If the script has a "spugwebIndex" variable, it should be associated
with a dictionary (dict<string, object>) mapping the child name
to the node for that child. The child node may be either an
instance of a @Node derivative, or a callable object. If it is a
callable object it will be converted to a @PythonFunc instance.
If the script has a "spugwebPage" variable, it should be associated
with either a callable object or a @Node derivative. This variable
can be used to override the presentation of the node for the script.
It is important to note that spugwebPage does not affect child lookups:
If you specify a path to a child of the script, it will still
look in the spugwebIndex or global symbol table to resolve the child,
it will not delegate child lookup to the spugwebPage node.
Properties:
path::
[string] script path name. If this is a relative path, it
is relative to the current directory. |
|
- Method resolution order:
- PythonScript
- ParentNode
- Node
Methods defined here:
- __init__(self, **properties)
- getDependentsTimestamp(self, request)
- getPage(self, request, response)
- isStatic(self, request)
Methods inherited from ParentNode:
- addChild(self, name, node)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Overrides @Node.buildCache() to build children.
- deleteAllChildren(self)
- Deletes all children of the node.
- deleteChild(self, name)
- Removes a specific child. Raises a *KeyError* if the child does not
exist.
parms:
name::
[string] child name
- emitPage(self, request, response)
- getAllChildren(self)
- Returns an unordered list of child objects
(list<tuple<string, @Node>>).
- getCachePath(self, request)
- Overrides the @Node.getCachePath() to construct the cache path
from the name of a file within the directory.
- getChild(self, name)
- getNodeAtPath(self, path, parentContext=None, name='')
- Overrides @Node.getNodeAtPath() to actually implement the recursive
path searching.
- getOrderedChildren(self)
- Returns a list of child names and objects (tuple<string, @Node>)
ordered by the "natural order" of the parent node. By default,
this is alphabetical.
- setPageNode(self, node)
- Sets the "page node": @getPage() requests will be delegated
to this node if it has been defined.
*Deprecated* - use @setPagePath() instead.
- setPagePath(self, path)
- Sets the path that @getPage() requests will be delegated to - this
allows a ParentNode to display something other than the default
directory index.
Methods inherited from Node:
- __getitem__(self, property)
- __setitem__(self, property, val)
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getContentType(self, request)
- Returns the content type of the node. By default, this is
"text/html".
May be overriden by derived classes.
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class Request(spug.web.cgi.CGIRequest) |
|
Request object which adds the following to CGIRequest:
Public-vars:
context::
[@NodeContext] the node context
remainingPath::
[list<string>] path components not used to get to the node.
dynamicBaseURL::
[string] base URL for dynamic requests called in a static context.
staticContext::
[boolean] true if the request occurs in a static context (while
building the static page tree)
locals::
[dict<any, any>] local objects. This dictionary can be
used to store information that must be passed between different
methods processing the same request. |
|
Methods defined here:
- __init__(self, args, env, query, path, context, remainingPath, staticContext=0, dynamicBaseURL=None)
- deleteSession(self, sessionId)
- Delete the session indicated by the session id.
parms:
sessionId::
[string]
- getAbsolutePath(self, traveledPath, treeName=None)
- Returns a string consisting of the absolute path necessary to
obtain the given traveled path.
parms:
traveledPath::
[string] the path from the root of the spugweb tree to the
referenced node.
treeName::
[string or None] if this is not *None*, the traveled path
is relative to the "local root" of the given tree.
See @Node.setLocalRoot().
The special value '.cur' indicates that the root is the current
node. This is used for safely dereferencing a child across
static\/dynamic contexts.
- getAuthority(self)
- Returns the "authority" section of the current path - host name and
optionally port number.
- getHostIP(self)
- Returns the host IP address (string).
- getProperty(self, property, defaultValue=None)
- Returns the value of a property, performing all necessary transforms
on it.
The "raw value" of a property is the value of the property in the
/context/ object. If the raw value is a callable object, or an
instance of @NodeProperty, it is called (with the request instance
as its only parameter) and the return value will be returned as the
"actual value" of the property. Any non-callable raw value
is simply returned as the actual value.
parms:
property::
[string] property name
defaultValue::
[any] A default "raw value" of the attribute. If the attribute
is unassigned, this raw value is used and all of the transforms
are applied.
- getPropertyDependency(self, property, defaultValue=None)
- Returns a @Dependency wrapper around a property, allowing us to make
cached values dependent on properties.
If the raw value of a property is an instance of @Dependency, the raw
value is returned. Otherwise, a dependent is constructed from the
class of the property.
XXX we should also be considering the timestamp of the file where
the property was assigned, as this can certainly affect the value of
the property.
parms:
property: [string] property name
defaultValue: [@Dependency or None] The value returned if the
property is not found.
- getRequestURL(self)
- getRootNode(self)
- Returns the root node (@Node).
- getSession(self)
- Returns the current session object (an instance of @Session), or
*None* if it does not exist.
- getSessionId(self)
- Returns the session id (a string) or *None* if there is no
session id defined.
- getVirtualRequest(self, path, localRoot=None)
- Creates a virtual request derived from self. Returns a
@Request instance containing the virtual request.
A virtual request is used to obtain node values from within
the system.
parms:
path::
[string] URL path of the request (may or may not include
leading forward slash)
localRoot::
[string] local root name to base the path at.
- isDirectoryPath(self)
- Returns true if the full path is "a directory path" - i.e. if the
path ends with a forward slash ("`/`").
- newSession(self)
- Creates a new @Session instance and returns it.
Sets the following session keys by default:
hostIP::
[string] client IP address (used for later verification
to prevent session theft)
path::
[string] session cookie path (defaults to the "base path" so
that it applies to the entire spugweb instance).
- renewSession(self, response)
- If there is a session for the request and its "renewel time" has
expired, create a new session id and store it in the response.
- resolvePath(self, relativePath)
- Returns a new full path relative to the existing utilized path
(list<string>). This is useful for traversing between "facades" of
a node. Current directory ("."), parent directory ("..") and root
directory ("/") function as they would in a shell when referencing
a file system path.
For example:
If the utilized path is either "`/foo/bar`" or "`/foo/bar/`" and
/relativePath/ is "test", "#['foo', 'bar', 'test']#`" is returned.
If the utilized path is "`/foo/bar`" and the /relativePath/ is
"`../test`", "#['foo', 'test']#" is returned.
If /relativePath/ begins with a slash ("`/`"), /relativePath/ is
returned (converted to a list of strings).
parms:
relativePath::
[string] path segment to append to the utilized path.
Data descriptors defined here:
- fullPath
- traveledPath
- utilizedPath
|
class Response |
|
The response object - passed into @Node.getPage() methods to allow
a response to be written back to the client. |
|
Methods defined here:
- __init__(self, out)
- parms:
out::
[file.write] output stream that the response will be written
to.
- setContentType(self, contentType)
- setHeader(self, header, value)
- setSession(self, session)
- Sets the session cookie.
parms:
session::
[@Session]
- write(self, data)
- Writes data to the output stream (back to the client).
This will write headers if they have not already been written.
- writeHeaders(self)
- Writes the HTTP response headers. This will be done automatically
from @write() if it has not been done before the first write.
|
class Session(__builtin__.dict) |
|
Implemenation of a session. A session maps keys to values using the
dictionary interface |
|
- Method resolution order:
- Session
- __builtin__.dict
- __builtin__.object
Methods defined here:
- __init__(self, sessionId, expireInterval, renewInterval)
- expired(self)
- Returns true if the session is expired
- renew(self)
- Resets expireTime and renewalTime from the expiration and renewal
intervals.
Data descriptors defined here:
- expireInterval
- expireTime
- id
- renewInterval
- renewTime
Methods inherited from __builtin__.dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- D.__contains__(k) -> True if D has a key k, else False
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- clear(...)
- D.clear() -> None. Remove all items from D.
- copy(...)
- D.copy() -> a shallow copy of D
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
- items(...)
- D.items() -> list of D's (key, value) pairs, as 2-tuples
- iteritems(...)
- D.iteritems() -> an iterator over the (key, value) items of D
- iterkeys(...)
- D.iterkeys() -> an iterator over the keys of D
- itervalues(...)
- D.itervalues() -> an iterator over the values of D
- keys(...)
- D.keys() -> list of D's keys
- pop(...)
- D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem(...)
- D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
- setdefault(...)
- D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(...)
- D.update(E, **F) -> None. Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
- values(...)
- D.values() -> list of D's values
Data and other attributes inherited from __builtin__.dict:
- __new__ = <built-in method __new__ of type object at 0x8146020>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
- fromkeys = <built-in method fromkeys of type object at 0x82fea6c>
- dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
|
class SessionManager |
|
Manages all of the known sessions and keeps track of their expiration. |
|
Methods defined here:
- __delitem__(self, sessionId)
- Used to delete a session.
- __init__(self)
- get(self, sessionId)
- Returns the given session or *None* if the session key is either
undefined or expired.
- newSession(self, expireInterval, renewInterval=-1)
- Creates and stores a new session object. Returns the @Session
instance.
parms:
liveInterval::
[float] session "time to live" in seconds.
renewInterval::
[float] session "time before renewal" in seconds. If -1,
66% of /liveInterval/ is used.
- renew(self, session)
- Renews the session by creating a new session key for it and changing
the expiration and renewal times.
|
class TextNode(FileNode) |
|
Node to represent a plain text file. |
|
- Method resolution order:
- TextNode
- FileNode
- Node
Methods defined here:
- getContentType(self, request)
Methods inherited from FileNode:
- emitPage(self, request, response)
- Even though we implement @getPage(), we have to also implement
@emitPage() so that we can generate a cache entry.
- getDependentsTimestamp(self, request)
- Implements @Node.getDependentsTimestamp() to return the timestamp
of the source file.
- getPage(self, request, response)
- isStatic(self, request)
- Implements @Node.isStatic()
Methods inherited from Node:
- __getitem__(self, property)
- __init__(self, **properties)
- __setitem__(self, property, val)
- buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
- Recursive function to build the cache for the node and its
descendents.
parms:
context::
[@NodeContext] node invocation context.
targetBaseURL::
[string] base URL of the target location. This will be the
base of all absolute URLs used to refer to other static pages
within the tree. You need not specify the full URL: the
path portion (starting from the first slash after host name
and optional port number) is normally adequate.
dynamicBaseURL::
[string or None] base URL of all dynamic web pages in the tree.
This will be the base of all absolute URLs referred to by
static pages. If *None*, attempting to link to a dynamic
node from a static node will cause an error.
- emitPageInContext(self, request, response)
- This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
- fixExtension(self, request, pathName)
- Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
- getCachePath(self, request)
- Returns the cache path for the node. By default this is constructed
from the cache path for the node with the extension for its content
type appended.
May be overriden by derived classes.
- getNodeAtPath(self, path, parentContext=None, name='')
- Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info
(tuple<@Node, @NodeContext, string>).
parms:
path::
[string] full path
parentContext::
[@NodeContext] the parent's context
name::
[string] the name that the node was referenced under (part of
the path)
- getPageInContext(self, request, response)
- Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
- getSourcePath(self)
- Returns the node's "source path". This is not context dependent.
- has_key(self, property)
- isLocalRoot(self, treeName)
- Returns true if the node is the local root for the given tree name.
parms:
treeName::
[string] tree to check for. A value of '.cur' always
returns true.
- load(self)
- "Loads" the node - this causes the node object to be fully
initialized. A node must be loaded prior to performing any other
operations on it.
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
Derived classes should not override this: override @_load() instead.
- refreshCache(self, request, cachePath)
- Refreshes the cached image of a cacheable node. If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
parms:
request::
[@Request]
cachePath::
[string] cache file name
- setLocalRoot(self, treeName)
- This method defines a node as a "local root". Local roots allow
URLs to be constructed relative to a known base. A local root
parameter can be specified in @Request.getAbsolutePath().
parms:
treeName::
[string] tree that the node is a local root for. Values
beginning with '.' are reserved and _should not be used_.
|
class XMLDocWrapper(XMLElemlet) |
|
Document wrapper generated from an XML source file. |
|
- Method resolution order:
- XMLDocWrapper
- XMLElemlet
- spug.web.htmlo.XNull
- spug.web.htmlo.HTMLElement
- spug.web.xmlo.Element
Methods defined here:
- __init__(self, request, doc, dep)
- parms:
request::
[@Request]
doc::
[@spug.web.xml.Element] document root. If not provided,
the document is obtained from the xmldocwrapper.file
dep::
[@Dependency] A dependent object for the document source.
- getDependentsTimestamp(self, request)
- setParcel(self, parcel)
- setTitle(self, title)
Data and other attributes defined here:
- NodeSlot = <class web.wof.NodeSlot at 0x82b129c>
- Seeker = <class web.wof.Seeker at 0x82b12cc>
Methods inherited from spug.web.htmlo.HTMLElement:
- formatTo(self, output, indentContent=0, indent=2, xhtml=0)
- Overrides @spug.web.xml.Element.formatTo() to provide an XHTML
parameter.
parms:
output::
[file.write] output stream
indentContent::
[boolean] if true, multiline content is indented.
indent::
[int] number of characters to indent children
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
- populate(self, valueDict)
- Populates this element and all nested elements from the value
dictionary.
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
The value of the element is set using the @set() method. This
is what is generally overriden to vary the way control values are
defined.
- set(self, value)
- Sets the value of an element in the manner prescribed for the
element. This is really only relevant for form controls. The base
class version of this just sets the "value" attribute. Derived
classes should override as appropriate.
- writeTo(self, output, xhtml=0)
- Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
parms:
output::
[file.write]
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
Methods inherited from spug.web.xmlo.Element:
- __delitem__(self, accessor)
- __getitem__(self, accessor)
- Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
parms:
accessor::
[string or tuple<string, string> or int] If this is a string
or tuple, returns the associated attribute. If it is an
integer, returns the associated content item.
If this is a single string, returns the value of an attribute
in the global namespace. If it is a tuple of two strings,
the first string is a namespace URI.
If this is an integer, returns the value of a child element.
Interspersed text is ignored.
- __len__(self)
- Returns the number of content nodes in the element.
- __nonzero__(self)
- Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
- __setitem__(self, accessor, value)
- append(self, val)
- Appends a new element or text string to the contents of the element.
parms:
val::
[string or @Element]
- copy(self)
- Returns a deep copy of the element.
- deleteItem(self, index)
- Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#". However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
- get(self, attr, default=None)
- getActualNamespace(self)
- Returns the actual namespace of the element name. The "actual
namespace" is the specified namespace if there is one,
it is the default namespace if there was no specified namespace.
- getAllChildren(self)
- Returns all child elements (list<@Element>). This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
- getChild(self, namespace, name)
- Returns the first child with the given name. Returns None if no
such child exists.
parms:
namespace::
[string] namespace URI
name::
[string]
- getChildren(self, namespace, name)
- Returns all children with the given name.
parms:
namespace::
[string] namespace URI
name::
[name]
- getDefaultNamespace(self)
- Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
- getFullName(self)
- Returns the namespace and name of the of the element
(tuple<string, string>). Note that the namespace is the
/specified namespace/, not the /actual namespace/.
- getName(self)
- Returns the simple unqualified name of the element.
- getNamespace(self, prefix)
- Returns the namespace URI for the given prefix. Returns None
if no such prefix is defined.
parms:
prefix::
[string] namespace prefix
- getParent(self)
- Returns the parent object (actually, a proxy to the parent object),
*None* if there is no parent.
- getPrefix(self, uri)
- Returns the namespace prefix for the given URI. Returns
None if no prefix is found for this URI.
parms:
uri::
[string] namespace URI to find the prefix for
- getValue(self)
- Returns the value of the element as one big string. This will
raise a ValueError if the element contains nested child elements.
- hasChildren(self)
- Returns true if the element has child elements.
- hasContents(self)
- Returns true if the element has contents (children or character
data).
- has_key(self, attr)
- Returns true if the element has the given attribute.
parms:
attr::
[string or tuple<string, string>] attribute to check for.
- index(self, item)
- Returns the index of the item within the contents list (an integer).
parms:
item::
[string or @Element]
- insert(self, index, val)
- iterate(self, explorer)
- Selectively iterates over the tree using the given explorer in
a depth-first traversal.
parms:
explorer::
[callable<any>] This object will be called for the node.
The value it returns indicates how the iteration proceeds.
The following return values are allowed:
EXPAND::
Iterate over the children of the node.
CONTINUE::
Do not iterate over the children of the node, continue
iteration with the next node in the parent's child list.
ABORT::
Abort iteration.
- setName = __setName(self, name)
- Sets the full name of the element.
parms:
name::
[tuple<string, string> or string] Either an unqualified name or
a tuple of namespace URI and local name.
- setValue = __setValue(self, newValue)
- Deletes all current contens of the element, and replaces it with
the new value.
parms:
newValue::
[string]
- setdefault(self, attr, default)
- strip(self, stripContent=0)
- Strips all "unnecessary" whitespace from the element and all nested
elements. Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation,
this is usually just for formatting.
parms:
stripContent::
[boolean] if true, indicates that indentation of content
elements (nodes with no nested children
- stripEmptyContents(self)
- If the element contents consists of nothing but whitespace, deletes
all contents. Otherwise makes no changes to the element.
Returns true if contents were removed, false if not.
This can used to "clean out" whitespace content after removing a
child element.
Data and other attributes inherited from spug.web.xmlo.Element:
- ABORT = 3
- CONTINUE = 2
- EXPAND = 1
|
class XMLElemlet(spug.web.htmlo.XNull) |
|
An elemlet constructed from an XML document. The source file
should be a document in the XHTML namespace containing a single
"content" node and zero or more "title" nodes (both in the spugweb
namespace).
Properties:
xmldocwrapper.file::
Source file for the XML wrapper page. |
|
- Method resolution order:
- XMLElemlet
- spug.web.htmlo.XNull
- spug.web.htmlo.HTMLElement
- spug.web.xmlo.Element
Methods defined here:
- __init__(self, request, doc=None, seeker=None)
- parms:
request::
[@Request]
doc::
[@spug.web.xml.Element] document root. If not provided,
the document is obtained from the xmldocwrapper.file
Data and other attributes defined here:
- Seeker = <class web.wof.Seeker at 0x82b120c>
Methods inherited from spug.web.htmlo.HTMLElement:
- formatTo(self, output, indentContent=0, indent=2, xhtml=0)
- Overrides @spug.web.xml.Element.formatTo() to provide an XHTML
parameter.
parms:
output::
[file.write] output stream
indentContent::
[boolean] if true, multiline content is indented.
indent::
[int] number of characters to indent children
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
- populate(self, valueDict)
- Populates this element and all nested elements from the value
dictionary.
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
The value of the element is set using the @set() method. This
is what is generally overriden to vary the way control values are
defined.
- set(self, value)
- Sets the value of an element in the manner prescribed for the
element. This is really only relevant for form controls. The base
class version of this just sets the "value" attribute. Derived
classes should override as appropriate.
- writeTo(self, output, xhtml=0)
- Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
parms:
output::
[file.write]
xhtml::
[boolean] if true, node and contents will be written in
XHTML instead of normal HTML.
Methods inherited from spug.web.xmlo.Element:
- __delitem__(self, accessor)
- __getitem__(self, accessor)
- Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
parms:
accessor::
[string or tuple<string, string> or int] If this is a string
or tuple, returns the associated attribute. If it is an
integer, returns the associated content item.
If this is a single string, returns the value of an attribute
in the global namespace. If it is a tuple of two strings,
the first string is a namespace URI.
If this is an integer, returns the value of a child element.
Interspersed text is ignored.
- __len__(self)
- Returns the number of content nodes in the element.
- __nonzero__(self)
- Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
- __setitem__(self, accessor, value)
- append(self, val)
- Appends a new element or text string to the contents of the element.
parms:
val::
[string or @Element]
- copy(self)
- Returns a deep copy of the element.
- deleteItem(self, index)
- Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#". However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
- get(self, attr, default=None)
- getActualNamespace(self)
- Returns the actual namespace of the element name. The "actual
namespace" is the specified namespace if there is one,
it is the default namespace if there was no specified namespace.
- getAllChildren(self)
- Returns all child elements (list<@Element>). This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
- getChild(self, namespace, name)
- Returns the first child with the given name. Returns None if no
such child exists.
parms:
namespace::
[string] namespace URI
name::
[string]
- getChildren(self, namespace, name)
- Returns all children with the given name.
parms:
namespace::
[string] namespace URI
name::
[name]
- getDefaultNamespace(self)
- Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
- getFullName(self)
- Returns the namespace and name of the of the element
(tuple<string, string>). Note that the namespace is the
/specified namespace/, not the /actual namespace/.
- getName(self)
- Returns the simple unqualified name of the element.
- getNamespace(self, prefix)
- Returns the namespace URI for the given prefix. Returns None
if no such prefix is defined.
parms:
prefix::
[string] namespace prefix
- getParent(self)
- Returns the parent object (actually, a proxy to the parent object),
*None* if there is no parent.
- getPrefix(self, uri)
- Returns the namespace prefix for the given URI. Returns
None if no prefix is found for this URI.
parms:
uri::
[string] namespace URI to find the prefix for
- getValue(self)
- Returns the value of the element as one big string. This will
raise a ValueError if the element contains nested child elements.
- hasChildren(self)
- Returns true if the element has child elements.
- hasContents(self)
- Returns true if the element has contents (children or character
data).
- has_key(self, attr)
- Returns true if the element has the given attribute.
parms:
attr::
[string or tuple<string, string>] attribute to check for.
- index(self, item)
- Returns the index of the item within the contents list (an integer).
parms:
item::
[string or @Element]
- insert(self, index, val)
- iterate(self, explorer)
- Selectively iterates over the tree using the given explorer in
a depth-first traversal.
parms:
explorer::
[callable<any>] This object will be called for the node.
The value it returns indicates how the iteration proceeds.
The following return values are allowed:
EXPAND::
Iterate over the children of the node.
CONTINUE::
Do not iterate over the children of the node, continue
iteration with the next node in the parent's child list.
ABORT::
Abort iteration.
- setName = __setName(self, name)
- Sets the full name of the element.
parms:
name::
[tuple<string, string> or string] Either an unqualified name or
a tuple of namespace URI and local name.
- setValue = __setValue(self, newValue)
- Deletes all current contens of the element, and replaces it with
the new value.
parms:
newValue::
[string]
- setdefault(self, attr, default)
- strip(self, stripContent=0)
- Strips all "unnecessary" whitespace from the element and all nested
elements. Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation,
this is usually just for formatting.
parms:
stripContent::
[boolean] if true, indicates that indentation of content
elements (nodes with no nested children
- stripEmptyContents(self)
- If the element contents consists of nothing but whitespace, deletes
all contents. Otherwise makes no changes to the element.
Returns true if contents were removed, false if not.
This can used to "clean out" whitespace content after removing a
child element.
Data and other attributes inherited from spug.web.xmlo.Element:
- ABORT = 3
- CONTINUE = 2
- EXPAND = 1
|
class XMLElemletFactory(Dependency) |
|
Factory to create an @XMLElemlet instance, allowing the document
to be parsed only once. |
|
Methods defined here:
- __call__(self, request)
- __init__(self, source)
- parms:
source::
[string or @spug.web.xmlo.Element] If this is the string,
it is the name of an XML or CXML file to load. If it is
an Element, it is the actual document object.
- getTimestamp(self, request)
| |