[Product-Developers] Re: objects not saved in bin/instance run script
Alex Clark
aclark at aclark.net
Fri Aug 14 19:56:14 UTC 2009
On 2009-08-13, Maxfield <netropic at u.washington.edu> wrote:
>
> Appreciate any help with this, I have a feeling I'm missing
> some kind of unknown magic in here. I'm trying to add a
> new MutablePropertySheet to a MembraneUser...
Have you tried pdb stepping through?
>
>
> ---------begin----------------------------------
> from Testing import makerequest
> import transaction
> from Products.CMFCore.utils import getToolByName
> from Products.PlonePAS.sheet import MutablePropertySheet
> from AccessControl.SecurityManagement import newSecurityManager
> from AccessControl.User import system
> from Acquisition import aq_base
>
> import pdb
>
> objs = app.listDAVObjects()
>
> #
> # find the plone site
> #
> plone_site = None
> for o in objs:
> if o.__class__.__name__ is 'PloneSite':
> plone_site = o
>
> app = makerequest.makerequest(app)
> newSecurityManager(None,system)
>
> MYPROPSHEET = 'remote_properties'
> MYPROPTYPE = 'lines'
> MYPROPNAME = 'messages'
>
> acl_users = getToolByName(plone_site,'acl_users')
> howard = acl_users.getUserById('howard')
> psheets = howard.listPropertysheets()
>
> print psheets
>
> if MYPROPSHEET in psheets:
> print 'found propertysheet'
> else:
> print 'could not find "' + MYPROPSHEET + '" in propertysheets'
> try:
> new_sheet = MutablePropertySheet( MYPROPSHEET, [ ( MYPROPNAME, 'lines' ) ] )
> howard.addPropertysheet( MYPROPSHEET, new_sheet )
> except KeyError:
> print 'property sheet could not be found but also could not be added!'
> sys.exit(1)
>
> transaction.commit()
> ----------------end----------------------------
--
Alex Clark · http://aclark.net
Buy Practical Plone 3: http://tinyurl.com/practical-plone
More information about the Product-Developers
mailing list