Sektionen
Benutzerspezifische Werkzeuge
Sie sind hier: Startseite Support Dokumentation docs Plone: globale Variablen und Methoden

Plone: globale Variablen und Methoden

In Plone sind viele globale Variablen verfügbar. Hier sind einige davon aufgelistet.

Plone view

Die foglenden Variablen und Methoden stehen unter Plone3 in jedem Template zur Verfügung und können in Python Code über die view selbst auch verwendet werden. Unter Plone 4 sind müssen die benötigten Teile im Kopf des Templates definiert werden.

Variablen

see: Products/CMFPlone/browser/interfaces.py >> IPlone

A method which puts all of the following view attributes into the globals of the current tal expression context (plus the toLocalizedTime method):

atool = Attribute("The portal_actions tool")

utool = Attribute("The portal_url tool")

portal = Attribute("The portal object itself")

portal_url = Attribute("The portal url")

mtool = Attribute("The portal_membership tool")

putils = Attribute("The plone_utils tool (PloneTool)")

wtool = Attribute("The portal_workflow tool")

ifacetool = Attribute("The portal_interface tool")

syntool = Attribute("The portal_syndication tool")

portal_title = Attribute("The title of the portal")

object_title = Attribute("The title of the current object (context)")

member = Attribute("The member object for the authenticated user in "
"context")

checkPermission = Attribute("The checkPermission method of the membership"
" tool")

membersfolder = Attribute("The portal's Members folder")

isAnon = Attribute("Boolean indicating whether the current user is "
"anonymous")

in Scripten analog: portal_membership.isAnonymousUser()

actions = Attribute("The result of listFilteredActionsFor(context) in the "
"portal_actions tool")

keyed_actions = Attribute("A mapping of action categories to action ids "
"to action information: "
"mapping[cat][id] == actioninfo")

user_actions = Attribute("Actions in the user category")

workflow_actions = Attribute("Actions in the workflow category")

folder_actions = Attribute("Actions in the folder category")

global_actions = Attribute("Actions in the global category")

portal_tabs = Attribute("The actions for the portal tabs")

wf_state = Attribute("The review_state of the current object")

portal_properties = Attribute("The portal_properties tool")

site_properties = Attribute("The site_properties tool")

ztu = Attribute("The ZTUtils module")

isFolderish = Attribute("A boolean indicating whether the object is "
"folderish")

here_url = Attribute("The url of the current object")

sl = Attribute("True if the left slot should be shown")

sr = Attribute("True if the right slot should be shown")

hidecolumns = Attribute("The css class to use for the column container"
"which determines which columns to show")

default_language = Attribute("The default language of the portal")

language = Attribute("The language of the current request or context.")

is_editable = Attribute("A boolean indicating if the current user has "
" edit permissions in this context")

isLocked = Attribute("A boolean indicating that the object is webdav "
"locked")

isRTL = Attribute("A boolean indicating that the current language is a "
"right-to-left language.")

visible_ids = Attribute("A boolean indicating whether to show object ids "
"to the current user")

current_page_url = Attribute("The full url with query string")

isContextDefaultPage = Attribute("Boolean indicating that the context is "
"the default page of its parent folder.")

isStructuralFolder = Attribute("Boolean indicating that the context is a "
"'Structural Folder'.")

Iterator = Attribute("A factory for generating sinple integer Iterators.")

tabindex = Attribute("An iterator for use in creating tabindexes.")

uniqueItemIndex = Attribute("An iterator for help inc reading unique "
"html ids.")
"""

Methoden

see: Products/CMFPlone/browser/interfaces.py >> IPlone

def getCurrentUrl():
""" Returns the actual url plus the query string. """

def keyFilteredActions(actions=None):
""" Returns a mapping of action categories to action ids to action
information: mapping[cat][id] == actioninfo

Optionally takes an action list, if ommitted it will be calculated
"""

def visibleIdsEnabled():
"""Determines whether to show object ids based on portal and user
settings.
"""

def isRightToLeft(domain='plone'):
"""Is the currently selected language a right to left language"""

def toLocalizedTime(time, long_format=None, time_only = None):
""" The time parameter must be either a string that is suitable for
initializing a DateTime or a DateTime object. Returns a localized
string.
"""

def isDefaultPageInFolder():
""" Returns a boolean indicating whether the current context is the
default page of its parent folder.
"""

def isStructuralFolder():
"""Checks if a given object is a "structural folder".

That is, a folderish item which does not explicitly implement
INonStructuralFolder to declare that it doesn't wish to be treated
as a folder by the navtree, the tab generation etc.
"""

def hide_columns(self, column_left, column_right):
""" Returns the CSS class used by the page layout hide empty
portlet columns.
"""

def navigationRootPath():
"""Get the current navigation root path
"""

def navigationRootUrl():
"""Get the url to the current navigation root
"""

def getParentObject():
"""Returns the parent of the current object, equivalent to
aq_inner(aq_parent(context)), or context.aq_inner.getParentNode()
"""

def getCurrentFolder():
"""If the context is the default page of a folder or is not itself a
folder, the parent is returned, otherwise the object itself is
returned.  This is useful for providing a context for methods
which wish to act on what is considered the current folder in the
ui.
"""

def getCurrentFolderUrl():
"""Returns the URL of the current folder as determined by
self.getCurrentFolder(), used heavily in actions.
"""

def getCurrentObjectUrl():
"""Returns the URL of the current object unless that object is a
folder default page, in which case it returns the parent.
"""

def isFolderOrFolderDefaultPage():
"""Returns true only if the current object is either a folder (as
determined by isStructuralFolder) or the default page in context.
"""

def isPortalOrPortalDefaultPage():
"""Returns true only if the current object is either the portal object
or the default page of the portal.
"""

def getViewTemplateId():
"""Returns the template Id corresponding to the default view method of
the context object.
"""

def showEditableBorder():
"""Returns true if the editable border should be shown
"""

def displayContentsTab():
"""Returns true if the contents tab should be displayed in the current
context.  Evaluates whether the object is a folder or the default
page of a folder, and checks if the user has relevant permissions.
"""

def getIcon(item):
"""Returns an object which implements the IContentIcon interface and
provides the informations necessary to render an icon.
The item parameter needs to be adaptable to IContentIcon.
Icons can be disabled globally or just for anonymous users with
the icon_visibility property in site_properties."""

def cropText(text, length, ellipsis):
""" Crop text on a word boundary """

def have_portlets(manager_name, view=None):
"""Determine whether a column should be shown."""

 

 

Weitere globale Methoden

In plone.app.layout sind weitere nützliche Methoden definiert die wie folgt verwendet werden können.

Es gibt die folgenden thematischen Views.

  • plone_tools
  • plone_context_state
  • plone_portal_state


Auf diese kann in Zope Page Templates wie folgt zu gegriffen werden.

<div tal:define="pstate     @@plone_portal_state;">
<span tal:content="pstate/portal_title">Portal Title</span>
</div>

In einem Page Template welches man TTW erstellt hat, wie folgt:

<div tal:define="pstate     here/@@plone_portal_state;">
<span tal:content="pstate/portal_title">Portal Title</span>
</div>

In Python funktioniert die Verwendung wie folgt:

from zope.component import getMultiAdapter
pstate = getMultiAdapter((self.context, self.request), name='plone_portal_state')
portal_title = pstate.portal_title()

plone_tools

In den plone_tools sind folgende Methoden verfügbar:

def actions():
"""The portal_actions tool
"""

def catalog():
"""The portal_catalog tool
"""

def membership():
"""The portal_membership tool
"""

def properties():
"""The portal_properties tool
"""

def syndication():
"""The portal_syndication tool
"""

def types():
"""The portal_types tool
"""

def url():
"""The portal_url tool"""

def workflow():
"""The portal_workflow tool"""

plone_portal_state

In plone portal state sind folgende Methoden verfügbar:

def portal():
"""The portal object
"""

def portal_title():
"""The title of the portal object
"""

def portal_url():
"""The URL of the portal object
"""

def navigation_root_path():
""" path of the navigation root
"""

def navigation_root_url():
"""The URL of the navigation root
"""

def default_language():
"""The default language in the portal
"""

def language():
"""The current language
"""

def locale():
"""Get the current locale
"""

def is_rtl():
"""Whether or not the portal is being viewed in an RTL language
"""

def member():
"""The current authenticated member
"""

def anonymous():
"""Whether or not the current member is Anonymous
"""

def friendly_types():
"""Get a list of portal types considered "end user" types
"""

plone_context_state

In plone context state sind folgende Methoden verfügbar:

def current_page_url():
"""The URL to the current page, including template and query string.
"""

def current_base_url():
"""The current "actual" URL from the request, excluding the query
string.
"""

def canonical_object():
"""The current "canonical" object.

That is, the current object unless this object is the default page
in its folder, in which case the folder is returned.
"""

def canonical_object_url():
"""The URL to the current "canonical" object.

That is, the current object unless this object is the default page
in its folder, in which case the folder is returned.
"""

def view_url():
"""URL to use for viewing

Files and Images get downloaded when they are directly
called, instead of with /view appended. We want to avoid that.
"""

def view_template_id():
"""The id of the view template of the context
"""

def is_view_template():
"""Return True if the currentl URL (in the request) refers to the
standard "view" of the context (i.e. the "view" tab).
"""

def object_url():
"""The URL of the current object
"""

def object_title():
"""The prettified title of the current object
"""

def workflow_state():
"""The workflow state of the current object
"""

def parent():
"""The direct parent of the current object
"""

def folder():
"""The current canonical folder
"""

def is_folderish():
"""True if this is a folderish object, structural or not
"""

def is_structural_folder():
"""True if this is a structural folder
"""

def is_default_page():
"""True if this is the default page of its folder
"""

def is_portal_root():
"""True if this is the portal or the default page in the portal
"""

def is_editable():
"""Whether or not the current object is editable
"""

def is_locked():
"""Whether or not the current object is locked
"""

def actions():
"""The filtered actions in the context
"""

def keyed_actions():
"""A mapping of action categories to action ids to
action information: mapping[cat][id] == actioninfo
"""

def portlet_assignable():
"""Whether or not the context is capable of having locally assigned
portlets.
"""