Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Johan Beyers
committed
Aug 19, 2011
1 parent
5dc71ec
commit a1d4fba
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
# Snippets for plone | |||
# catalog queries | |||
snippet pc | |||
from Products.CMFCore.utils import getToolByName | |||
from DateTime import DateTime | |||
pc = getToolByName(${1:self.context}, 'portal_catalog') | |||
query = {'portal_type' : '${2}', | |||
'review_state' : '${3:published}', | |||
'sort_on' : 'getObjPositionInParent', | |||
'sort_order' : 'reverse', | |||
'path' : {'query' : '/'.join(portal.getPhysicalPath()), | |||
'depth' : 1}, | |||
'getEnd' : {'query' : DateTime(), | |||
'range' : 'max' | |||
} | |||
} | |||
brains = pc(query) | |||
|
|||
# members, users | |||
snippet pm | |||
pm = getToolByName(${1:self.context}, 'portal_membership') | |||
user = pm.getAuthenticatedMember() | |||
if not pm.checkPermission('${2}', ${3:self.context}): | |||
return False | |||
|
|||
# Getting the portal | |||
snippet pu | |||
portal_url = getToolByName(${1:self.context}, 'portal_url') | |||
portal = portal_url.getPortalObject() | |||
|
|||
# Boilerplate for zctl files | |||
snippet bp_zctl | |||
""" Run this script to ${1}. | |||
|
|||
Run via ./bin/instance run <filename> | |||
""" | |||
|
|||
import transaction | |||
from AccessControl.SecurityManagement import newSecurityManager | |||
from Products.CMFCore.utils import getToolByName | |||
|
|||
user = app.acl_users.getUser('admin') | |||
newSecurityManager(None, user.__of__(app.acl_users)) | |||
portal = app['ShipTrack'] | |||
|
|||
${2:# Your code here} | |||
|
|||
transaction.commit() |