[CMF-checkins] CVS: Products/CMFDefault/skins/zpt_generic - get_permalink.py:1.2

Yvo Schubbe y.2005- at wcm-solutions.de
Sun Mar 13 14:08:30 EST 2005


Update of /cvs-repository/Products/CMFDefault/skins/zpt_generic
In directory cvs.zope.org:/tmp/cvs-serv30580/CMFDefault/skins/zpt_generic

Added Files:
	get_permalink.py 
Log Message:
forward-porting CMFUid related changes from CMF-1_5-branch


=== Products/CMFDefault/skins/zpt_generic/get_permalink.py 1.1 => 1.2 ===
--- /dev/null	Sun Mar 13 14:08:30 2005
+++ Products/CMFDefault/skins/zpt_generic/get_permalink.py	Sun Mar 13 14:08:30 2005
@@ -0,0 +1,25 @@
+## Script (Python) "get_permalink"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=Returns the permalink url or None
+##
+from Products.CMFCore.utils import getToolByName
+
+# calculate the permalink if the uid handler tool exists, permalinks
+# are configured to be shown and the object is not folderish
+uidtool = getToolByName(context, 'portal_uidhandler', None)
+if uidtool is not None:
+    proptool = getToolByName(context, 'portal_properties', None)
+    showPermalink = getattr(proptool, 'enable_permalink', None)
+    isFolderish = getattr(context.aq_explicit, 'isPrincipiaFolderish', None)
+    
+    if showPermalink and not isFolderish:
+        # returns the uid (generates one if necessary)
+        urltool = getToolByName(context, 'portal_url')
+        uid = uidtool.register(context)
+        url = "%s/permalink/%s" % (urltool(), uid)
+        return url



More information about the CMF-checkins mailing list