Open source cms for mobile and desktop websites

nive.application

This file contains the main application functionality. The application handles configuration registration, roots and the database. Also it provides convenient functions to lookup all different kinds of configurations.

Application.modules stores configuration objects registered by calling Register().

See Application.Startup() for the main entry point and connected events.

Not to be mixed up with pyramid applications or projects. It is possible to use multiple nive applications in a single pyramid app.

class nive.application.Application(configuration=None)

nive Application implementaion.

SQLite example:

appConf = AppConf(id="website", 
                  title="nive app")
dbConf = DatabaseConf(context="Sqlite3", 
                      fileRoot="data", 
                      dbName="data/ewp.db")
appConf.modules.append(dbConf)

MySql example:

appConf = AppConf(id="website", 
                  title="nive app")
dbConf = DatabaseConf(context="MySql", 
                      fileRoot="data", 
                      dbName="nive",
                      host="localhost",
                      user="user",
                      password="password")
appConf.modules.append(dbConf)

Requires (Configuration, Registration, AppFactory, Events.Events)

The startup process is handled by nive.portal.portal on application startup. During startup the system fires four events in the following order:

  • startup(app)
  • startRegistration(app, pyramidConfig)
  • finishRegistration(app, pyramidConfig)
  • run(app)

All acl definitions are mapped to self.__acl__.

ViewModuleConf.acl values are added first, AppConf.acl are appended to the end of the list. This might make it hard to replace single permissions defined by view modules because pyramid uses the first matching definition in the list.

To disable any view module acl definitions or replace single permissions use the FinishRegistration event and post process acls as needed.

Setup(debug=False)

Called by nive.portal.portal on application startup. Sets up the registry.

Events:

  • startup(app)
StartRegistration(pyramidConfig)

Processes all registered components and commits view definitions to the pyramid application configuration.

Events:

  • startRegistration(app, pyramidConfig)
FinishRegistration(pyramidConfig, cachedDbConnection=None)

Finishes the registration process and cashes the database structure. Configurations will have a write lock after the registration is finished.

cachedDbConnection is a nive.utils.dataPool2.connection instance to avoid reconnects on application startup. The connection can be accessed during runtime through self.db.usedconnection.

Events:

  • finishRegistration(app, pyramidConfig)
Run()

Signals the application is up and running.

Events:

  • run(app)
Close()

Close database and roots.

Events:

  • close()
root(name='')

Events: - loadRoot(root) - loadFromCache() called for the root

returns root object

obj(id, rootname='', **kw)

returns object

db

returns datapool object

portal

returns the portal

app

returns itself. for compatibility.

GetRoot(name='')

Returns the data root object. If name is empty the default root is returned.

Events: - loadRoot(root) - loadFromCache() called for the root

returns root object

GetRoots()

Returns all root objects.

returns list

GetTool(toolID, contextObject=None)

Load tool object. toolID must be the tool.id or dotted python name.

returns the tool object.

GetWorkflow(wfProcID, contextObject=None)

Load workflow process. wfProcID must be the wf.id or dotted python name.

returns the workflow object

GetDB()

Create data pool object and database connection.

returns the datapool object

Query(sql, values=())

Start a sql query on the database.

returns tuple or none

TestDB()

Test database connection for errors. Returns state and error message.

returns bool, message

NewConnection()

Creates a new database connection. Works before startup and application setup.

NewDBApi()

Creates a raw database connection (dbapi). Works before startup and application setup.

GetVersion()
CheckVersion()
LookupObj(id, rootname='', **kw)

use obj() instead

class nive.application.Configuration

Read access functions for root, type, type field, meta field and category configurations.

Requires: - nive.nive

QueryConf(queryFor, context=None)

Returns a list of configurations or empty list

QueryConfByName(queryFor, name, context=None)

Returns configuration or None

Factory(queryFor, name, context=None)

Query for configuration and lookup class reference. Does not call __init__ for the new class.

returns class or None

GetRootConf(name='')

Get the root object configuration. If name is empty, the default name is used.

returns dict or None

GetAllRootConfs()

Get all root object configurations as list.

returns list

GetRootIds()

Get all root object ids.

returns list

GetDefaultRootName()

Returns the name of the default root.

returns string

GetObjectConf(typeID, skipRoot=False)

Get the type configuration for typeID. If type is not found root definitions are searched as well.

returns configuration or none

GetAllObjectConfs(visibleOnly=False)

Get all type configurations.

returns list

GetTypeName(typeID)

Get the object type name for the id.

returns string

GetFld(fldID, typeID=None)

Get type or meta field definition. Type fields have the priority if typeID is not None.

returns configuration or None

GetFldName(fldID, typeID=None)

Get type or meta field name. Type fields have the priority if typeID is not None.

returns string

GetObjectFld(fldID, typeID)

Returns object field configuration.

returns configuration or None

GetAllObjectFlds(typeID)

Get all object field configurations.

returns list or None

GetMetaFld(fldID)

Get meta field configuration

returns configuration or None

GetAllMetaFlds(ignoreSystem=True)

Get all meta field configurations.

returns list

GetMetaFldName(fldID)

Get meta field name for id.

returns string

GetToolConf(toolID, contextObject=None)

Get the tool configuration.

returns configuration or None

GetAllToolConfs(contextObject=None)

Get all tool configurations.

returns list

GetCategory(categoryID='')

Get category configuration.

returns configuration or None

GetAllCategories(sort=u'name', visibleOnly=False)

Get all category configurations.

returns list

GetCategoryName(categoryID)

Get category name for id.

returns string

GetGroups(sort=u'name', visibleOnly=False)

Get a list of configured groups.

returns list

GetGroupName(groupID)

Get group name for id.

returns string

GetWorkflowConf(processID, contextObject=None)

Get the workflow process configuration.

returns configuration or None

GetAllWorkflowConfs(contextObject=None)

Get all workflow configurations.

returns list

StoreSysValue(key, value)

Stores a value in pool_sys table. Value must be a string of any size.

LoadSysValue(key)

Loads the value stored as key from pool_sys table.

DeleteSysValue(key)

Deletes a single system value

class nive.application.AppFactory

Internal class for dynamic object creation and caching.

Requires: - Application

© 2013 Nive GmbH