[gen] Created param config.groupsForGlobalRoles that disabled by default creation of a group for every global role. On a appy class it is now possible to define a static method 'generateUid' that generates a UID for every instance of this class, instead of using the standard Appy way to produce such UIDs. [shared] dav.Resource: allow to retrieve the result encoded or not in utf8.
This commit is contained in:
parent
d385b8514e
commit
88bd5e5bce
9 changed files with 42 additions and 20 deletions
|
@ -599,4 +599,6 @@ class Config:
|
|||
self.ogone = None
|
||||
# When using Google analytics, specify here the Analytics ID
|
||||
self.googleAnalyticsId = None
|
||||
# Create a group for every global role?
|
||||
self.groupsForGlobalRoles = False
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -608,6 +608,7 @@ class ZopeGenerator(Generator):
|
|||
repls['ogone'] = repr(self.config.ogone)
|
||||
repls['googleAnalyticsId'] = repr(self.config.googleAnalyticsId)
|
||||
repls['activateForgotPassword'] = self.config.activateForgotPassword
|
||||
repls['groupsForGlobalRoles'] = self.config.groupsForGlobalRoles
|
||||
self.copyFile('config.pyt', repls, destName='config.py')
|
||||
|
||||
def generateInit(self):
|
||||
|
|
|
@ -250,14 +250,16 @@ class ZopeInstaller:
|
|||
appyTool.log('Group "admins" created.')
|
||||
|
||||
# Create a group for every global role defined in the application
|
||||
for role in self.config.applicationGlobalRoles:
|
||||
relatedGroup = '%s_group' % role
|
||||
if appyTool.count('Group', noSecurity=True, login=relatedGroup):
|
||||
continue
|
||||
appyTool.create('groups', noSecurity=True, login=relatedGroup,
|
||||
title=relatedGroup, roles=[role])
|
||||
appyTool.log('Group "%s", related to global role "%s", was ' \
|
||||
'created.' % (relatedGroup, role))
|
||||
# (if required).
|
||||
if self.app.config.getProductConfig().groupsForGlobalRoles:
|
||||
for role in self.config.applicationGlobalRoles:
|
||||
groupId = role.lower()
|
||||
if appyTool.count('Group', noSecurity=True, login=groupId):
|
||||
continue
|
||||
appyTool.create('groups', noSecurity=True, login=groupId,
|
||||
title=role, roles=[role])
|
||||
appyTool.log('Group "%s", related to global role "%s", was ' \
|
||||
'created.' % (groupId, role))
|
||||
|
||||
# Create POD templates within the tool if required
|
||||
for contentType in self.config.attributes.iterkeys():
|
||||
|
@ -307,11 +309,8 @@ class ZopeInstaller:
|
|||
id=language, title=title)
|
||||
appyTool.log('Translation object created for "%s".' % language)
|
||||
|
||||
# Execute custom installation code if any
|
||||
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
|
||||
|
||||
# Now, if required, we synchronise every Translation object with the
|
||||
# corresponding "po" file on disk.
|
||||
# Synchronize, if required, synchronise every Translation object with
|
||||
# the corresponding "po" file on disk.
|
||||
if appyTool.loadTranslationsAtStartup:
|
||||
appFolder = self.config.diskFolder
|
||||
appName = self.config.PROJECTNAME
|
||||
|
@ -325,6 +324,9 @@ class ZopeInstaller:
|
|||
appyTool.log('Translation "%s" updated from "%s".' % \
|
||||
(translation.id, poName))
|
||||
|
||||
# Execute custom installation code if any.
|
||||
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
|
||||
|
||||
def configureSessions(self):
|
||||
'''Configure the session machinery.'''
|
||||
# Register a function warning us when a session object is deleted. When
|
||||
|
|
|
@ -57,7 +57,15 @@ class BaseMixin:
|
|||
if created and rq:
|
||||
# Create the final object and put it at the right place.
|
||||
tool = self.getTool()
|
||||
id = tool.generateUid(obj.portal_type)
|
||||
# The app may define a method klass.generateUid for producing an UID
|
||||
# for instance of this class. If no such method is found, we use the
|
||||
# standard Appy method to produce an UID.
|
||||
id = None
|
||||
klass = tool.getAppyClass(obj.portal_type)
|
||||
if hasattr(klass, 'generateUid'):
|
||||
id = klass.generateUid(obj.REQUEST)
|
||||
if not id:
|
||||
id = tool.generateUid(obj.portal_type)
|
||||
if not initiator:
|
||||
folder = tool.getPath('/data')
|
||||
else:
|
||||
|
|
|
@ -52,6 +52,7 @@ enableSessionTimeout = <!enableSessionTimeout!>
|
|||
discreetLogin = <!discreetLogin!>
|
||||
ogone = <!ogone!>
|
||||
googleAnalyticsId = <!googleAnalyticsId!>
|
||||
groupsForGlobalRoles = <!groupsForGlobalRoles!>
|
||||
|
||||
# When Zope is starting or runs in test mode, there is no request object. We
|
||||
# create here a fake one for storing Appy wrappers.
|
||||
|
|
|
@ -9,7 +9,7 @@ class GroupWrapper(AbstractWrapper):
|
|||
def showLogin(self):
|
||||
'''When must we show the login field?'''
|
||||
if self.o.isTemporary(): return 'edit'
|
||||
return 'view'
|
||||
return ('view', 'result')
|
||||
|
||||
def showGroups(self):
|
||||
'''Only the admin can view or edit roles.'''
|
||||
|
|
|
@ -134,7 +134,11 @@ class UserWrapper(AbstractWrapper):
|
|||
return self._callCustom('validate', new, errors)
|
||||
|
||||
def onEdit(self, created):
|
||||
self.title = self.login
|
||||
# Set a title for this user.
|
||||
if self.firstName and self.name:
|
||||
self.title = '%s %s' % (self.name, self.firstName)
|
||||
else:
|
||||
self.title = self.login
|
||||
aclUsers = self.o.acl_users
|
||||
login = self.login
|
||||
if created:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue