List Info

Thread: Scripting ZOPE/Plone installation




Scripting ZOPE/Plone installation
user name
2006-09-28 14:49:39
Hi,

I'm in the progress of setting up a medium sized Plone installation. I'm very new to Python/Zope/Plone, so am struggling a little.

What I would like to be able to do is write a script to build the entire Zope/Plone instance from sources and the configure it automatically via 'zopectl run <script>'.

The setup is as follows:
Zope 2.8.7-final
  ZEO server
  4 zope clients
Plone 2.1.4

I've built a bash script which builds and installs the sources and then re-writes the config files to point at the ZEO server. I then want to create a folder in the root of the Zope instance to hold several Plone sites. So far, I've been able to create the folder with:
app.manage_addFolder('plone_sites','Plone Sites')
get_transaction().commit()

Which results in...
-c:1: DeprecationWarning: This will be removed in ZODB 3.6:
   use transaction.get() instead of get_transaction().
   transaction.commit() is a shortcut spelling of transaction.get().commit(),
   and transaction.abort() of transaction.get().abort().

I've tried using the methods described in the warning, but with no success...
>>&gt; transaction.commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'transaction' is not defined
&gt;>> app.transaction.commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: transaction
>>> transaction.get().commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'transaction' is not defined
&gt;>> app.transaction.get().commit()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: transaction

Anyway, as the folder gets created I'm not too worried about this.

The next step is to create the Plone sites. Looking through the CMFPlone folder I've discovered the method manage_addSite which looks like it is being called by the ZMI on site creation, so...

plone_sites_folder = getattr(app, 'plone_sites')
plone_sites_folder.manage_addProduct['CMFPlone'].manage_addSite( id='cms', title='CMS', description='A CMS')

gives the error...

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 437, in create
    self.setupPlone(p)
  File "/home/zope/client0/Products/CMFPlone/Portal.py", line 384, in setupPlone
    self.setupPortalContent(p)
  File "/home/zope/client0/Products/CMFPlone/Portal.py", line 223, in setupPortalContent
    p.invokeFactory('Large Plone Folder', 'Members')
  File "/home/zope/client0/Products/CMFCore/PortalFolder.py", line 408, in invokeFactory
    return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
  File "/home/zope/client0/Products/CMFCore/TypesTool.py", line 925, in constructContent
    ob = info.constructInstance(container, id, *args, **kw)
  File "/home/zope/client0/Products/CMFCore/TypesTool.py", line 333, in constructInstance
    raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
AccessControl.unauthorized.Unauthorized: Cannot create Large Plone Folder

So, I've looked into authentication, and tried...

from AccessControl.SecurityManagement import newSecurityManager
newSecurityManager(None, 'adminuser')
plone_sites_folder.manage_addProduct['CMFPlone'].manage_addSite( id='cms', title='CMS', description='A CMS')

gives...
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", line 295, in _setObject
    object.manage_fixupOwnershipAfterAdd()
  File "/home/zope/zope-2.8/lib/python/AccessControl/Owned.py", line 257, in manage_fixupOwnershipAfterAdd
    self.changeOwnership(user)
  File "/home/zope/zope-2.8/lib/python/AccessControl/Owned.py", line 147, in changeOwnership
    new=ownerInfo(user)
  File "/home/zope/zope-2.8/lib/python/AccessControl/Owned.py", line 287, in ownerInfo
    uid=user.getId()
AttributeError: 'str' object has no attribute 'getId'

So I guess that isn't much use.

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!

Thanks

Duncan
-- 
Duncan Mortimer
duncanfmrib.ox.ac.uk">duncanfmrib.ox.ac.uk



Scripting ZOPE/Plone installation
user name
2006-09-28 16:01:13
Duncan Mortimer wrote:

> get_transaction().commit()
> 
> Which results in...
> -c:1: DeprecationWarning: This will be removed in ZODB
3.6:
>    use transaction.get() instead of get_transaction().
Yes this is deprecated but still works - for future proofing
you might 
want one the newer command.

Add the line  "import transaction" to the top of
your script to make the 
newer one. It was that missing, which made it not work for
you before.

> The next step is to create the Plone sites. Looking
through the CMFPlone 
> folder I've discovered the method manage_addSite which
looks like it is 
> being called by the ZMI on site creation, so...
> 
> plone_sites_folder = getattr(app, 'plone_sites')
>
plone_sites_folder.manage_addProduct['CMFPlone'].manage_addS
ite( 
> id='cms', title='CMS', description='A CMS')
> AccessControl.unauthorized.Unauthorized: Cannot create
Large Plone Folder
> 
> So, I've looked into authentication, and tried...
That's the right approach - the reason for your error was
exactly what 
you thought, you need to become admin user first.


> 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.


Cheers
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
Scripting ZOPE/Plone installation
user name
2006-10-04 07:14:01
Duncan Mortimer wrote:
> Hi,
> 
> I'm in the progress of setting up a medium sized Plone
installation. I'm
> very new to Python/Zope/Plone, so am struggling a
little.
> 
> What I would like to be able to do is write a script to
build the entire
> Zope/Plone instance from sources and the configure it
automatically via
> 'zopectl run <script>'.

For automating this stuff, you might want to look at
instancemanager
(http://plo
ne.org/products/instance-manager) and zope corp.'s
buildout
(http://www.zope.
org/DevHome/Buildout).

With multiple zeo backends and building from source: sounds
a bit like
buildout.

Reinout


-- 
Reinout van Rees                       r.van.rees 
zestsoftware.nl
http://vanrees.org/weblog/
                  http://zestsoftware.nl/
"Military engineers build missiles. Civil engineers
build targets."


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

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