[gen] Bugfix: in batch mode (Zope 'zopectl run'), the Appy user must be 'system'.

This commit is contained in:
Gaetan Delannay 2014-03-18 12:11:21 +01:00
parent 4515eb1f80
commit 889289407f
2 changed files with 11 additions and 2 deletions

View file

@ -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)

View file

@ -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):