[gen] Bugfix: in batch mode (Zope 'zopectl run'), the Appy user must be 'system'.
This commit is contained in:
parent
4515eb1f80
commit
889289407f
|
@ -53,6 +53,7 @@ else:
|
||||||
# Zope was initialized in a minimal way. Complete Zope install.
|
# Zope was initialized in a minimal way. Complete Zope install.
|
||||||
from Testing import makerequest
|
from Testing import makerequest
|
||||||
app = makerequest.makerequest(app)
|
app = makerequest.makerequest(app)
|
||||||
|
app.REQUEST._fake_ = True
|
||||||
# Log as Zope admin
|
# Log as Zope admin
|
||||||
from AccessControl.SecurityManagement import newSecurityManager
|
from AccessControl.SecurityManagement import newSecurityManager
|
||||||
user = app.acl_users.getUserById(zopeUser)
|
user = app.acl_users.getUserById(zopeUser)
|
||||||
|
|
|
@ -971,8 +971,16 @@ class ToolMixin(BaseMixin):
|
||||||
# d. All the identification methods failed. So identify the user as
|
# d. All the identification methods failed. So identify the user as
|
||||||
# "anon" or "system".
|
# "anon" or "system".
|
||||||
if not login:
|
if not login:
|
||||||
# If we have a real request object, it is the anonymous user.
|
# If we have a fake request, we are at startup or in batch mode and
|
||||||
login = (req.__class__.__name__ == 'Object') and 'system' or 'anon'
|
# 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
|
return login, password
|
||||||
|
|
||||||
def getLdapUser(self, login, password):
|
def getLdapUser(self, login, password):
|
||||||
|
|
Loading…
Reference in a new issue