List Info

Thread: Scripting ZOPE/Plone installation




Scripting ZOPE/Plone installation
user name
2006-09-28 16:38:47
Thanks for the quick reply, but it fails with a different
error! The  
following is from a zopectl debug shell...

 >>> import transaction
 >>> from AccessControl.SecurityManagement import
newSecurityManager
 >>> adminuser = app.acl_users.getUser('adminuser')
 >>> newSecurityManager(None, adminuser)
 >>> plone_sites_folder = getattr(app,
'plone_sites')
 >>>
plone_sites_folder.manage_addProduct['CMFPlone'].manage_addS
ite 
( id='test', title='test', description='test')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File
"/home/zope/client0/Products/CMFPlone/Portal.py",
line 465,  
in manage_addSite
     p = gen.create(self, id.strip(), create_userfolder)
   File
"/home/zope/client0/Products/CMFPlone/Portal.py",
line 434,  
in create
     parent._setObject(id, portal)
   File
"/home/zope/zope-2.8/lib/python/OFS/ObjectManager.py&qu
ot;, line  
295, in _setObject
     object.manage_fixupOwnershipAfterAdd()
   File
"/home/zope/zope-2.8/lib/python/AccessControl/Owned.py&
quot;, line  
257, in manage_fixupOwnershipAfterAdd
     self.changeOwnership(user)
   File
"/home/zope/zope-2.8/lib/python/AccessControl/Owned.py&
quot;, line  
147, in changeOwnership
     new=ownerInfo(user)
   File
"/home/zope/zope-2.8/lib/python/AccessControl/Owned.py&
quot;, line  
289, in ownerInfo
     db=user.aq_inner.aq_parent
AttributeError: aq_inner

It does create something, as subsequent efforts report...

zExceptions.BadRequest: The id "test" is invalid -
it is already in use.

Thanks again.

On 28 Sep 2006, at 17:01, Nick Davis wrote:

> Duncan Mortimer wrote:
>
>> from AccessControl.SecurityManagement import
newSecurityManager
>> newSecurityManager(None, 'adminuser')
>>
plone_sites_folder.manage_addProduct['CMFPlone'].manage_addS
ite 
>> ( id='cms', title='CMS', description='A CMS')
>
> Here's your bug - you need this instead of your 2cnd
line:
>
> adminuser = app.acl_users.getUser('adminuser')
> newSecurityManager(None,adminuser)
>
>
>> I'd appreciate some help on the matter, and also
would like to put  
>> in a request for this kind of thing to be
documented somewhere -  
>> all the sites I can find just talk about using the
ZMI!
> This is a problem in general. I personally prefer your
approach of  
> creating stuff using code, and feel the ZMI can get in
the way. I  
> feel your pain here. 
>
> You would find DocFinderTab v useful if you've not
already got it.  
> google for DocFinderTab for more info.

I'll look into that.

Thanks again

Duncan
-- 
Duncan A B Mortimer DPhil MChem
                 Computing Officer, FMRIB Centre, University
of Oxford,
               John Radcliffe Hospital, Headington, Oxford
OX3 9DU, UK.
Tel: (0)1865 222713
WWW: http://www.fmrib.ox
.ac.uk/~duncan    email: duncanfmrib.ox.ac.uk



_______________________________________________
Setup mailing list
Setuplists.plone.org
http://
lists.plone.org/mailman/listinfo/setup
Scripting ZOPE/Plone installation
user name
2006-09-29 09:07:40
Duncan Mortimer wrote:
> Thanks for the quick reply, but it fails with a
different error! 
You are, however, making progress.  

>     db=user.aq_inner.aq_parent
> AttributeError: aq_inner
This is a common acquisition error, when you're doing things
that are 
normally done in the ZMI, in a script. I've found sometimes
by assigning 
an object to a variable in a script, it somehow loads it, or
"brings 
into scope". I have been somewhat in the dark, but
sometimes if you try 
to get at:

app.a.b.c.d

it helps if you first say -  x = app.a.b   y = app.a.b.c 
etc.

This seems to load stuff in that would've been pulled in
automatically 
if you were going via the ZMI.

Failing this, make sure the methods you are calling are not
"ZMI-only" 
i.e make assumptions that only hold when you're accessing
through Zope.

>> You would find DocFinderTab v useful if you've not
already got it.  
>> google for DocFinderTab for more info.
> 
> 
> I'll look into that.
BTW Docfinder tab basically collates all the python
docstrings and makes 
them helpfully viewable in the ZMI.

I like your approach to this. Really, it should be easy to
construct 
Zope/Plone objects with code, in a tidy modular way,
completely seperate 
from the ZMI. But instead its rather tangled up. I daresay
Zope 3 fixes 
this but we're not there yet.

Another thing I found hard to get used to, learning this,
was the heavy 
use of multiple inheritance.

It helps to use a proper debugger that can step through the
Zope 
library/API code, such as emacs (which we use on Linux), or
maybe 
BoaConstructor / WingIDE but I don't know those.....

Regards,
Nick

-- 
Nick Davis
Web Application Developer
University of Leicester
http://www2.le.ac.uk
http://ebulletin.le.ac.uk


_______________________________________________
Setup mailing list
Setuplists.plone.org
http://
lists.plone.org/mailman/listinfo/setup
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )