Package Products :: Package ZenModel :: Module ZenModelBase :: Class ZenModelBase |
[hide private]
[frames] | no frames]

# Class ZenModelBase

source code

    object --+
             |
            ZenModelBase

Known Subclasses:
  - ZenModelRM.ZenModelRM
  - , ZenModelItem.ZenModelItem

All ZenModel Persistent classes inherit from this class. It provides some screen management functionality, and general utility methods.

Instance Methods | [hide private]
__call__(self) Invokes the default view. | source code
view(self) Returns the default view even if index_html is overridden. | source code
__hash__(self) | source code
string
    >>> dmd.Devices.prepId('ab^*cd')
    'ab__cd'
    >>> dmd.Devices.prepId('ab^*cd', subchar='Z')
    'abZZcd'
    >>> dmd.Devices.prepId('/boot')
    'boot'
    >>> dmd.Devices.prepId('/')
    '-'
    >>> dmd.Devices.prepId(' mydev ')
    'mydev'
prepId(self, id, subchar='_') Clean out an id of illegal characters. | source code
boolean
    >>> dmd.Devices.checkValidId('^*')
    'The id "^*" contains characters illegal in URLs.'
    >>> dmd.Devices.checkValidId('Server')
    'The id "Server" is invalid - it is already in use.'
    >>> dmd.Devices.checkValidId('ZenTestId')
    True
checkValidId(self, id, prep_id=False) Checks that an id is a valid Zope id. | source code
string
    >>> id1 = dmd.Devices.getUnusedId('devices', 'dev')
    >>> id1
    'dev'
    >>> dmd.Devices.createInstance(id1)
    <Device at /zport/dmd/Devices/devices/dev>
    >>> id2 = dmd.Devices.getUnusedId('devices', 'dev')
    >>> id2
    'dev2'
getUnusedId(self, relName, baseKey, extensionIter=None) Return a new id that is not already in use in the relationship. | source code
string
    >>> dmd.Devices.getIdLink()
    '<a href="/zport/dmd/Devices">/</a>'
getIdLink(self) DEPRECATED Return an a link to this object with its id as the name. | source code
callZenScreen(self, REQUEST, redirect=False) Call and return screen specified by zenScreenName value of REQUEST. | source code
string |
zenScreenUrl(self) Return the url for the current screen as defined by zenScreenName. | source code
string |
urlLink(self, text=None, url=None, attrs={}) Return an anchor tag if the user has access to the remote object. | source code
string
    >>> dmd.Devices.getBreadCrumbUrlPath()
    '/zport/dmd/Devices'
    >>> rc = dmd.Reports._getOb('Graph Reports')
    >>> rc.manage_addGraphReport('test').getBreadCrumbUrlPath()
    '/zport/dmd/Reports/Graph%20Reports/test/editGraphReport'
getBreadCrumbUrlPath(self) Return the url to be used in breadcrumbs for this object. | source code
getBreadCrumbName(self) | source code
list
    >>> dmd.Devices.Server.breadCrumbs()
    [('/zport/dmd/Devices', 'Devices'),
        ('/zport/dmd/Devices/Server', 'Server')]
breadCrumbs(self, terminator='dmd', terminate=lambda x: False) Return the data to create the breadcrumb links for this object. | source code
upToOrganizerBreadCrumbs(self, terminator='dmd') | source code
boolean |
checkRemotePerm(self, permission, robject) Look to see if the current user has permission on remote object. | source code
zentinelTabs(self, templateName, REQUEST=None) Return a list of hashes that define the screen tabs for this object. | source code
_selectedTabName(self, templateName, REQUEST=None) | source code
zmanage_editProperties(self, REQUEST=None, redirect=False, audit=True) Edit a ZenModel object and return its proper page template. | source code
string |
getPrimaryDmdId(self, rootName="dmd", subrel="") Return the full dmd id of this object for instance /Devices/Server. | source code
zenpathjoin(self, path) DEPRECATED Build a Zenoss path based on a list or tuple. | source code
zenpathsplit(self, path) DEPRECATED Split a path on its '/'. | source code
createHierarchyObj(self, root, name, factory, relpath="", alog=None) DEPRECATED this is only seems to be used in Organizer.createOrganizer - Create an object from its path we use relpath to skip down any missing relations in the path and factory is the constructor for this object. | source code
getHierarchyObj(self, root, name, relpath) DEPRECATED this doesn't seem to be used anywere don't use it!!! | source code
getDmd(self) DEPRECATED Return the dmd root object with unwraped acquisition path. | source code
getDmdRoot(self, name) Return a dmd root organizer such as "Systems". | source code
getDmdObj(self, path) DEPRECATED Return an object from path that starts at dmd. | source code
getZopeObj(self, path) DEPRECATED Return an object from path tat starts at zope root. | source code
string |
getNowString(self) Return the current time as a string in the format '2007/09/27 14:09:53'. | source code
string |
todayDate(self) Return today's date as a string in the format 'mm/dd/yyyy'. | source code
string |
yesterdayDate(self) Return yesterday's date as a string in the format 'mm/dd/yyyy'. | source code
all_meta_types(self, interfaces=None) DEPRECATED Override the ObjectManager method that is used to control the items available in the add drop down in the ZMI. | source code
manage_deleteObjects(self, ids=(), REQUEST=None) Delete objects by id from this object and return to the current template as defined by callZenScreen. | source code
custPropertyIds(self) List custom properties that are defined at root node. | source code
[{'id':'cName','label':'Name', 'type':'string'},] |
custPropertyMap(self) Return custom property definitions. | source code
[{'id':'cName','label':'Name', 'type':'string'},] |
visibleCustPropertyMap(self) List custom property definitions that are visible using custPropertyMap: | source code
saveCustProperties(self, REQUEST) Save custom properties from REQUEST.form. | source code
getObjByPath(self, path) Lookup and object by its path. | source code
boolean
    >>> dmd.isLocalName('Devices')
    True
    >>> dmd.Devices.Server.isLocalName('Devices')
    False
isLocalName(self, name) Check to see if a name is local to our current context or if it comes from our acquisition chain. | source code
helpLink(self) DEPRECATED Return a link to the objects help file. | source code
string |
getIconPath(self) Return the icon associated with this object. | source code
aqBaseHasAttr(self, attr) Return hasattr(aq_base(self), attr) This is a convenience function for use in templates, where it's not so easy to make a similar call directly. | source code

Class Variables | [hide private]
| _zendoc = `''`
| sub_meta_types = `()`
| security = `ClassSecurityInfo()`
| index_html = `None`

Method Details | [hide private]

### view(self) | source code
Returns the default view even if index_html is overridden. Permission: ZEN_VIEW

### __hash__(self) (Hashing function) | source code
Overrides: object.__hash__ (inherited documentation)

### prepId(self, id, subchar='_') | source code
Clean out an id of illegal characters. Parameters: `subchar` (string) - Character to be substituted with illegal characters `id` (string) Returns: string
    >>> dmd.Devices.prepId('ab^*cd')
    'ab__cd'
    >>> dmd.Devices.prepId('ab^*cd', subchar='Z')
    'abZZcd'
    >>> dmd.Devices.prepId('/boot')
    'boot'
    >>> dmd.Devices.prepId('/')
    '-'
    >>> dmd.Devices.prepId(' mydev ')
    'mydev'

### checkValidId(self, id, prep_id=False) | source code
Checks that an id is a valid Zope id. Looks for invalid characters and checks that the id doesn't already exist in this context. Parameters: `prep_id` (boolean) `id` (string) Returns: boolean
    >>> dmd.Devices.checkValidId('^*')
    'The id "^*" contains characters illegal in URLs.'
    >>> dmd.Devices.checkValidId('Server')
    'The id "Server" is invalid - it is already in use.'
    >>> dmd.Devices.checkValidId('ZenTestId')
    True

### getUnusedId(self, relName, baseKey, extensionIter=None) | source code
Return a new id that is not already in use in the relationship. If baseKey is not already in use, return that. Otherwise append values from extensionIter to baseKey until an used key is found. The default extensionIter appends integers starting with 2 and counting up. Parameters: `extensionIter` (iterator) `baseKey` (string) `relName` (string) Returns: string
    >>> id1 = dmd.Devices.getUnusedId('devices', 'dev')
    >>> id1
    'dev'
    >>> dmd.Devices.createInstance(id1)
    <Device at /zport/dmd/Devices/devices/dev>
    >>> id2 = dmd.Devices.getUnusedId('devices', 'dev')
    >>> id2
    'dev2'

### getIdLink(self) | source code
DEPRECATED Return an a link to this object with its id as the name. Returns: string
    >>> dmd.Devices.getIdLink()
    '<a href="/zport/dmd/Devices">/</a>'
An HTML link to this object

### callZenScreen(self, REQUEST, redirect=False) | source code
Call and return screen specified by zenScreenName value of REQUEST. If zenScreenName is not present call the default screen. This is used in functions that are called from forms to get back to the correct screen with the correct context.

### zenScreenUrl(self) | source code
Return the url for the current screen as defined by zenScreenName. If zenScreenName is not found in the request the request url is used. Returns: string An url to this object

### urlLink(self, text=None, url=None, attrs={}) | source code
Return an anchor tag if the user has access to the remote object. Parameters: `text` - the text to place within the anchor tag or string. Defaults to the id of this object. `url` - url for the href. Default is getPrimaryUrlPath `attrs` (dict) - any other attributes to be place in the in the tag. Returns: string An HTML link to this object

### getBreadCrumbUrlPath(self) | source code
Return the url to be used in breadcrumbs for this object. normally this is equal to getPrimaryUrlPath. It can be used as a hook to modify the url so that it points towards a different tab then the default. Returns: string
    >>> dmd.Devices.getBreadCrumbUrlPath()
    '/zport/dmd/Devices'
    >>> rc = dmd.Reports._getOb('Graph Reports')
    >>> rc.manage_addGraphReport('test').getBreadCrumbUrlPath()
    '/zport/dmd/Reports/Graph%20Reports/test/editGraphReport'
A url to this object

### breadCrumbs(self, terminator='dmd', terminate=lambda x: False) | source code
Return the data to create the breadcrumb links for this object. This is a list of tuples where the first value is the URL of the bread crumb and the second is the lable. Returns: list
    >>> dmd.Devices.Server.breadCrumbs()
    [('/zport/dmd/Devices', 'Devices'),
        ('/zport/dmd/Devices/Server', 'Server')]
List of tuples to create a bread crumbs

### checkRemotePerm(self, permission, robject) | source code
Look to see if the current user has permission on remote object. Parameters: `permission` - Zope permission to be tested. ie "View" `robject` - remote objecct on which test is run. Will test on primary acquisition path. Returns: boolean Permission: ZEN_COMMON

### zentinelTabs(self, templateName, REQUEST=None) | source code
Return a list of hashes that define the screen tabs for this object. Keys in the hash are: action = the name of the page template for this tab name = the label used on the tab permissions = a tuple of permissions to view this template Permission: ZEN_VIEW
    >>> dmd.Devices.zentinelTabs('deviceOrganizerStatus')
    [{'action': 'deviceOrganizerStatus', 'selected': True,
        'name': 'Classes', 'permissions': ('View',)},
    {'action': 'viewEvents', 'name': 'Events', 'permissions': ('View',)},
    {'action': 'zPropertyEdit', 'name': 'Configuration Properties',
        'permissions': ('View',)},
    {'action': 'perfConfig', 'name': 'Templates',
        'permissions': ('Manage DMD',)}]

### zmanage_editProperties(self, REQUEST=None, redirect=False, audit=True) | source code
Edit a ZenModel object and return its proper page template. Object will be reindexed if nessesary. Permission: ZEN_MANAGE_DMD

### getPrimaryDmdId(self, rootName="dmd", subrel="") | source code
Return the full dmd id of this object for instance /Devices/Server. Everything before dmd is removed. A different rootName can be passed to stop at a different object in the path. If subrel is passed any relationship name in the path to the object will be removed. Parameters: `rootName` (string) - Name of root `subrel` (string) - Name of relation Returns: string Path to object Permission: ZEN_VIEW
    >>> d = dmd.Devices.Server.createInstance('test')
    >>> d.getPrimaryDmdId()
    '/Devices/Server/devices/test'
    >>> d.getPrimaryDmdId('Devices')
    '/Server/devices/test'
    >>> d.getPrimaryDmdId('Devices','devices')
    '/Server/test'

### zenpathjoin(self, path) | source code
  - DEPRECATED Build a Zenoss path based on a list or tuple. Parameters: `path` (list or tuple
        >>> dmd.zenpathjoin(('zport', 'dmd', 'Devices', 'Server'))
        '/zport/dmd/Devices/Server'
)

### getDmd(self) | source code
DEPRECATED Return the dmd root object with unwraped acquisition path.
    >>> dmd.Devices.Server.getDmd()
    <DataRoot at /zport/dmd>

### getDmdRoot(self, name) | source code
Return a dmd root organizer such as "Systems". The acquisition path will be cleaned so that it points directly to the root.
    >>> dmd.Devices.Server.getDmdRoot("Systems")
    <System at /zport/dmd/Systems>

### getDmdObj(self, path) | source code
DEPRECATED Return an object from path that starts at dmd.
    >>> dmd.getDmdObj('/Devices/Server')
    <DeviceClass at /zport/dmd/Devices/Server>

### getZopeObj(self, path) | source code
DEPRECATED Return an object from path tat starts at zope root.
    >>> dmd.getZopeObj('/zport/dmd/Devices/Server')
    <DeviceClass at /zport/dmd/Devices/Server>

### all_meta_types(self, interfaces=None) | source code
DEPRECATED Override the ObjectManager method that is used to control the items available in the add drop down in the ZMI. It uses the attribute sub_menu_items to create the data structures. This is a list of meta_types for the available classes. This functionality is rarely used in Zenoss because the ZMI is not the perfered management interface.

### manage_deleteObjects(self, ids=(), REQUEST=None) | source code
Delete objects by id from this object and return to the current template as defined by callZenScreen. Uses ObjectManager._delObject to remove the object. Permission: ZEN_VIEW

### custPropertyIds(self) | source code
List custom properties that are defined at root node. Custom properties start with a lower "c" followed by a uppercase character.

### visibleCustPropertyMap(self) | source code
List custom property definitions that are visible using custPropertyMap:
Returns: [{'id':'cName','label':'Name', 'type':'string'},]

### saveCustProperties(self, REQUEST) | source code
Save custom properties from REQUEST.form. Permission: ZEN_MANAGE_DMD

### getObjByPath(self, path) | source code
  - Lookup and object by its path. Basically does a Zope unrestricted traverse on the path given. Parameters: `path` (list or string /zport/dmd/Devices
        >>> dmd.getObjByPath(('zport','dmd','Devices'))
        <DeviceClass at /zport/dmd/Devices>
        >>> dmd.getObjByPath(('Devices','Server'))
        <DeviceClass at /zport/dmd/Devices/Server>
        >>> dmd.getObjByPath('/zport/dmd/Devices/Server')
        <DeviceClass at /zport/dmd/Devices/Server>
        >>> dmd.getObjByPath('Devices/Server')
        <DeviceClass at /zport/dmd/Devices/Server>
)

### helpLink(self) | source code
DEPRECATED Return a link to the objects help file. Permission: ZEN_VIEW

### getIconPath(self) | source code
Return the icon associated with this object. The icon path is defined in the zProperty zIcon. Returns: string Path to icon Permission: ZEN_VIEW
    >>> dmd.Devices.Server.zIcon = '/zport/dmd/img/icons/server.png'
    >>> d = dmd.Devices.Server.createInstance('test')
    >>> d.getIconPath()
    '/zport/dmd/img/icons/server.png'

### aqBaseHasAttr(self, attr) | source code
Return hasattr(aq_base(self), attr) This is a convenience function for use in templates, where it's not so easy to make a similar call directly. hasattr itself will swallow exceptions, so we don't want to use that. We also need to allow for values of None, so something like getattr(aq_base(self, attr, None) doesn't really tell us anything. Testing __dict__ is not a good choice because it doesn't allow for properties (and I believe __getitem__ calls.) So while this looks pretty attrocious, it might be the most sane solution.