[CMF-checkins] SVN: CMF/branches/1.5/C Added tab to
'portal_uidhandler' tool to allow querying objects given UID.
Tres Seaver
tseaver at palladion.com
Tue Sep 13 08:18:42 EDT 2005
Log message for revision 38450:
Added tab to 'portal_uidhandler' tool to allow querying objects given UID.
Collector #383: thanks to Kevin McDermott for the patch.
Changed:
U CMF/branches/1.5/CHANGES.txt
U CMF/branches/1.5/CMFUid/UniqueIdHandlerTool.py
A CMF/branches/1.5/CMFUid/www/
A CMF/branches/1.5/CMFUid/www/queryUID.pt
-=-
Modified: CMF/branches/1.5/CHANGES.txt
===================================================================
--- CMF/branches/1.5/CHANGES.txt 2005-09-12 12:46:09 UTC (rev 38449)
+++ CMF/branches/1.5/CHANGES.txt 2005-09-13 12:18:41 UTC (rev 38450)
@@ -10,6 +10,9 @@
Others
+ - Collector #383: Added tab to 'portal_uidhandler' tool to allow
+ querying objects given UID.
+
- CMFCatalogAware: refactoring. Defines now 2 methods,
_getCatalogTool() and _getWorkflowTool(), that are used to find
the catalog and workflow tool. It's now possible to override
Modified: CMF/branches/1.5/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- CMF/branches/1.5/CMFUid/UniqueIdHandlerTool.py 2005-09-12 12:46:09 UTC (rev 38449)
+++ CMF/branches/1.5/CMFUid/UniqueIdHandlerTool.py 2005-09-13 12:18:41 UTC (rev 38450)
@@ -17,14 +17,18 @@
$Id$
"""
+import os
+
import Missing
import zLOG
from Globals import InitializeClass
+from Globals import package_home
from AccessControl import ClassSecurityInfo
from Acquisition import Implicit, aq_base
from OFS.SimpleItem import SimpleItem
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.CMFCore.utils import getToolByName, UniqueObject
from Products.CMFCore.ActionProviderBase import ActionProviderBase
@@ -37,6 +41,8 @@
UID_ATTRIBUTE_NAME = 'cmf_uid'
+_wwwdir = os.path.join( package_home( globals() ), 'www' )
+
class UniqueIdHandlerTool(UniqueObject, SimpleItem, ActionProviderBase):
__doc__ = __doc__ # copy from module
@@ -49,6 +55,15 @@
)
id = 'portal_uidhandler'
+
+ manage_options = ( ActionProviderBase.manage_options
+ + ( {'label':'Query',
+ 'action':'manage_queryObject'}
+ ,
+ )
+ + SimpleItem.manage_options
+ )
+
alternative_id = "portal_standard_uidhandler"
meta_type = 'Unique Id Handler Tool'
@@ -60,7 +75,7 @@
UniqueIdError = UniqueIdError
security = ClassSecurityInfo()
-
+
def _reindexObject(self, obj):
# add uid index and colums to catalog if not yet done
UID_ATTRIBUTE_NAME = self.UID_ATTRIBUTE_NAME
@@ -241,5 +256,8 @@
return self.unrestrictedGetObject(uid)
except UniqueIdError:
return default
-
+
+ security.declareProtected(ManagePortal, 'manage_queryObject')
+ manage_queryObject = PageTemplateFile('queryUID.pt', _wwwdir)
+
InitializeClass(UniqueIdHandlerTool)
Added: CMF/branches/1.5/CMFUid/www/queryUID.pt
===================================================================
--- CMF/branches/1.5/CMFUid/www/queryUID.pt 2005-09-12 12:46:09 UTC (rev 38449)
+++ CMF/branches/1.5/CMFUid/www/queryUID.pt 2005-09-13 12:18:41 UTC (rev 38450)
@@ -0,0 +1,31 @@
+<h1 tal:replace="structure context/manage_page_header">HEADER</h1>
+<h1 tal:replace="structure context/manage_tabs">TABS</h1>
+
+<h3>Query <code>portal_uid_handler</code> Tool </h3>
+
+<div tal:define="uid request/uid | nothing">
+<form action="." method="POST"
+ tal:attributes="action string:${context/absolute_url};"
+>
+ <input type="text" name="uid:int" value=""
+ tal:attributes="value uid" />
+ <input type="submit" name="manage_queryObject:method" value=" Query UID ">
+</form>
+
+<div tal:condition="uid"
+ tal:define="obj python:context.queryObject(uid, None);">
+ <div tal:condition="obj">
+ <strong>Found
+ <a href="#object_url"
+ tal:attributes="href obj/absolute_url"
+ tal:content="obj/getId">OBJECTID</a></strong>
+ </div>
+ <div tal:condition="not: obj">
+ <strong>No object matching uid
+ <span tal:content="uid">UID</span> found</strong>
+ </div>
+</div>
+
+</div>
+
+<h1 tal:replace="structure context/manage_page_footer">FOOTER</h1>
More information about the CMF-checkins
mailing list