diff --git a/bin/job.py b/bin/job.py index d882677..f308925 100644 --- a/bin/job.py +++ b/bin/job.py @@ -53,6 +53,7 @@ else: # Zope was initialized in a minimal way. Complete Zope install. from Testing import makerequest app = makerequest.makerequest(app) + app.REQUEST._fake_ = True # Log as Zope admin from AccessControl.SecurityManagement import newSecurityManager user = app.acl_users.getUserById(zopeUser) diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index ef365d6..726d256 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -971,8 +971,16 @@ class ToolMixin(BaseMixin): # d. All the identification methods failed. So identify the user as # "anon" or "system". if not login: - # If we have a real request object, it is the anonymous user. - login = (req.__class__.__name__ == 'Object') and 'system' or 'anon' + # If we have a fake request, we are at startup or in batch mode and + # the user is "system". Else, it is "anon". At Zope startup, Appy + # uses an Object instance as a fake request. In "zopectl run" mode + # (the Zope batch mode), Appy adds a param "_fake_" on the request + # object created by Zope. + if (req.__class__.__name__ == 'Object') or \ + (hasattr(req, '_fake_') and req._fake_): + login = 'system' + else: + login = 'anon' return login, password def getLdapUser(self, login, password):