示例#1
0
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))
示例#2
0
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__))
示例#3
0
 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)
示例#4
0
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__))
示例#5
0
 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)
示例#6
0
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__))
示例#7
0
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__)
示例#8
0
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__)
示例#9
0
文件: event.py 项目: novareto/uvcsite
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))
示例#10
0
 def checkRule(self, login):
     uvcsite.log(login)
     return True
示例#11
0
 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
示例#12
0
 def checkRule(self, login):
     uvcsite.log(login)
     return True
示例#13
0
 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