Open source cms for mobile and desktop websites

nive.definitions

Using configuration classes

The predefined configuration classes are meant to handle the different cms modules and parts. Empty configurations are already filled with default values for convenience. Also configuration classes provide functions for easy copying and changing.

You have to use one of these to extend or change anything in the application.

Each configuration class can be used with python dictionary or attribute notation to set or get values.

Values can be defined in python files as

baseConf(id='test',name='test')

or

c = baseConf()
c.id = 'test'
c.name = 'test'

or dictionary syntax:

baseConf(**{'id':'test','name':'test'})
c["id"]
c.get("id")
c.update(values)
c.keys()
c.copy()

Alternatively configurations can be defined outside python code as json files. The specific configuration class is mapped from the type value

{
    "type":    "ObjectConf",
    "copyFrom":"my_app.app",
    "id":      "my_object",
    "name":    "My Object",
    "dbparam": "my_object",
    "context": "website.my_object",
    ...
}

Json files are distinguished by their file extension ”.json” from python dotted path names. You can manually load json files by calling nive.helper.LoadConfiguration(filename).

nive.helper.LoadConfiguration("my_object.json")

To copy and customize existing configurations call the constructor with the configuration to be copied as first non-keyword parameter:

a = baseConf(id='test',name='test')
b = baseConf(a, id='test2')

or

cms = AppConf("my_app.app", id="my_website", ...)

Json: add “copyFrom”

{
    "type":    "AppConf",
    "copyFrom":"my_app.app",
    "id":      "my_website",
    ...
}    

Configurations

class nive.definitions.Conf(copyFrom=None, **values)

Configuration class with no predefined fields

Interface: IConf

class nive.definitions.FieldConf(copyFrom=None, **values)

Definition of a field used for object.data, object.meta, form.field and tool.data

Values

*id :       Unique field id as ascii string with maximum 25 chars. Used as column name
            in database tables.
*datatype : Datatype of the field based on nive.definitions.DataTypes.
size :      Field size of stored data. Depends on datatype. 
default :   Default value.
listItems : Used for list and checkbox types. Contains items with id and name 
            definitions [{"id": "id1", "name": "name1"},...].
            If listItems is a callable the callback must take two arguments:
            callback(fieldconf, object) and return a list with id and name items.
settings :  Extended settings for fields. Possible values depend on datatype.
unique   :  The field value has to be unique on database level.
fulltext :  Use this field in fulltext index.

Extended values (optional and used as default for forms)

name :        Display name. 
description : Description.
required :    Form input is required.
readonly :    This field is not included in forms.
hidden :      This field is rendered as hidden field in forms.
len :         Depends on datatype. 
node :        Form field object for rendering and validation (colander schema node).
validator :   Form field validator callback.
widget :      Form widget rendered in HTML forms.

Call FieldConf().test() to verify configuration values.

Data field types

The types define the data field format (like string or number), widget and internal handling. Use these for FieldConf.datatypes.

id Name
string String
number Number
float Float
bool Bool
htext HTML Text
text Text
code HTML / Javascript / CSS
json Json
file File
date Date
datetime Datetime
list List
radio Radio Selection
multilist Multiple Selection
checkbox Multiple Checkboxes
lines Lines
email E-Mail
url URL
urllist URL List
password Password
unit ID Reference
unitlist ID Reference List
timestamp Timestamp

Interface: IFieldConf

class nive.definitions.AppConf(copyFrom=None, **values)

Application configuration class. Contains all configurable options for the cms (nive.Application).

Values

*id :          Ascii used as name in url traversal.
*context :     Dotted python name or class reference used as factory.
title :        Application title (optional).
description :  Application description (optional).
    
# extensions
extensions:List of dotted python names or class references to extend context with
           additional functionality. Used in object factory.
meta :    Meta layer definition of custom and system fields.
modules : List of included configurations. Calls nive.Registration.Include for 
          each module on startup. 
          Refer to helper.ResolveConfiguration for possible values. 
categories : list of categories {'id': 'the id', 'name': 'the name'}.
listDefault: list of meta field names to be used as default list fields in
             database query results.

# security
groups : List of Definitions.GroupConf with groups used in this application.
acl :    List of pyramid acls for permission settings.
    
# options
fulltextIndex :    Enable fulltext index based on FieldConf.fulltext setting.
autocommit :       Enable autocommit for object write and delete operations.
useCache :         Cache database on application level.
frontendCodepage : Default=utf-8. The codepage used to render the html frontend.
workflowEnabled :  Enable or disable the workflow engine.
events  : Register for one or multiple Application events. 
          Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 

Call AppConf().test() to verify configuration values.

Version 0.9.12 update:

All meta fields are now included in the application configuration, including custom definitions and system fields. The list stored as self.meta has been empty in previous versions and all fields have been added automatically on application startup. From version 0.9.12 on all meta fields are stored in the AppConf instance.

Interface: IAppConf

class nive.definitions.DatabaseConf(copyFrom=None, **values)

Database configuration

*context : Database type to be used. supports "Sqlite3" and "MySql" by default. 
           MySql requires python-mysqldb installed.
*dbName  : sqlite3=database file path, mysql=database name 
fileRoot : Relative or absolute root directory for files.
host     : database server host.
port     : database server port.
user     : database server user.
password : database server password.
useTrashcan : Move files to fileRoot.__traschcan directory on delete.
unicode  : Database is using unicode mode.
dbCodePage : If not in unicode mode, the database codepage used (default "utf-8").
connection : Specifies the database connection management class. Default None.
verifyConnection : Verify connection is still alive each time a connection is requested.
                   Automatically reconnects if the connection is closed.
timeout  : Timeout in seconds for database requests, if supported.
querylog : Enable database query log. "querylog" is used as filename the application 
           will use for the query log and the number of traceback lines. 
           use e.g. (10,'sql.log')
events  : Register for one or multiple Application events. 
          Register each event as e.g. Conf(event="run", callback=function).

Interface: IDatabaseConf

Call DatabaseConf().test() to verify configuration values.

class nive.definitions.ObjectConf(copyFrom=None, **values)

Configuration of a object type definition

Values

*id :      Unique type id as ascii string with maximum 25 chars.
*name :    Name used for display.
*dbparam : Database table name.
*context : Dotted python name or class reference used as factory. 
extensions:List of dotted python names or class references to extend context with
           additional functionality. Used in object factory.
data :     List of nive.definitions.FieldConf classes. Are mapped to the data table
           except for "file" data types. 
template : Template file name to render the default view. If file name is a
           relative path ('text.pt') the template is looked up in the active 
           design or view module templatePath. The file name can also be a 
           absolute dotted python name ('my_app.templates:text.pt').
views :    List of object view definitions. Either nive.definitions.ViewConf or 
           nive.definitions.ViewModuleConf.
forms :    Configuration of object form subsets and actions. Refer to nive.Form.

subtypes  : Define possible subtypes. None=no objects allowed, 
            `definitions.AllTypesAllowed`=all objects allowed, 
            [IContainer,IPageElement]=list with interfaces of allowed objects.
selectTag : Default select tag for this type. Stored as meta.pool_stag.
category  : Default category stored as meta.pool_category.
hidden    : Hide in select lists in user interface.
workflowEnabled : Enable or disable workflow for this type.
workflowID       : Workflow process id.

# security
acl :     List of pyramid acls for permission settings.

events  : Register for one or multiple Application events.
          Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 
version   : Optional version string.
description      : Description.

Call ObjectConf().test() to verify configuration values.

Object instances provide the configuration as configuration attribute.

Interface: IObjectConf

class nive.definitions.RootConf(copyFrom=None, **values)

Configuration of a root object

Values

*id      : Unique type id as ascii string.
*name    : Display name.
*context : Dotted python name or class reference used as factory. 
extensions:List of dotted python names or class references to extend context with
           additional functionality. Used in object factory.
template : Template file name to render the default view. If file name is a
           relative path ('root.pt') the template is looked up in the active 
           design or view module templatePath. The file name can also be a 
           absolute dotted python name ('my_app.templates:root.pt').
views    : List of object view definitions. Either nive.definitions.ViewConf 
           or nive.definitions.ViewModuleConf.

default  : Use this root as default root
subtypes : Define possible subtypes. None=no objects allowed, *=all objects allowed, 
           [IContainer,IPageElement]=list with interfaces of allowed objects.
urlTraversal : if True the root name is allowed to be used in url traversal.
workflowEnabled : Enable or disable workflow for this type.
workflowID       : Workflow process id.

acl :     List of pyramid acls for permission settings.

events  : Register for one or multiple Application events.
          Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 
description : Description.

Call RootConf().test() to verify configuration values.

Interface: IRootConf

class nive.definitions.ViewModuleConf(copyFrom=None, **values)

View module configuration

Used to group views and define module based default values for included views. View modules are registered and loaded on application level.

Values

*id    : Unique view module id as ascii string. Used to register and 
         lookup the view module.
name   : Display name 
template : The main template containing the slots to insert content.
static : Static directory
staticName : By default ViewModule.id is used as url name to map the static
             directory. To change the default specify a different name here.  
assets : list of assets required. each asset included as tuple (asset_id, asset_path)
acl    : Pyramid security definitions added to nive.Application acls
events  : Register for one or multiple Application events. 
          Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 
description : optional description

Included views

views : a list of nive.definitions.ViewConf definitions. These views use the
        following default values.
widgets : WidgetConf list for IToolboxWidgetConf and insertion points.

View defaults, can be overridden by single views

context      : default value for ViewModuleConf.views. 
view         : default value for ViewModuleConf.views. 
renderer     : default value for ViewModuleConf.views. 
containment  : default value for ViewModuleConf.views. 
permission   : default value for ViewModuleConf.views. 
templates    : default value for ViewModuleConf.views, if renderers are used.
               This refers to the directory templates with relative path are
               looked up.

Call ViewModuleConf().test() to verify configuration values.

Interface: IViewModuleConf

class nive.definitions.ViewConf(copyFrom=None, **values)

Configuration for a view definition

Parameters refer mainly to pyramid.add_view. If the view is included in a ViewModuleConf, defaults are loaded from the module (see ViewModuleConf above).

Values

*view       : the view class or function to be used 
*name       : the url name used to call this view. May be empty as default view 
              for object.
attr        : if the view is mapped to a class, this is the function to be called
context     : the object or interface this view is invoked for
renderer    : renderer name or template path
containment : load the view for this root context 
permission  : permission required to access the view
options     : additional view options supported by pyramid.add_view() as dict
id          : (optional) unique view id as ascii string. Can be used to remove, 
              change or replace a single view before the view is registered.
description : (optional) description

All parameters except id and description are passed to pyramid.add_view()

Call ViewConf().test() to verify configuration values.

Interface: IViewConf

class nive.definitions.PortalConf(copyFrom=None, **values)

Portal configuration class. Contains all configurable options for the portal (nive.Portal).

Values

portalDefaultUrl : redirect for portal root (/) requests
loginUrl         : login form url 
loginSuccessUrl  : redirect after succesfull login url 
forbiddenUrl     : redirect for unauthorized requests
logoutUrl        : logout function
logoutSuccessUrl : redirect on succesfull logout
accountUrl       : user account page
favicon          : favicon asset path
robots           : robots.txt contents

Call PortalConf().test() to verify configuration values.

Interface: IPortalConf

class nive.definitions.ToolConf(copyFrom=None, **values)

Tool configuration

Values

*id      : Unique tool id as ascii string. Used to register and lookup the tool.
*context : Dotted python name or class reference used as factory. 
*apply   : List of interfaces the tool is registered for. 
data     : Tool data defined as nive.definitions.FieldConf list.
values   : Values to override data.default on execution.
views    : List of nive.definitions.ViewConf definitions. 
mimetype : Mimetype of tool return stream
hidden   : Hide in user interface.
name     : Display name
events   : Register for one or multiple Application events. 
           Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 
description : Description

Call ToolConf().test() to verify configuration values.

Interface: IToolConf

class nive.definitions.ModuleConf(copyFrom=None, **values)

Generic module definition for application extension

Values

*id     : Unique type id as ascii string.
context : Dotted python name or class reference used as factory.
name    : Display name.
views   : List containing ViewConf or ViewModuleConf definitions. 
events  : Register for one or multiple Application events. 
          Register each event as e.g. Conf(event="run", callback=function).
extensions:List of dotted python names or class references to extend context with
           additional functionality. Used in object factory.
translations : A single or multiple directories containing translation files. 
modules : Additional module configuration to be included.
description : Description.

Call ModuleConf().test() to verify configuration values.

Interface: IModuleConf

class nive.definitions.WidgetConf(copyFrom=None, **values)

Configuration for a widget link

Use this configuration to link existing views to plugin points in user interfaces. Currently used for ToolboxWidget and EditorWidget

Values

*apply      : List of interfaces of context objects this widget is used for.
*viewmapper : View name in context to render widget contents.
*widgetType : Plugin point to register this widget for (IToolboxWidgetConf or IEditorWidgetConf).
*id         : Unique ascii string id to register this widget.
name        : Widget name.
sort        : Default sort for widgets as number.
events      : Register for one or multiple Application events. 
              Register each event as e.g. Conf(event="run", callback=function).
translations : A single or multiple directories containing translation files. 
description : Description.

Call WidgetConf().test() to verify configuration values.

Interface: IWidgetConf

class nive.definitions.GroupConf(copyFrom=None, **values)

Configuration of a group or principal definition

Values

id : Unique type id as ascii string with maximum 25 chars.
name : Display name. 
hidden : Hide in select lists in user interface.
description : Description.

Interface: IGroupConf

nive.definitions.LocalGroupsTbl = 'pool_groups'

Structure defines the additional tables with settings for identity column and table fields.

© 2013 Nive GmbH