Never been to DZone Snippets before?

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

About this user

Mario Orlandi

« Newer Snippets
Older Snippets »
Showing 11-16 of 16 total

Dead Content Type Inspector

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

Db Connection

// eGenix mxODBC Database Connection: connection string sample
DSN=LocalServer;
DATABASE=GammaMedidata;
UID=sa;
PWD=******;


// eGenix mxODBC Database Connection: connection string sample
DRIVER=SQL Server;
SERVER=(local);
UID=sa;
PWD=****;
DATABASE=wam


// MySQL connection string sample
dbcobraf@www2.cobraf.com cobraf 'password'

contentItems()

p.Members.contentItems(filter={'portal_type':['Folder',]})

// Search a specific Purchase, then remove all SalesAttachment from it
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

get folder object

portal = context.portal_url.getPortalObject()
photosFolder = getattr(portal,'photos')


photosFolder = portal.restrictedTraverse('projects/picture-masking-service/incoming-pictures/')

getHomeFolder

// retrieving the home folder of the current user
m = pm.getAuthenticatedMember()
pm = context.portal_membership
mf = pm.getHomeFolder()

// retrieving the home folder of the a specific user
mf = pm.getHomeFolder(userId)

redirect

request = context.REQUEST
...
request.RESPONSE.redirect(request.HTTP_REFERER)
...
« Newer Snippets
Older Snippets »
Showing 11-16 of 16 total