lunes, 4 de febrero de 2008

Expresiones de fórmulas en KMKey

0 comentarios
 
Cuando configuramos uszndo el ZMI (para usuarios avanzados), hay un montón de sitios donde podemos definir fórmulas usando expresiones TALES. En cada caso, los objetos disponibles pueden ser diferentes, y es dificil recordarlos. Aquí dejo una lista de los más usados:

Expressions used in Default Value of Fields

mapping = {
'field': self,
'datamodel': datamodel,
'user': getSecurityManager().getUser(),
'portal': getToolByName(self, 'portal_url').getPortalObject(),
'modules': SecureModuleImporter,
'DateTime': DateTime,
'nothing': None,
}


Expressions used in Fields

mapping = data.copy() # XXX there may be DEFAULT_VALUE_MARKER here

# XXX hack replace DEFAULT_VALUE_MARKER
for k, v in mapping.items():
if v is DEFAULT_VALUE_MARKER:
mapping[k] = '' # XXX should be field's default
portal = getToolByName(self, "portal_url").getPortalObject()

# Wrapping util in the current acquisition context
util = fieldStorageNamespace.__of__(portal)

mapping.update({
'value': value,
'data': data,
'field': self,
'user': getSecurityManager().getUser(),
'portal': portal,
'modules': SecureModuleImporter,
'DateTime': DateTime,
'nothing': None,
# Useful for objects
'object': context,
'proxy': proxy,
# Deprecated: use the 'object' name instead
'context': context,
# Methods registry
'util': util,
})


Expressions used in Layouts

portal = getToolByName(self, 'portal_url').getPortalObject()
data = {
'layout': self,
'datastructure': datastructure,
'datamodel' : datastructure.getDataModel(),
'kw': kw,
'nothing': None,
'portal': portal,
'modules': SecureModuleImporter,
}


Expressions used in Widgets

wftool = getToolByName(self, 'portal_workflow')
portal = getToolByName(self, 'portal_url').getPortalObject()
proxy = datamodel._proxy
if proxy is not None:
review_state = wftool.getInfoFor(proxy, 'review_state', None)
else:
review_state = None
data = {
'widget': self,
'datamodel': datamodel,
'user': datamodel._acl_cache_user,
'nothing': None,
'context': datamodel._context,
'portal': portal,
'modules': SecureModuleImporter,
'proxy': proxy,
'portal_workflow': wftool,
'review_state': review_state,
'layout_mode': layout_mode,
}

Expressions used in Workflows

ob = sci.object
wf = sci.workflow
data = {
'here': ob,
'container': aq_parent(aq_inner(ob)),
'nothing': None,
'root': wf.getPhysicalRoot(),
'request': getattr( ob, 'REQUEST', None ),
'modules': SecureModuleImporter,
'user': getSecurityManager().getUser(),
'state_change': sci,
'transition': sci.transition,
'status': sci.status,
'stacks': sci.stacks,
'kwargs': sci.kwargs,
'workflow': wf,
'scripts': wf.scripts,
}


Expressions used in Actions

data = {
'object_url': object_url,
'folder_url': folder.absolute_url(),
'portal_url': portal.absolute_url(),
'object': object,
'folder': folder,
'portal': portal,
'nothing': None,
'request': getattr( object, 'REQUEST', None ),
'modules': SecureModuleImporter,
'member': member,
'here': object,
}


Expressions used in KMKey Relation Widgets conditions

query = catalog.makeAdvancedQuery({})
if self.query_expression:
data = {
'widget': self,
'datastructure': datastructure,
'datamodel' : datastructure.getDataModel(),
'kw': kw,
'nothing': None,
'modules': SecureModuleImporter,
'MatchGlob': MatchGlob,
'Eq': Eq,
'Le': Le,
'Ge': Ge,
'In': In,
'Between': Between,
'Generic': Generic
}

Leave a Reply