Site

class dasha.core.Site[source]

Bases: tollan.utils.namespace.Namespace

This class manages the context of a DashA site, composed of a server and a set of extensions.

It shall be constructed via the from_* class methods. Two objects are expected:

  1. “server”. This shall be a function that returns the server instance.

    This function optionally may take the site instance as the only argument.

  2. “extensions”. The shall be a list of items that an

    Extension object could be created from.

Attributes Summary

logger

Methods Summary

from_any(arg)

Create a site from arg.

from_dict(d, \*\*kwargs)

Construct a Namespace instance from dict.

from_filepath(filepath)

Create a site from a python source file.

from_object(arg)

Create a site from an object that contains the site configurations.

init_app(self)

Initialize server and the extensions.

Attributes Documentation

logger = <Logger Site (INFO)>

Methods Documentation

classmethod from_any(arg)[source]

Create a site from arg.

It checks the value of arg and dispatches to the most probable from_* factory method.

classmethod from_dict(d, \*\*kwargs)[source]

Construct a Namespace instance from dict.

This is different from object_from_dict in that it uses the class attributes as the defaults, thus could behave differently if called from subclasses.

Note

The class attribute settings may be overriden by the content of d and kwargs.

Parameters
*args

A list of dicts.

**kwargs

Additional keyword arguments that get updated to the dict.

classmethod from_filepath(filepath)[source]

Create a site from a python source file.

Parameters
filepathstr or Path

The path of the python source file to use.

Returns
Site

A Site instance.

classmethod from_object(arg)[source]

Create a site from an object that contains the site configurations.

Parameters
argobject or str

The object to use. If str, getobj is used to import the object.

Returns
Site

A Site instance.

init_app(self)[source]

Initialize server and the extensions.

This will instantiates the extensions and call the init_app methods of them.

Note

server will be replaced with the actual server instance after this call.