review_state
from Products.CMFCore.utils import getToolByName wtool = getToolByName(context, "portal_workflow") wf_state = wtool.getInfoFor(obj,'review_state',None)
DZone Snippets > morlandi > plone
12158 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
from Products.CMFCore.utils import getToolByName wtool = getToolByName(context, "portal_workflow") wf_state = wtool.getInfoFor(obj,'review_state',None)
from AccessControl import Unauthorized from Products.CMFPlone.utils import transaction_note from Products.CMFPlone import PloneMessageFactory as _ REQUEST = context.REQUEST if REQUEST.get('REQUEST_METHOD', 'GET').upper() == 'GET': raise Unauthorized, 'This method can not be accessed using a GET request' parent = context.aq_inner.aq_parent parent.manage_delObjects(context.getId()) message = _(u'${title} has been deleted.', mapping={u'title' : context.title_or_id()}) transaction_note('Deleted %s' % context.absolute_url()) context.plone_utils.addPortalMessage(message) return state.set(status = 'success')
this will show the number rows returned (which would be 3 in the example above).
a list of all the column headings, returning a list containing emp_id, first, last and salary
returns a list of tuples in our example:
[(43, 'Bob', 'Roberts', 50000),
(101, 'Cheeta', 'leCat', 100000),
(99, 'Jane', 'Junglewoman', 100001)]
will return a list of dictionaries, with one dictionary for each row:
[{'emp_id': 42, 'first': 'Bob','last': 'Roberts', 'salary': 50000},
{'emp_id': 101, 'first: 'Cheeta', 'last': 'leCat', 'salary': 100000},
{'emp_id': 99, 'first': 'Jane', 'last': 'Junglewoman', 'salary': 100001}]
returns a dictionary describing the structure of the results table.
The dictionary has the key name, type, null and width.
Name and type are self explanatory, null is true if that field may contain a null value and width is the width in characters of the field.
Note that null and width may not be set by some Database Adapters.
displays the result in a similar way to a relational database.
The DTML below displays the result below:
<pre>
<dtml-var "list_all_employees().asRDB()">
</pre>
... displays ...
emp_id first last salary
42 Bob Roberts 50000
101 Cheeta leCat 100000
99 Jane Junglewoman 100001
return row 0, column 1 of the result, bob in this example.
Be careful using this method as changes in the schema will cause unexpected results.
print "Dead Content Type Inspector" print for i in context.portal_catalog.uniqueValuesFor('portal_type'): if i in context.portal_types: continue print i results = context.portal_catalog(portal_type=i) for i in results: print i.getURL() print print return printed
DSN=LocalServer; DATABASE=GammaMedidata; UID=sa; PWD=******;
DRIVER=SQL Server; SERVER=(local); UID=sa; PWD=****; DATABASE=wam
dbcobraf@www2.cobraf.com cobraf 'password'
p.Members.contentItems(filter={'portal_type':['Folder',]})
purchaseBrains = context.portal_catalog.searchResults( portal_type='Purchase', getPurchaseId = 1000 ) if len(purchaseBrains)==1: purchase = purchaseBrains[0].getObject() print purchase objs = purchase.contentItems(filter={'portal_type':['SalesAttachment',]}) ids = [] for obj in objs: id = obj[0] print id ids.append(id) print ids purchase.manage_delObjects(ids=ids) return printed
portal = context.portal_url.getPortalObject() photosFolder = getattr(portal,'photos')
photosFolder = portal.restrictedTraverse('projects/picture-masking-service/incoming-pictures/')
m = pm.getAuthenticatedMember() pm = context.portal_membership mf = pm.getHomeFolder()
mf = pm.getHomeFolder(userId)
request = context.REQUEST ... request.RESPONSE.redirect(request.HTTP_REFERER) ...