Open source cms for mobile and desktop websites

nive.objects

This file provides object functionality for objects_. The different components are separated into classes. However these classes are not meant to be used as standalone.

object.files values

tag = file fldname
filename = filename
file = readable file object
fileid = unique file id as number
uid = fileid as string
size = file size in bytes
path = absolute local path
mime = file mime type
extension = file extension
tempfile = True/False. If True file is not committed, yet.

See nive.components.objects.base for subclassing base classes

class nive.objects.Object(id, dbEntry, parent, configuration, **kw)

Object implementation with read access.

meta

meta values

data

data values

files

files

dataroot

returns the current root object in parent chain

app

returns the cms application itself

parent

returns the parent object

db

returns the database object

GetFld(fldname)

Get the meta/data value and convert to type.

returns value or None

GetFile(fldname, loadFileData=False)

Get the file as File object with meta information. The included file pointer is opened on read. This functions directly accesses the database and ignores files cached in object.files.

returns File object or None

GetFileByName(filename)

Get a file by filename. See GetFile() for details. This functions directly accesses the database and ignores files cached in object.files.

returns File object or None

GetFileByUID(uid)

Get a file by uid. Only for files contained in this object. See GetFile() for details. This functions directly accesses the database and ignores files cached in object.files.

returns File object or none

GetID()

Get the object id as number.

returns number

GetTypeID()

returns the object type as string

GetTypeName()

returns the the object type name as string

GetFieldConf(fldId)

Get the FieldConf for the field with id = fldId. Looks up data, file and meta fields.

returns FieldConf or None

GetTitle()

returns the objects meta.title as string

GetPath()

returns the url path name of the object as string

IsRoot()

returns bool

GetParents()

returns all parent objects as list

GetParentIDs()

returns all parent ids as list

GetParentTitles()

returns all parent titles as list

GetParentPaths()

returns all parent paths as list

IsContainer()

returns if this object is a container

GetTool(name)

Load a tool for execution in the objects context. Only works for tools applied to this objects type.

returns the tool or None

Event - loadToool(tool=toolObj)

Close()

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

Event - close()

root()

bw 0.9.12: use dataroot property instead! returns the current root object in parent chain

GetRoot()

bw 0.9.12: to be removed. returns the current root object

GetApp()

bw 0.9.12: to be removed. returns the cms main application object

GetParent()

bw 0.9.12: to be removed. returns the parent object in the hierarchy

class nive.objects.ObjectEdit

Provides edit functionality for objects.

Requires (Object, ObjectWorkflow)

SplitData(sourceData)

Split sourceData dictionary in data, meta and file based on this objects configuration. Unused fields in source data are ignored.

returns data, meta, files (each as dictionary)

Commit(user)

Commit changes made to data, meta and file attributes and calls workflow “edit” action.

Event: - commit()

Workflow action: edit

Undo()

Undo changes made to data, meta and file attributes

Event: - undo()

Update(data, user)

Updates data, commits and calls workflow “edit” action. data can contain data, meta and files.

data = dictionary containing data, meta and files
user = the current user
returns bool 

Events:

  • update(data)
  • commit()

Workflow action: edit

StoreFile(fldname, file, user)

Store a file under fldname. Existing files will be replaced.

fldname = field name to store the file
file = the file to store as FileObject
user = the current user
returns bool

Events:

  • storeFile(filename, fldname)

Workflow action: edit

DeleteFile(fldname, user)

Delete a file from this object.

fldname = field name to store the file
user = the current user
returns bool

Event: - deleteFile(fldname)

Workflow action: edit

RenameFile(filekey, filename, user)

Changes the filename field of the file filekey.

filekey = file to set the new filename for
filename = new filename
user = the current user
returns bool
UpdateInternal(data)

Update this objects data without calling workflow actions or events

returns bool

CommitInternal(user)

Commit changes made to data, meta and files attributes without calling wf

Event: - commit()

CreateSelf(data, user, **kw)

Called after the new object is created.

Event: - wfInit(processID)

Workflow action: create

class nive.objects.ObjectWorkflow

Provides workflow functionality for objects. Workflow process objects are handled and loaded by the application. Meta layer fields pool_wfp stores the process id and pool_wfa the current state.

WfAllow(action, user, transition=None)

Check if action is allowed in current state in workflow. This functions returns True or False and unlike WFAction() will not raise a WorkflowNotAllowed Exception.

Event: - wfAllow(name)

returns bool

WfAction(action, user, transition=None)

Trigger workflow action. If several transitions are possible for the action in the current state the first is used. In this case the transition id can be passed as parameter.

Event: - wfAction(name)

raises WorkflowNotAllowed

WfInit(user)

Called after object was created

GetWf()

Returns the workflow process for the object.

Event: - wfLoad(workflow)

returns object

GetNewWf()

Returns the new workflow process configuration for the object based on settings:

  1. uses configuration.workflowID if defined
  2. query application modules for workflow

returns conf object

GetWfInfo(user)

returns the current workflow state as dictionary

GetWfState()
SetWfState(stateID)

Sets the workflow state for the object. The new is state is set regardless of transitions or calling any workflow actions.

SetWfProcess(processID, user, force=False)

Sets or changes the workflow process for the object. If force is false either

  1. no wfp must be set for the object or
  2. the current workflow with action change_wfprocess is called

Workflow action: change_wfprocess

© 2013 Nive GmbH