[Zope3-Users] Run starup code with zope 3.

Sebastian Bartos seth.kriticos at googlemail.com
Thu Feb 12 11:50:27 EST 2009


Hi folks,

I'm struggling with some Zope 3 startup code. I registered a user like
this for the Session Credentials plugin and login form stuff:

...

    def create(self, data):
        site = getSite()
        sm = site.getSiteManager()

        if sm.has_key('auth'):
            return "Site is already set up"

        pau = Pluggableauth()
        sm['auth'] = pau
        sm.registerUtility(pau, Iauth)
        users = PrincipalFolder()
        sm['auth']['Users'] = users
        sm.registerUtility(users, IAuthenticatorPlugin, name="Users")
        pau.authenticatorPlugins = (users.__name__, )
        pau.credentialsPlugins = ("No Challenge if Authenticated",
                                  "Session Credentials")

        user = InternalPrincipal("user", "foo", "user",
                                 passwordManagerName="SHA1")
        users["user"] = user
       principalPermissionManager.grantAllPermissionsToPrincipal("user")

...


This also works fine, but when I restart the server, the permissions are
gone. Now I want to call the permission granting on Zope startup (when
the startup is complete).
I traced a possible solution to subscribe to the IProcessStartupEvent
event, but I'm a bit lost how to implement it.

Now I have a few questions:

0. Is there a simple way to make this permission granting persistent?

1. Is there some example code somewhere of someone who did something
like this before (run stuff on startup)?

2. Does this code run when the server is fully initialized, or before.
Obviously putting it in the __init__.py is no use, because it is called
before the core services are online.

Thanks
- Seth

-- 
Sebastian Bartos, <seth.kriticos at googlemail.com>
keyserevr: pgp.mit.edu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20090212/ab5f1a69/attachment.bin 


More information about the Zope3-users mailing list