mewlo.mpacks.core.site.msite module

msite.py This file contains classes to handle Mewlo site class.

class mewlo.mpacks.core.site.msite.MewloSite(sitemodulename, debugmode, commandlineargs=None, defaultconfigname=None)[source]

Bases: object

The MewloSite class represents a single “site” that handles requests. Typically you will only have one site running.

absolute_filepath(relpath)[source]
absolute_url(relpath)[source]
add_addons()[source]

Does nothing in base class, but subclass can overide.

add_default_settings_aliases()[source]

Set default alias settings.

add_default_settings_config()[source]

Set default config settings.

add_earlydefault_settings()[source]

Set some default overrideable settings.

add_fallback_loggers()[source]

Create any default fallback loggers that we should always put in place.

add_latedefault_aliases()[source]

Add some late aliases.

add_latesettings_aliases()[source]

Add some late aliases.

add_latesettings_assets()[source]

Does nothing in base class, but subclass can overide.

add_logger(logger)[source]

Just ask the logmanager to add the logger.

add_loggers()[source]

Does nothing in base class, but subclass can overide.

add_navnodes()[source]

Does nothing in base class, but subclass can overide.

add_routes()[source]

Does nothing in base class, but subclass can overide.

add_settings_early()[source]

Does nothing in base class, but subclass can overide.

alias_settings_change()[source]

Inform asset manager of new alias settings. This must be called whenever alias settings may change.

appendcomp(componentname, component)[source]

Shortcut to append an already created component.

build_routeurl_byid(routeid, flag_relative, args)[source]

Build a url to a route with some optional args.

comp(componentname)[source]

Shortcut to look up a component.

create_allcomponents()[source]

Create all the various components we uses.

createappendcomp(componentname, componentclass, *args, **kwargs)[source]

Shortcut to create and then append a component by class.

does_request_match_siteprefix(request)[source]

See if the request matches the prefix for this site (which could be blank).

dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

get_allpack_events()[source]

Get combined eventlist (report on update checking, etc.) for all packs on sites

get_commandlinearg(keyname, defaultval=None)[source]

Get commandline arg or use default.

get_configval(keyname, defaultval=None)[source]

Get a value from the appropriate config file.

get_controllerroot()[source]

Simple accessor.

get_debugmode()[source]

Return the debubmode.

get_id()[source]

The get_id() function is a generic one that we use in several places where we have a hierarchy of objects (for example routegroups). Introspection will cause it to be used when displaying debug information.

get_installdir()[source]

Get the directory path of the mewlo installation from the mewlo pack.

get_isenabled()[source]

Simple accessor for isenabled flag.

get_pkgdirimp_config()[source]
get_pkgdirimp_dotpathprefix_site()[source]

Return import of ourself; useful for relative importing.

get_root_pack_directory_list()[source]

Return a list of directories in the base/install path of Mewlo, where addon packs should be scanned

get_settingsection(sectionname)[source]

Return a settings value.

get_settingval(sectionname, valuename, defaultval=None)[source]

Return a settings value.

get_site_pack_directory_list()[source]

Return a list of absolute directory paths where (addon) packs should be scanned

get_sitemodulename()[source]

Return import of ourself; useful for relative importing.

get_sitename()[source]

Simple accessor.

get_siteprefix()[source]

Simple accessor for site prefix (defines a prefix for the url of the site).

is_readytoserve()[source]

Check if there were any site prep errors, OR if any packs report they are not ready to run (need update, etc.).

logevent(event, request=None, fields={})[source]

Shortcut to add a log message from an event/failure.

logevents(events, request=None)[source]

Shortcut to add a log message from a possible iterable of events.

merge_settings(settings)[source]

Merge in some settings to our site settings.

post_runroute_callable(request)[source]

Called after a route is invoked. :return: failure on error

pre_runroute_callable(route, request)[source]

Called after a route is matched, but before it is invoked. :return: failure on error

preprocess_settings(eventlist)[source]

This function is used to preprocess/cache some settings before we start. This function is called early in the startup() function.

process_mewloexception_web_response(request, exp)[source]

A MewloWeb exception was thrown by controller – we can generate a page in response to this.

process_request(request)[source]

Run the request through the routes and handle it if it matches any. :return: True if the request is for this site and we have set request.response

process_request_ends(request, ishandled)[source]

Do stuff before processing a request

process_request_starts(request)[source]

Do stuff before processing a request

relative_url(relpath)[source]
rendersections_from_template(template, args=None, required_sections=[])[source]

Shortcut to return dictionary of html for a template and set responsedata from it, passing response object to template as an extra arg.

rendersections_from_template_file(templatefilepath, args=None, required_sections=[])[source]

Shortcut to render a template and set responsedata from it, passing response object to template as an extra arg.

renderstr_from_template(template, args=None)[source]

Shortcut to return html for a template and set responsedata from it, passing response object to template as an extra arg.

renderstr_from_template_file(templatefilepath, args=None)[source]

Shortcut to render a template and set responsedata from it, passing response object to template as an extra arg.

renderstr_from_template_string(templatestring, args=None)[source]

Shortcut to render a template and set responsedata from it, passing response object to template as an extra arg.

resolve(text)[source]
resolve_filepath(text)[source]
run_allconfigfuncs(functionname, *args, **kwargs)[source]

Run func in the appropriate config file(s).

run_configfunc(functionname, *args, **kwargs)[source]

Run func in the appropriate config file(s).

set_debugmode(val)[source]

Set debugmode for the site, which may also have to pass on this value to components.

set_sitemanager(sitemanager)[source]

Set sitemanager reference.

set_statelabel(statelabel)[source]

For debugging we keep track of startup state progression.

setup_confighelper()[source]

The DEFAULT configname should have been set .

setup_early()[source]

Do early setup stuff. Most of the functions invoked here are empty and are intended for subclasses to override. This function is called by MewloSiteManager, right after site object is instantiated, before startup()

shutdown(eventlist=None)[source]

Shutdown everything.

shutdown_allcomponents()[source]

Shutdown all of our site components, in REVERSE order.

startup(eventlist=None)[source]

Do preparatory stuff after settings have been set. It is critical that this function get called prior to running the system.

startup_prep(stageid, eventlist)[source]

Startup prep.

startup_prep_allcomponents(eventlist)[source]

Loop through all startup stages and invoke all components (and ourself).

updatecheck()[source]

Check all packs for updates. The packs themselves will store details about update check results. Note this covers not just web updates available, but database updates needed.

updaterun()[source]

Check all packs for updates. The packs themselves will store details about update check results. Note this covers not just web updates available, but database updates needed.

validate_setting_config(eventlist, varname, iserror, messagestr)[source]

Helper function for the validate() method.

validatesettings(eventlist=None)[source]

Validate settings and return an EventList with errors and warnings. This function is called early in the startup() function, after preprocess_settings().