Open source cms for mobile and desktop websites

Root

This page contains a list of all functions supported by roots. The list is ordered by the different classes roots inherit their functionality from.

class nive.components.objects.base.PageRootBase(path, app, rootDef)

Root with content element support

  • handles sub pages
  • handles page columns
  • rendered as website page
  • is an element container
  • supports paste of elements and pages
  • contained pages and elements are sortable

Interfaces: IPageContainer, IPageElementContainer, IContainer, IRoot

Root values and parents

class nive.container.Root(path, app, rootDef)

The root is a container for objects but does not store any data in the database itself. It is the entry point for object access. Roots are only handled by the application.

Requires (Container, ContainerFactory, Event)

Root.root()

this will return itself. Used for object compatibility.

Root.app

returns the cms application the root is used for

Root.db

returns the datapool object

Root.parent

this will return None. Used for object compatibility.

Root.LookupObj(id, **kw)

Lookup the object referenced by id anywhere in the tree structure. Use obj() to restrain lookup to the first sublevel only.

id = number
**kw = version information

returns the object or None

Root.LookupTitle(id)

Lookup the object title referenced by id anywhere in the tree structure.

returns title as string or empty string

Root.ObjQueryRestraints(containerObj=None, parameter=None, operators=None)

The functions returns two dictionaries (parameter, operators) used to restraint object lookup in subtree. For example a restraint can be set to ignore all objects with meta.pool_state=0. All container get (GetObj, GetObjs, ...) functions use query restraints internally.

See nive.search for parameter and operator usage.

Please note: Setting the wrong values for query restraints can easily crash the application.

Event: - loadRestraints(parameter, operators)

returns parameter dict, operators dict

Root.GetID()

returns 0. the root id is always zero.

Root.GetTypeID()

returns the root type id from configuration

Root.GetTypeName()

returns the root type name from configuration

Root.GetTitle()

returns the root title from configuration.

Root.GetPath()

returns the url path name as string.

Root.IsRoot()

returns always True.

Root.GetRoot()

returns self.

Root.GetApp()

returns the cms application.

Root.GetParent()

returns None.

Root.GetParents()

returns empty list. Used for object compatibility.

Root.GetParentIDs()

returns empty list. Used for object compatibility.

Root.GetParentTitles()

returns empty list. Used for object compatibility.

Root.GetParentPaths()

returns empty list. Used for object compatibility.

Root.GetTool(name)

Load a tool in the roots’ context. Only works for tools registered for roots or this root type.

returns the tool object or None

Event - loadToool(tool=toolObj)

Root.Close()

Close the root and all contained objects. Currently only used in combination with caches.

Event - close()

Subobjects

class nive.container.Container

Container implementation with read access for subobjects used for objects and roots.

Requires: ContainerFactory

Container.obj(id, **kw)

shortcut for GetObj

Container.GetObj(id, **kw)

Get the subobject by id.

id = object id as number
**kw = load information
returns the object or None

Events: - loadObj(obj)

Container.GetObjs(parameter=None, operators=None, **kw)

Search for subobjects based on parameter and operators.

parameter = dict. see nive.Search
operators = dict. see nive.Search
kw.sort = sort objects. if None container default sort is used
kw.batch = load subobjects as batch
**kw = see Container.GetObj()
returns all matching subobjects as list

see nive.Search for parameter/operators description

Events - loadObj(obj)

Container.GetObjsList(fields=None, parameter=None, operators=None, pool_type=None, **kw)

Search for subobjects based on parameter and operators. This function performs a sql query based on parameters and does not load any object.

fields = list. see nive.Search
parameter = dict. see nive.Search
operators = dict. see nive.Search
kw.sort = sort objects. if None container default sort is used
kw.batch = load subobjects as batch
returns dictionary list

see nive.Search for parameter/operators description

Container.GetObjsBatch(ids, **kw)

Tries to load the objects with as few sql queries as possible.

ids = list of object ids as number
**kw = see Container.GetObj()
returns all matching sub objects as list

Events - loadObj(objs)

Container.GetContainers(parameter=None, operators=None, **kw)

Loads all subobjects with container functionality. Uses select tag range nive.definitions.StagContainer to nive.definitions.StagPageElement - 1.

kw.batch = load subobjects as batch and not as single object
parameter = see pool Search
operators = see pool Search
**kw = see Container.GetObj()
returns all matching sub objects as list

see nive.Search for parameter/operators description

Events - loadObj(objs)

Container.GetContainerList(fields=None, parameter=None, operators=None, **kw)

Lists all subobjects with container functionality. Uses select tag range nive.definitions.StagContainer to nive.definitions.StagPageElement - 1. This function performs a sql query based on parameters and does not load any object.

fields = list. see nive.Search
parameter = see pool Search
operators = see pool Search
kw.batch = load subobjects as batch
**kw = see Container.GetObj()
returns dictionary list

see nive.Search for parameter/operators description

Container.GetContainedIDs(sort=None)

Returns the ids of all contained objects including subfolders sorted by sort. Default is GetSort().

returns list

Container.GetSort()

The default sort order field name.

returns the field id as string

Container.IsContainer()

Editing values

class nive.container.ContainerEdit

Container with add and delete functionality for subobjects.

Requires: Container

ContainerEdit.Create(type, data, user, **kw)

Creates a new sub object.

type = object type id as string or object configuration
data = dictionary containing data for the new object
user = the currently active user
**kw = version information
returns the new object or None

Events

  • beforeAdd(data=data, type=type, user=user, kw) called for the container
  • create(user=user, kw) called for the new object
  • afterAdd(obj=obj, user=user, kw) called for the container after object has been committed

Workflow actions

  • add (called in context of the container)
  • create (called in context of the new object)
ContainerEdit.Duplicate(obj, user, updateValues=None, **kw)

Duplicate the object including all data and files and store as new subobject.

obj = the object to be duplicated
user = the currently active user
updateValues = dictionary containing meta, data, files
**kw = version information
returns new object or None

Events

  • beforeAdd(data=data, type=type, user=user, kw) called for the container
  • duplicate(kw) called for the new object
  • afterAdd(obj=obj, user=user, kw) called for the container after obj has been committed

Workflow action

  • add (called in context of the container)
  • create (called in context of the new object)
ContainerEdit.Delete(id, user, obj=None, **kw)

Delete the subobject referenced by id.

id = id of object to be deleted
user = the currently active user
obj = the object to be deleted. Will be loaded automatically if None
**kw = version information
returns True or False

Events

  • delete(user=user) called on object to be deleted
  • afterDelete(id=id, user=user) called on container after object has been deleted

Workflow action

  • remove (called in context of the container)
  • delete (called in context of the new object)
ContainerEdit.DeleteInternal(id, user, obj=None, **kw)

Like Delete() but does not call any workflow action.

id = id of object to be deleted
user = the currently active user
obj = the object to be deleted. Will be loaded automatically if None
**kw = version information
returns True or False

Events

  • delete() called on object to be deleted
  • afterDelete(id=id) called on container after object has been deleted

Global search functions

This file provides global search functionality, database lookup and sql query wrappers. It is usually attached to root objects.

Search parameter handling

Most functions support a similar parameter handling for generating sql queries.

Parameters  
fields

list of database fields (field ids) to include in result. prefix ‘-‘: special fields or aggregate functions can be inserted by adding

a ‘-‘ in front of the field. -count(*) or -MAX(field1)

prefix ‘+’: special fields skipped in SQL query e.g. ‘+preview’

parameter dictionary with fieldname:value entries used for search conditions
operators dictionary with fieldname:operator entries used for search conditions default: strings=*LIKE*, all others=’=’ possible values: ``=, LIKE, IN, >, <, <=, >=, !=, BETWEEN ``
sort result sort field or list if multiple
ascending sort ascending or decending
start start position in result
max maximum number of result records

Parameter for operator BETWEEN has to be formatted: e.g. ‘2006/10/10’ AND ‘2006/10/11’

Keyword options (Not supported by all functions)
logicalOperator link between conditions. default: AND. possible: AND, OR, NOT
condition custom sql condition statement appended to WHERE clause
groupby used as sql GROUP BY statement
join adds a custom custom sql join statement
jointype left, inner, right. default = inner (used by SearchType())
mapJoinFld fieldname to map title by left/right join (used by SearchType())
addID Add fld.id in query without showing in result list. used for custom columns e.g. -(select ...)
skipRender render result flds as html element. default: pool_type, pool_wfa, pool_wfp to skip all: True, or a list of fields (“pool_wfa”,”pool_type”)
skipCount enable or disable second query to get the number of all records.
Search result (supported by Search*() functions)
criteria dictionary containing parameters used in search
count number of records contained in result
total total number of records matching the query
items result list. each record as dictionary. Each field is rendered for display depending on skipRender keyword. This means list entries are replaced by their readable names, dates are rendered readable.
start record start number in result
max maximum number of records
next start number of next record set
nextend end number of next record set
prev start number of previous record set
prevend end number of previous record set
sql the sql statement used
class nive.search.Search
Search.Select(pool_type=None, parameter={}, fields=['id'], operators={}, sort=None, ascending=1, start=0, max=0, **kw)

Fast and simple sql query.

If pool_type is not set the query will apply to the meta layer only. In this case you can only include pool_meta.fields in fields.

If pool_type is set you can use meta and data fields. The query is restricted to a single type.

Supported keywords: groupby, logicalOperator, condition, dontAddType

The following example selects all children of the current object

fields = ["id", "title", "pool_type"]
parameter["pool_unitref"] = self.id
records = self.root().Select(parameter=parameter, fields=fields)

returns records as list

Search.SelectDict(pool_type=None, parameter={}, fields=[u'id'], operators={}, sort=None, ascending=1, start=0, max=0, **kw)

Fast and simple sql query.

If pool_type is not set the query will apply to the meta layer only. In this case you can only include pool_meta.fields in fields.

If pool_type is set you can use meta and data fields. The query is restricted to a single type.

Supported keywords: groupby, logicalOperator, condition

Records are returned as dictionaries

The following example selects all children not of type image of the current object

fields = ["id", "title", "pool_type"]
parameter = {"pool_unitref": self.id}
operators = {"pool_type": "!="}
records = self.root().SelectDict("image", parameter=parameter, fields=fields, 
                                 operators=operators)

returns records as dict list

Search.Search(parameter, fields=[], operators={}, sort=u'title', ascending=1, start=0, max=100, **kw)

Extended meta layer search function. Supports all keyword options and search result.

Example

root.()Search({"title":"test"}, 
              fields=["id", "pool_type", "title"], 
              start=0, max=50, 
              operators={"title":"="})

returns search result (See above)

Search.SearchType(pool_type, parameter, fields=[], sort=u'title', ascending=1, start=0, max=100, **kw)

Extended meta and data layer search function. Supports all keyword options and search result.

Example

root.()SearchType("image", 
                  parameter={"title":"test"}, 
                  fields=["id", "pool_type", "title"], 
                  start=0, max=50, 
                  operators={"title":"="})

returns search result (See above)

Search.SearchData(pool_type, parameter, fields=[], sort=u'id', ascending=1, start=0, max=100, **kw)

Extended data layer search function. Supports all keyword options and search result.

Example

root.()SearchData("image", 
                  parameter={"text": "new"}, 
                  fields=["id", "text", "title"], 
                  start=0, max=50, 
                  operators={"text":"LIKE"})

returns search result (See above)

Search.SearchFulltext(phrase, parameter=None, fields=('id', 'title', 'pool_type', '-pool_fulltext.text as fulltext'), sort=u'', ascending=1, start=0, max=300, **kw)

Fulltext search function. Searches all text fields marked for fulltext search. Uses searchPhrase as parameter for text search. Supports all keyword options and search result.

Example

root().SearchFulltext("new", parameter={}, 
                  fields=["id", "title"], 
                  start=0, max=50, 
                  operators={"text":"LIKE"})

returns search result (See above)

Search.SearchFulltextType(pool_type, phrase, parameter=None, fields=['id', 'title'], sort=None, ascending=1, start=0, max=300, **kw)

Fulltext search function. Searches all text fields marked for fulltext search of the given type. Uses searchPhrase as parameter for text search. Supports all keyword options and search result.

Example

root.()SearchFulltextType("text",
                  parameter={"searchPhrase": "new"}, 
                  fields=["id", "text", "title"], 
                  start=0, max=50, 
                  operators={"text":"LIKE"})

returns search result (See above)

Search.SearchFilename(filename, parameter, fields=[], sort=None, ascending=1, start=0, max=100, **kw)

Filename search function. Searches all physical file filenames (not url path names). Supports all keyword options and search result.

Includes matchinng files as “result_files” in each record.

Example

root.()SearchFulltextType("text",
                  parameter={"searchPhrase": "new"}, 
                  fields=["id", "text", "title"], 
                  start=0, max=50, 
                  operators={"text":"LIKE"})

returns search result (See above)

Search.GetTree(flds=[u'id', u'pool_unitref', u'title', u'pool_filename', u'pool_type', u'pool_state', u'pool_wfa', u'pool_sort'], sort=u'pool_sort', base=0, parameter=u'')

Select list of all folders from db.

returns the subtree {‘items’: [{u’id’: 354956L, ‘ref1’: 354954L, ‘ref2’: 354952L, ..., ‘ref10’: None, ‘items’: [...]}]

Search.TreeParentIDs(id)

returns the parent ids for the object with id as list

Search.TreeParentTitles(id)

returns the parent titles for the object with id as list

Search.GetEntriesAsCodeList(pool_type, name_field, parameter=None, operators=None, sort=None)

Search the database for entries of type pool_type and return matches as codelist

[{"name": name_field, "id": object.id}, ... ]

If the name_field is stored as data field, insert data. at the beginning of name_field (e.g. data.header)

returns list

Search.GetEntriesAsCodeList2(name_field, parameter=None, operators=None, sort=None)

Search the database and return matches as codelist

[{"name": name_field, "id": object.id}, ... ]

returns list

Search.GetGroupAsCodeList(pool_type, name_field, parameter=None, operators=None, sort=None)

Search the database for entries of type pool_type and return matches grouped by unique name_field values as codelist

[{"name": name_field, "id": object.id}, ... ]

If the name_field is stored as data field, insert data. at the beginning of name_field (e.g. data.header)

returns list

Search.GetGroupAsCodeList2(name_field, parameter=None, operators=None, sort=None)

Search the database and return matches grouped by unique name_field values as codelist

[{"name": name_field, "id": object.id}, ... ]

returns list

Search.FilenameToID(filename, unitref=None, parameter=None, firstResultOnly=True, operators=None)

Convert url path filename (meta.pool_filename) to id. This function does not lookup physical files and their filenames.

returns id

Search.IDToFilename(id)

Convert id to url path filename (meta.pool_filename). This function does not lookup physical files and their filenames.

returns string

Search.ConvertDatarefToID(pool_type, dataref)

Search for object id based on dataref and pool_type.

returns id

Search.GetMaxID()

Lookup id of the last created object.

returns id

Search.GetReferences(unitID, types=[])

Search for references in unit or unitlist fields of all objects.

returns id list

Search.LoadListItems(fieldconf, obj=None, pool_type=None, force=False)

Load field list items in correspondance to to field.id and field.settings. if force is false and fieldconf contains list items, the existing field.listItems are returned. set force=true to reload.

obj and pool_type only used for workflow lookup

returns dict list

Extensions

class nive.cms.cmsview.cutcopy.ContainerCopy

Cut, copy and paste functionality for object container

class nive.cms.cmsview.sort.Sort

Container sort functionality

Objects can explicitly be sorted and moved up or down in sequence. Sort values are stored in meta.pool_sort.

class nive.components.extensions.path.AlternatePath

Enables readable url path names instead of ids for object traversal. Names are stored as meta.pool_filename and generated from title by default. Automatic generation can be disabled by setting meta.customfilename to False for each object.

Extensions like .html are not stored. Path matching works independent from extensions.

Object development

class nive.container.ContainerSecurity

Provides functionality to allow or disallow the creation of objects based on object configuration.subtypes.

class nive.events.Events
© 2013 Nive GmbH