class documentation

class ZMSLinkElement(zmscustom.ZMSCustom): (source)

View In Hierarchy

Represent a link element that can resolve, embed, or proxy other content.

Link elements can either behave like a normal local content node or expose another object inline by reference. Depending on attr_type/_embed_type they may:

  • link to another object without embedding it,
  • embed the referenced object directly,
  • recursively proxy the referenced subtree,
  • or retrieve remote content through the REST API.
Method __proxy__ Build the proxy object used for recursive embedded traversal.
Method breadcrumbs_obj_path Return the breadcrumb path for this element.
Method breadcrumbs_obj_pathPROXY Return the breadcrumb path resolved through the current proxy context.
Method display_icon Return the icon markup for this element or its referenced target.
Method embedRemoteContent Retrieve rendered body content from a remote reference.
Method getChildNodes Return child nodes visible for this link element.
Method getChildNodesPROXY Return child nodes for the active proxy or referenced object.
Method getEmbedType Return the configured embedding mode for this link element.
Method getHref2IndexHtml Return the index HTML URL for this link element.
Method getHref2IndexHtmlPROXY Return the index HTML URL resolved through the current proxy context.
Method getLevel Return the effective hierarchy level of this element.
Method getLevelPROXY Return the level resolved through the active proxy context. For recursively embedded elements the level is delegated to the proxy. For directly embedded elements the level is calculated based on the parent node level unless the parent is the same as the proxy, in which case it is treated as the root of the embedding context and assigned level 0.
Method getNavElements Return navigation elements for this link element.
Method getNavElementsPROXY Return navigation elements for the current proxy context.
Method getNavItems Return navigation items for this element.
Method getNavItemsPROXY Return navigation items for the current proxy context. Overrides getNavItems of zmscontainerobject.ZMSContainerObject.
Method getObjProperty Return a property value from this element, its proxy, or its reference.
Method getObjPropertyPROXY Read an object property directly from the supplied proxy object. Overrides getObjProperty of _objattrs.ObjAttrs.
Method getParentNode The parent of this node. All nodes except root may have a parent.
Method getParentNodePROXY Return the parent node visible through the current proxy context.
Method getProxy Return the cached proxy object for this (embedding) link element.
Method getRef Return the stored link target reference.
Method getRefObj Resolve and cache the referenced object for this link element.
Method getRemoteObj Fetch remote metadata for a link element with embed type 'remote'.
Method getSelf Return the effective object for this link element.
Method getSelfPROXY Resolve the effective object for the proxy context.
Method getTitle Return the display title for this element.
Method getTitlealt Return the alternate title for this element.
Method getTitlealtPROXY Resolve the alternate title through the proxy or reference chain.
Method getTitlePROXY Resolve the title through the proxy or reference chain.
Method getTreeNodes Return an empty tree node list for link elements.
Method getType Return the effective type for this link element.
Method getTypePROXY Return the effective type resolved through embedding or proxying. Overrides getType of zmscustom.ZMSCustom.
Method initProxy Create a ZMSProxyObject for a resolved embedded target.
Method isActive Return whether the element is active in the current request context.
Method isEmbedded Return whether this element renders another object inline.
Method isEmbeddedRecursive Return whether this element uses recursive embedding.
Method isMetaType Return whether this element matches the requested meta type.
Method isMetaTypePROXY Check whether this element or its resolved target matches a meta type.
Method isPage Return whether this element resolves to a page-like target. Embedded and remote link elements are treated as pages when their resolved target has the corresponding flag set.
Method isPageContainer Return False because link elements are never page containers.
Method isPageElement Return whether this element behaves like a page element. Embedded and remote link elements are treated as page elements when their resolved target has the corresponding flag set.
Method manage_changeProperties Update link element properties from the ZMI form submission.
Method manage_options Handle the ZMI action 'manage_options'.
Method printHtml Return the printable HTML for this link element.
Method printHtmlPROXY Render the printable HTML through the current proxy or reference.
Method renderShort Render the compact presentation of the link element.
Method setEmbedType Persist the requested embedding mode on the raw _embed_type attribute.
Class Variable __ac_permissions__ Undocumented
Class Variable __authorPermissions__ Undocumented
Class Variable getParentNode__roles__ Undocumented
Class Variable meta_id Undocumented
Class Variable meta_type Undocumented
Class Variable security Undocumented
Method _getBodyContent Render the body content for the link element (as HTML).
Instance Variable _embed_type Undocumented
def __proxy__(self): (source)

Build the proxy object used for recursive embedded traversal.

Returns
objectThis element itself or a proxy wrapping the referenced object.
def breadcrumbs_obj_path(self, portalMaster=True): (source)

Return the breadcrumb path for this element.

Parameters
portalMaster:boolInclude the portal master in the breadcrumb path.
Returns
listBreadcrumb object path.
def breadcrumbs_obj_pathPROXY(self, proxy, portalMaster=True): (source)

Return the breadcrumb path resolved through the current proxy context.

Parameters
proxy:objectActive proxy object.
portalMaster:boolInclude the portal master in the breadcrumb path.
Returns
listBreadcrumb object path.
def display_icon(self, *args, **kwargs): (source)

Return the icon markup for this element or its referenced target.

Parameters
*args:tuplePositional arguments for the icon display.
**kwargs:dictKeyword arguments for the icon display.
Returns
strIcon markup for this element or its referenced target.
def embedRemoteContent(self, REQUEST): (source)

Retrieve rendered body content from a remote reference.

The remote endpoint is only contacted when the embed type is 'remote'.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
str | NoneRemote HTML fragment or None when remote embedding is not active.
def getChildNodes(self, REQUEST={}, meta_types=None, reid=None): (source)

Return child nodes visible for this link element.

Parameters
REQUEST:dictCurrent request context.
meta_types:list | NoneOptional meta type filter.
reid:str | NoneOptional regular-expression id filter.
Returns
listResolved child node list.
def getChildNodesPROXY(self, proxy, REQUEST={}, meta_types=None, reid=None): (source)

Return child nodes for the active proxy or referenced object.

Recursively embedded elements expose proxied child nodes. Direct embedded elements expose non-page children of the referenced object. Overrides original method of zmscontainerobject.ZMSContainerObject.

Parameters
proxy:objectActive proxy object.
REQUEST:dictCurrent request context.
meta_types:list | NoneOptional meta type filter.
reid:str | NoneOptional regular-expression id filter.
Returns
listChild nodes visible through the embedding context.
def getEmbedType(self): (source)

Return the configured embedding mode for this link element.

Special handling for _embed_type, because it is a raw attribute and not a property. The value is stored as the raw attribute _embed_type. If it is not set, the method falls back to the legacy object property attr_type.

Returns
str | NoneEmbedding mode such as 'embed', 'recursive', 'remote', or an empty value.
def getHref2IndexHtml(self, REQUEST, deep=1): (source)

Return the index HTML URL for this link element.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
deep:intDepth flag forwarded to the proxy lookup.
Returns
strResolved index HTML URL.
def getHref2IndexHtmlPROXY(self, proxy, REQUEST, deep=1): (source)

Return the index HTML URL resolved through the current proxy context.

Parameters
proxy:objectActive proxy object.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
deep:intDepth flag forwarded to the base implementation.
Returns
strResolved index HTML URL.
def getLevel(self): (source)

Return the effective hierarchy level of this element.

def getLevelPROXY(self, proxy): (source)

Return the level resolved through the active proxy context. For recursively embedded elements the level is delegated to the proxy. For directly embedded elements the level is calculated based on the parent node level unless the parent is the same as the proxy, in which case it is treated as the root of the embedding context and assigned level 0.

Parameters
proxy:objectActive proxy object.
Returns
intEffective hierarchy level for this element.
def getNavElements(self, REQUEST, expand_tree=1, current_child=None, subElements=[]): (source)

Return navigation elements for this link element.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
expand_tree:intFlag controlling tree expansion.
current_child:object | NoneCurrently selected child node.
subElements:listAccumulator for nested elements.
Returns
listNavigation elements visible for this element.
def getNavElementsPROXY(self, proxy, REQUEST, expand_tree=1, current_child=None, subElements=[]): (source)

Return navigation elements for the current proxy context.

Parameters
proxy:objectActive proxy object.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
expand_tree:intFlag controlling tree expansion.
current_child:object | NoneCurrently selected child node.
subElements:listAccumulator for nested elements.
Returns
listNavigation elements visible through the embedding context.
def getNavItems(self, current, REQUEST, opt={}, depth=0): (source)

Return navigation items for this element.

Parameters
current:objectCurrent navigation node.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
opt:dictNavigation options.
depth:intCurrent navigation depth.
Returns
listNavigation items visible for this element.
def getNavItemsPROXY(self, proxy, current, REQUEST, opt={}, depth=0): (source)

Return navigation items for the current proxy context. Overrides getNavItems of zmscontainerobject.ZMSContainerObject.

Parameters
proxy:objectActive proxy object.
current:objectCurrent navigation node.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
opt:dictNavigation options.
depth:intCurrent navigation depth.
Returns
listNavigation items visible through the embedding context.
def getObjProperty(self, key, REQUEST={}, default=None): (source)

Return a property value from this element, its proxy, or its reference.

The method first checks the link element itself, then falls back to the local base implementation, recursive proxies, or the referenced object, depending on the embedding mode.

Parameters
key:strAttribute identifier.
REQUEST:dictRequest context used for multilingual and preview values.
default:anyDefault value when no property can be resolved.
Returns
anyResolved property value.
def getObjPropertyPROXY(self, proxy, key, REQUEST={}, default=None): (source)

Read an object property directly from the supplied proxy object. Overrides getObjProperty of _objattrs.ObjAttrs.

Parameters
proxy:objectObject or proxy that owns the attribute.
key:strAttribute identifier.
REQUEST:dictRequest context used for multilingual values.
default:anyUnused compatibility parameter.
Returns
anyAttribute value resolved from the proxy.
def getParentNode(self): (source)

The parent of this node. All nodes except root may have a parent.

def getParentNodePROXY(self, proxy): (source)

Return the parent node visible through the current proxy context.

def getProxy(self): (source)

Return the cached proxy object for this (embedding) link element.

The proxy is stored in the request so repeated rendering and traversal use the same resolved object.

Returns
objectThis element or its request-cached proxy.
def getRef(self): (source)

Return the stored link target reference.

The reference is read from attr_ref in the language derived from the current coverage value.

Returns
strLink target reference string.
def getRefObj(self): (source)

Resolve and cache the referenced object for this link element.

The lookup result is buffered in the request to avoid repeated traversal and link resolution while rendering a page.

Returns
object | NoneReferenced object or None if the target cannot be resolved.
def getRemoteObj(self): (source)

Fetch remote metadata for a link element with embed type 'remote'.

The returned mapping is expected to be JSON produced by the remote REST API endpoint for the current language.

Returns
dictParsed JSON payload from the remote object, or an empty mapping on failure.
def getSelf(self, meta_type=None): (source)

Return the effective object for this link element.

Parameters
meta_type:str | NoneOptional meta type constraint.
Returns
objectThe resolved object for this element or its proxy.
def getSelfPROXY(self, proxy, meta_type=None): (source)

Resolve the effective object for the proxy context.

Parameters
proxy:objectProxy or referenced object to resolve against.
meta_type:str | NoneOptional meta type constraint.
Returns
objectThe resolved object for the current proxy context.
def getTitle(self, REQUEST): (source)

Return the display title for this element.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
strResolved title or a fallback display type label.
def getTitlealt(self, REQUEST): (source)

Return the alternate title for this element.

Remote embeddings read the value from the remote payload; other modes use the local proxy or referenced object and fall back to the display type.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
strAlternate title string.
def getTitlealtPROXY(self, proxy, REQUEST): (source)

Resolve the alternate title through the proxy or reference chain.

Parameters
proxy:objectActive proxy object.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
strAlternate title resolved for the current embedding context.
def getTitlePROXY(self, proxy, REQUEST): (source)

Resolve the title through the proxy or reference chain.

Parameters
proxy:objectActive proxy object.
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
strTitle resolved for the current embedding context.
def getTreeNodes(self, REQUEST={}, meta_types=None): (source)

Return an empty tree node list for link elements.

Link elements do not contribute their own tree structure here. If none, this is a empty node list.

Parameters
REQUEST:dictCurrent request context.
meta_types:list | NoneOptional meta type filter.
Returns
listEmpty node list.
def getType(self): (source)

Return the effective type for this link element.

def getTypePROXY(self, proxy): (source)

Return the effective type resolved through embedding or proxying. Overrides getType of zmscustom.ZMSCustom.

Parameters
proxy:objectActive proxy object.
Returns
strEffective type.
def initProxy(self, base, url_base, proxy, recursive=False): (source)

Create a ZMSProxyObject for a resolved embedded target.

Parameters
base:objectAcquisition base for the proxy.
url_base:strAbsolute URL base for the proxy.
proxy:objectReferenced object that should be exposed as proxy.
recursive:boolFlag indicating recursive embedding.
Returns
ZMSProxyObjectProxy object wrapping the referenced node.
def isActive(self, REQUEST): (source)

Return whether the element is active in the current request context.

Embedded and remote link elements additionally respect the resolved target activity state.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent request context.
Returns
boolTrue if the element should be treated as active.
def isEmbedded(self, REQUEST=None): (source)

Return whether this element renders another object inline.

def isEmbeddedRecursive(self, REQUEST=None): (source)

Return whether this element uses recursive embedding.

def isMetaType(self, meta_type, REQUEST={'preview': 'preview'}): (source)

Return whether this element matches the requested meta type.

Parameters
meta_type:str | listMeta type or list of meta types to test.
REQUEST:dictRequest context used by downstream checks.
Returns
boolTrue if this element or its resolved target matches.
def isMetaTypePROXY(self, proxy, meta_type, REQUEST={'preview': 'preview'}): (source)

Check whether this element or its resolved target matches a meta type.

For recursively embedded elements the check is delegated to the proxy. For directly embedded elements it also checks the referenced object unless the special NOREF or NORESOLVEREF markers suppress resolution.

Parameters
proxy:objectActive proxy object.
meta_type:str | listMeta type or list of meta types to test.
REQUEST:dictRequest context used by downstream checks.
Returns
boolTrue if the element or resolved target matches.
def isPage(self): (source)

Return whether this element resolves to a page-like target. Embedded and remote link elements are treated as pages when their resolved target has the corresponding flag set.

Returns
boolTrue if this element should be treated as a page-like target.
def isPageContainer(self): (source)

Return False because link elements are never page containers.

Returns
boolFalse because link elements are never page containers.
def isPageElement(self): (source)

Return whether this element behaves like a page element. Embedded and remote link elements are treated as page elements when their resolved target has the corresponding flag set.

Returns
boolTrue if this element should be treated as a page element.
def manage_changeProperties(self, lang, REQUEST, RESPONSE): (source)

Update link element properties from the ZMI form submission.

The method stores XML-backed properties, marks the object as modified, recalculates the raw embed type, and redirects back to the management UI with a status message.

Parameters
lang:strActive management language, usually a three-letter ZMS language id such as 'eng' or 'ger'.
REQUEST:ZPublisher.HTTPRequestCurrent ZMI request containing edited attribute values (especially XML-backed object attributes and attr_type).
RESPONSE:ZPublisher.HTTPResponseResponse used for the redirect back to the management UI.
Returns
ZPublisher.HTTPResponseRedirect response pointing back to the management form.
def manage_options(self): (source)

Handle the ZMI action 'manage_options'.

def printHtml(self, level, sectionizer, REQUEST, deep=True): (source)

Return the printable HTML for this link element.

Parameters
level:intCurrent print depth.
sectionizer:anyHelper used to build printable section numbering.
REQUEST:ZPublisher.HTTPRequestCurrent rendering request.
deep:boolIf true, render nested content recursively.
Returns
strPrintable HTML fragment.
def printHtmlPROXY(self, proxy, level, sectionizer, REQUEST, deep=True): (source)

Render the printable HTML through the current proxy or reference.

Recursive embeddings delegate to the proxy tree, while direct embeddings delegate to the referenced object.

Parameters
proxy:objectActive proxy object for recursive rendering.
level:intCurrent print depth.
sectionizer:anyHelper used to build printable section numbering.
REQUEST:ZPublisher.HTTPRequestCurrent rendering request.
deep:boolIf true, render nested content recursively.
Returns
strPrintable HTML fragment.
def renderShort(self, REQUEST): (source)

Render the compact presentation of the link element.

Embedded links delegate to the referenced object when possible, while non-embedded links fall back to the regular body rendering.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent rendering request.
Returns
strShort HTML rendering for the element.
def setEmbedType(self, REQUEST): (source)

Persist the requested embedding mode on the raw _embed_type attribute.

Special handling for _embed_type, because it is a raw attribute and not a property. If the selected mode would recursively embed an ancestor, the value is replaced with 'cyclic' so callers can react to the invalid state.

Expected values for REQUEST['attr_type'] are for example 'embed', 'recursive', 'remote', or an empty string for a plain non-embedded link. Cyclic recursive references are normalized to 'cyclic'.

Parameters
REQUEST:ZPublisher.HTTPRequestRequest carrying the submitted attr_type value.
Returns
NoneNone
__ac_permissions__ = (source)

Undocumented

__authorPermissions__: tuple[str, ...] = (source)

Undocumented

getParentNode__roles__ = (source)

Undocumented

meta_id: str = (source)

Undocumented

meta_type: str = (source)

Undocumented

security = (source)

Undocumented

def _getBodyContent(self, REQUEST): (source)

Render the body content for the link element (as HTML).

Depending on the embedding mode this may use remote content, a recursive proxy, the referenced object, or the local template output.

Parameters
REQUEST:ZPublisher.HTTPRequestCurrent rendering request.
Returns
strRendered HTML body for the element.
_embed_type = (source)

Undocumented