Esempio n. 1
0
    def isPending(self):
        annot = IAnnotations(self.context)
        sub_mod_pending_list = getAdapter(self.context,
                                          IMembershipPendingList,
                                          'pending_sub_mod_email')

        return sub_mod_pending_list.is_pending(self.user_email)
Esempio n. 2
0
 def afterSetUp(self):
     self.obj = Dummy()
     self.dan = IClickdates(self.obj)
     self.dan.clickDate()
     self.thisMonth = datetime.date.today().month
     self.thisYear = datetime.date.today().year
     self.annotations = IAnnotations(self.obj)
     self.date = "%s-%s" % (self.thisYear, self.thisMonth)
Esempio n. 3
0
 def __init__(self, context, request):
     self.context = context
     self.request = request
     annotations = IAnnotations(context.getCanonical())
     mapping = annotations.get(KEY)
     if mapping is None:
         mapping = annotations[KEY] = PersistentDict({
             'page_background': None,
         })
     self.mapping = mapping
Esempio n. 4
0
    def save_import_history(self):
        annot = IAnnotations(self.context)
        listen_annot = annot.get(PROJECTNAME)
        if listen_annot is None:
            annot[PROJECTNAME] = listen_annot = OOBTree()
        import_annot = listen_annot.get('import')
        if import_annot is None:
            listen_annot['import'] = import_annot = OOBTree()

        now = str(time.time())
        data = dict(msgids=self.msgids, filename=self.filename)
        import_annot[now] = OOBTree(data)
Esempio n. 5
0
 def getAnnotation(context):
     annotations = IAnnotations(context)
     try:
         result = annotations[key]
     except KeyError:
         result = factory()
         annotations[key] = result
     # Containment has to be set up late to allow containment proxies
     # to be applied, if needed. This does not trigger an event and is idempotent
     # if containment is set up already.
     contained_result = zope.app.container.contained.contained(
         result, context, key)
     return contained_result
Esempio n. 6
0
    def post_validate(self, REQUEST, errors):
        form = REQUEST.form
        if form.has_key('password') or form.has_key('confirmPassword'):
            password = form.get('password', None)
            confirm = form.get('confirmPassword', None)

            annotations = IAnnotations(self)
            passwordDigest = annotations.get(PASSWORD_KEY, None)

            if not passwordDigest:
                if not password and not confirm:
                    errors['password'] = u'An initial password must be set'
                    return
            if password or confirm:
                if password != confirm:
                    errors['password'] = errors[
                        'confirmPassword'] = u'Passwords do not match'
Esempio n. 7
0
    def verifyCredentials(self, credentials):
        """Authenticate against the password stored via attribute on this person,
        or pass authentication on to the next PAS plugin
        """
        login = credentials.get('login', None)
        password = credentials.get('password', None)
        logger.info("Adapting an igcPerson... %s %s" % (login, password))

        if login is None or password is None:
            return False


#TODO: with a line of code, we can have here login as anyone, for testing
#        gcommons_tool = getToolByName(self.context,FSD_TOOL)
#        if (password == gcommons_tool.getUseInternalPassword()( return true

        digest = sha(password).digest()
        annotations = IAnnotations(self.context)
        passwordDigest = annotations.get(PASSWORD_KEY, None)
        return (login == self.getUserName() and digest == passwordDigest)
Esempio n. 8
0
 def setPasswordDigested(self, value):
     """
     This is used when migrating, password already sha
     """
     annotations = IAnnotations(self)
     annotations[PASSWORD_KEY] = value
Esempio n. 9
0
 def setPassword(self, value):
     """"""
     if value:
         annotations = IAnnotations(self)
         annotations[PASSWORD_KEY] = sha(value).digest()
 def __init__(self, context):
     self.context = context
     annot = IAnnotations(context)
     self.listen_annot = annot.setdefault(PROJECTNAME, OOBTree())
     self.migration_annot = self.listen_annot.setdefault(
         'migration', PersistentList())
    def migrate(self):
        if self.is_updated():
            return _(u'already migrated')

        # set the appropriate list type based on the previous settings
        # this may need to mark the appropriate interface on the mailing
        # list as well
        if self.context.moderated:
            self.context.list_type = PostModeratedListTypeDefinition
        elif self.context.closed:
            self.context.list_type = MembershipModeratedListTypeDefinition
        else:
            self.context.list_type = PublicListTypeDefinition

        # copy over the membership stuff
        annot = IAnnotations(self.context)
        listen_annot = annot.get('listen', {})
        old_subscribers = listen_annot.get('subscribers', [])

        # create the new annotations by using current adapters
        mem_list = IWriteMembershipList(self.context)
        for subscriber in old_subscribers:
            mem_list.subscribe(subscriber)

        # unsubscribe (but leave as allowed senders) those who don't
        # receive mail
        nomail = listen_annot.get('norecvmail', [])
        for allowed_sender in nomail:
            mem_list.unsubscribe(allowed_sender)

        # copy over the moderation messages
        self.mod_post_pending_list = getAdapter(self.context, IPostPendingList,
                                                'pending_pmod_post')
        for i in self.context.mqueue.objectIds():
            (header, body) = splitMail(self.context.mqueue[i])
            post = {'header': header, 'body': body}
            (user_name, user_email) = parseaddr(header.get('from', ''))
            self.mod_post_pending_list.add(user_email,
                                           user_name=user_name,
                                           post=post)

        # creates list managers from moderators and list owner
        managers = []
        managers.append(self.context.list_owner)
        for moderator in self.context.moderators:
            managers.append(moderator)
        self.context.managers = tuple(managers)
        convert_manager_emails_to_memberids(self.context)

        # translate archived vocabulary
        if self.context.archived == 'not archived':
            self.context.archived = 2
        elif self.context.archived == 'plain text':
            self.context.archived = 1
        elif self.context.archived == 'with attachments':
            self.context.archived = 0
        else:
            return _(u'error translating archive option')

        # annotate the list to say the migration completed
        self.migration_annot.append('policy_migration')

        return _(u'successfully migrated')
 def __init__(self, context):
     self.context = context
     annot = IAnnotations(context)
     listen_annot = annot.setdefault(PROJECTNAME, OOBTree())
     self.digest = listen_annot.setdefault('digest', PersistentList())
Esempio n. 13
0
 def __init__(self, context):
     self.context = context
     annot = IAnnotations(context)
     self.listen_annot = annot.setdefault(PROJECTNAME, OOBTree())
     self.mail_sender = ISendMail(context)
     self.mem_list = IWriteMembershipList(self.context)
Esempio n. 14
0
 def get_import_annot(self):
     annot = IAnnotations(self.context)
     listen_annot = annot.get(PROJECTNAME)
     if listen_annot:
         return listen_annot.get('import')