def applyPermissionsForExistentCoUsers(factory): site = grok.getSite() hfm = IHomeFolderManager(site) principal = factory.object master_id = IMasterUser(principal).id if hfm.get(master_id) is None: hfm.create(IMasterUser(principal).id) homefolder = principal.homefolder #IHomeFolder(principal) if homefolder is None: return um = getUtility(IUserManagement) user = um.getUser(principal.id) if not user: return rollen = user['rollen'] if user['az'] != '00': pid = "%s-%s" % (user['mnr'], user['az']) else: pid = user['mnr'] if homefolder.__name__ != pid: for pf in homefolder.keys(): if pf in rollen: prm = IPrincipalRoleManager(homefolder.get(pf)) if prm.getSetting('uvc.Editor', pid).getName() == 'Unset': prm.assignRoleToPrincipal('uvc.Editor', pid) uvcsite.log('Give uvc.Editor to %s in folder %s' % (pid, pf))
def applyViewContentForCoUsers(factory): principal = factory.object homefolder = None #if IUnauthenticatedPrincipal.providedBy(principal): # homefolder = principal.homefolder #else: # # Workaround, um weiter arbeiten zu können - CK muss noch fixen # #try: # # homefolder = IHomeFolder(principal) # #except TypeError: # # return # homefolder = IHomeFolder(principal) homefolder = principal.homefolder if not homefolder: return if homefolder.__name__ != principal.id: hprm = IPrincipalRoleManager(homefolder) if hprm.getSetting('uvc.HomeFolderUser', principal.id).getName() in ('Deny', 'Unset'): hprm.assignRoleToPrincipal('uvc.HomeFolderUser', principal.id) uvcsite.log( 'applying Role uvc.HomeFolderUser for USER %s in HOMEFOLDER %s' % (principal.id, homefolder.__name__))
def createInProductFolder(self): homefolder = IHomeFolder(self.principal).homeFolder if not homefolder: utility = getUtility(IHomeFolderManager) utility.assignHomeFolder(uvcsite.IMasterUser(self.principal).id) if self.folderURI and not self.folderURI in homefolder.keys(): pf = self.productfolder homefolder[self.folderURI] = pf() uvcsite.log('Add Productfolders %s to Homefolder: %s' % (self.folderURI, self.principal.id), severity=logging.DEBUG)
def applyViewContentForCoUsers(factory): principal = factory.object homefolder = IHomeFolder(principal).homeFolder if not homefolder: return if homefolder.__name__ != principal.id: hprm = IPrincipalRoleManager(homefolder) if hprm.getSetting('uvc.HomeFolderUser', principal.id).getName() in ('Deny', 'Unset'): hprm.assignRoleToPrincipal('uvc.HomeFolderUser', principal.id) log('applying Role uvc.HomeFolderUser for USER %s in HOMEFOLDER %s' % (principal.id, homefolder.__name__))
def applyViewContentForCoUsers(factory): principal = factory.object homefolder = IHomeFolder(principal).homeFolder if not homefolder: return if homefolder.__name__ != principal.id: hprm = IPrincipalRoleManager(homefolder) setting = hprm.getSetting('uvc.HomeFolderUser', principal.id).getName() if setting in ('Deny', 'Unset'): hprm.assignRoleToPrincipal('uvc.HomeFolderUser', principal.id) log('applying Role uvc.HomeFolderUser for USER %s in HOMEFOLDER %s' % (principal.id, homefolder.__name__))
def handle_save(obj, event): sp = transaction.savepoint() wf = IWorkflowInfo(obj) try: 1 / 0 if True: wf.fireTransition('review') uvcsite.log('add Document in state review') else: pdf = zope.component.getMultiAdapter((obj, event.request), name=u"pdf") pdf.create(fn="/tmp/kk/%s.pdf" % (obj.__name__)) wf.fireTransition('publish') except StandardError, e: sp.rollback() wf.fireTransition('progress') uvcsite.logger.exception("ES IST EIN FEHLER AUFGETRETEN") uvcsite.log('simpleaddon', e.__doc__)
def applyPermissionsForExistentCoUsers(factory): principal = factory.object createProductFolders(principal) homefolder = IHomeFolder(principal).homeFolder if not homefolder: return um = getUtility(IUserManagement) user = um.getUser(principal.id) rollen = user['rollen'] if user['az'] != '00': pid = "%s-%s" % (user['mnr'], user['az']) else: pid = user['mnr'] if homefolder.__name__ != pid: for pf in homefolder.keys(): if pf in rollen: prm = IPrincipalRoleManager(homefolder.get(pf)) if prm.getSetting('uvc.Editor', pid).getName() == 'Unset': prm.assignRoleToPrincipal('uvc.Editor', pid) uvcsite.log('Give uvc.Editor to %s in folder %s' % (pid, pf))
def checkRule(self, login): uvcsite.log(login) return True
def execute(self, factory, config, require, **kw): if os.environ.get('UVC_SEC_CHECK') == '1': if require is _require_marker: context = grok.context.bind().get(factory) uvcsite.log('%r --> %r' % (factory, context)) return True
def add(self, account): if account.az in self._users: raise KeyError("Account `%s` already exists." % account.az) self._users[account.az] = account log("Successfully Created User %s" % account.az) return True