Example #1
0
 def prepare_for_execution(self, restart=False):
     job = EventJob('system')
     transaction.commit()  # needed to have self.event._p_oid
     job.callable = self._callback
     event_oid = self.event._p_oid
     listener = Listener(job, event_oid)
     get_socket().send_pyobj(('start', listener))
Example #2
0
 def prepare_for_execution(self, restart=False):
     job = EventJob('system')
     transaction.commit()  # needed to have self.event._p_oid
     job.callable = self._callback
     event_oid = self.event._p_oid
     listener = Listener(job, event_oid)
     get_socket().send_pyobj(('start', listener))
Example #3
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     oid = str(get_oid(context))
     get_socket().send_pyobj(('stop', 'persistent_' + oid))
     context.state = PersistentList(['accepted'])
     accept_preregistration(request, context, root)
     request.registry.notify(ActivityExecuted(self, [context], None))
     return {}
Example #4
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     oid = str(get_oid(context))
     get_socket().send_pyobj(('stop', 'persistent_' + oid))
     context.state = PersistentList(['accepted'])
     accept_preregistration(request, context, root)
     request.registry.notify(ActivityExecuted(self, [context], None))
     return {}
Example #5
0
    def start(self, context, request, appstruct, **kw):
        data = context.get_data(PersonSchema())
        annotations = getattr(context, 'annotations',
                              {}).get(PROCESS_HISTORY_KEY, [])
        data.update({'password': appstruct['password']})
        data = {
            key: value
            for key, value in data.items() if value is not colander.null
        }
        data.pop('title')
        root = getSite()
        locale = my_locale_negotiator(request)
        data['locale'] = locale
        person = Person(**data)
        principals = find_service(root, 'principals')
        name = person.first_name + ' ' + person.last_name
        users = principals['users']
        name = name_chooser(users, name=name)
        users[name] = person
        grant_roles(person, roles=('Member', ))
        grant_roles(person, (('Owner', person), ))
        person.state.append('active')
        oid = str(get_oid(context))
        get_socket().send_pyobj(('stop', 'persistent_' + oid))
        organization = context.organization
        if organization:
            person.setproperty('organization', organization)

        root.delfromproperty('preregistrations', context)
        person.init_annotations()
        person.annotations.setdefault(PROCESS_HISTORY_KEY,
                                      PersistentList()).extend(annotations)
        person.reindex()
        request.registry.notify(ActivityExecuted(self, [person], person))
        root.addtoproperty('news_letter_members', person)
        newsletters = root.get_newsletters_automatic_registration()
        email = getattr(person, 'email', '')
        if newsletters and email:
            for newsletter in newsletters:
                newsletter.subscribe(person.first_name, person.last_name,
                                     email)

        transaction.commit()
        if email:
            mail_template = root.get_mail_template('registration_confiramtion',
                                                   person.user_locale)
            subject = mail_template['subject'].format(
                novaideo_title=root.title)
            recipientdata = get_user_data(person, 'recipient', request)
            message = mail_template['template'].format(
                login_url=request.resource_url(root, '@@login'),
                novaideo_title=root.title,
                **recipientdata)
            alert('email', [root.get_site_sender()], [email],
                  subject=subject,
                  body=message)

        return {'person': person}
Example #6
0
    def start(self, context, request, appstruct, **kw):
        data = context.get_data(PersonSchema())
        annotations = getattr(context, 'annotations', {}).get(PROCESS_HISTORY_KEY, [])
        data.update({'password': appstruct['password']})
        data = {key: value for key, value in data.items()
                if value is not colander.null}
        data.pop('title')
        root = getSite()
        locale = my_locale_negotiator(request)
        data['locale'] = locale
        person = Person(**data)
        principals = find_service(root, 'principals')
        name = person.first_name + ' ' + person.last_name
        users = principals['users']
        name = name_chooser(users, name=name)
        users[name] = person
        grant_roles(person, roles=('Member',))
        grant_roles(person, (('Owner', person),))
        person.state.append('active')
        oid = str(get_oid(context))
        get_socket().send_pyobj(('stop', 'persistent_' + oid))
        organization = context.organization
        if organization:
            person.setproperty('organization', organization)

        root.delfromproperty('preregistrations', context)
        person.init_annotations()
        person.annotations.setdefault(
            PROCESS_HISTORY_KEY, PersistentList()).extend(annotations)
        person.reindex()
        request.registry.notify(ActivityExecuted(self, [person], person))
        root.addtoproperty('news_letter_members', person)
        newsletters = root.get_newsletters_automatic_registration()
        email = getattr(person, 'email', '')
        if newsletters and email:
            for newsletter in newsletters:
                newsletter.subscribe(
                    person.first_name, person.last_name, email)

        transaction.commit()
        if email:
            mail_template = root.get_mail_template(
                'registration_confiramtion', person.user_locale)
            subject = mail_template['subject'].format(
                novaideo_title=root.title)
            recipientdata = get_user_data(person, 'recipient', request)
            message = mail_template['template'].format(
                login_url=request.resource_url(root, '@@login'),
                novaideo_title=root.title,
                **recipientdata)
            alert('email', [root.get_site_sender()], [email],
                  subject=subject, body=message)

        return {'person': person}
Example #7
0
    def start(self, context, request, appstruct, **kw):
        data = context.get_data(PersonSchema())
        annotations = getattr(context, 'annotations',
                              {}).get(PROCESS_HISTORY_KEY, [])
        data.update({'password': appstruct['password']})
        data = {
            key: value
            for key, value in data.items() if value is not colander.null
        }
        data.pop('title')
        structure = data.pop('structure')
        site = get_site_folder(True)
        root = getSite()
        person = Person(**data)
        principals = find_service(root, 'principals')
        name = getattr(person, 'first_name', '') + ' '\
            + getattr(person, 'last_name', '')
        users = principals['users']
        name = name_chooser(users, name=name)
        users[name] = person
        if structure:
            grant_roles(person, roles=(('CulturalAnimator', site), ))
            person.setproperty('structure', structure)
        else:
            grant_roles(person, roles=(('Member', site), ))

        grant_roles(person, roles=('Member', ))
        grant_roles(person, (('Owner', person), ))
        person.state.append('active')
        person.reindex()
        get_socket().send_pyobj(
            ('stop', 'persistent_' + str(get_oid(context))))
        root.delfromproperty('preregistrations', context)
        person.add_customeraccount()
        person.init_annotations()
        person.annotations.setdefault(PROCESS_HISTORY_KEY,
                                      PersistentList()).extend(annotations)
        request.registry.notify(ActivityExecuted(self, [person], person))
        transaction.commit()
        localizer = request.localizer
        mail_template = site.get_mail_template('subscription_statement')
        subject = mail_template['subject']
        message = mail_template['template'].format(
            person=person,
            user_title=localizer.translate(_(getattr(person, 'user_title',
                                                     ''))),
            login_url=request.resource_url(root, '@@login'),
            lac_title=request.root.title)
        alert('email', [site.get_site_sender()], [person.email], {
            'subject': subject,
            'body': message
        })
        return {'person': person}
Example #8
0
    def start(self, context, request, appstruct, **kw):
        data = context.get_data(PersonSchema())
        annotations = getattr(context, 'annotations', {}).get(PROCESS_HISTORY_KEY, [])
        data.update({'password': appstruct['password']})
        data = {key: value for key, value in data.items()
                if value is not colander.null}
        data.pop('title')
        structure = data.pop('structure')
        site = get_site_folder(True)
        root = getSite()
        person = Person(**data)
        principals = find_service(root, 'principals')
        name = getattr(person, 'first_name', '') + ' '\
            + getattr(person, 'last_name', '')
        users = principals['users']
        name = name_chooser(users, name=name)
        users[name] = person
        if structure:
            grant_roles(person, roles=(('CulturalAnimator', site),))
            person.setproperty('structure', structure)
        else:
            grant_roles(person, roles=(('Member', site),))

        grant_roles(person, roles=('Member',))
        grant_roles(person, (('Owner', person),))
        person.state.append('active')
        person.reindex()
        get_socket().send_pyobj(
            ('stop',
             'persistent_' + str(get_oid(context))))
        root.delfromproperty('preregistrations', context)
        person.add_customeraccount()
        person.init_annotations()
        person.annotations.setdefault(
            PROCESS_HISTORY_KEY, PersistentList()).extend(annotations)
        request.registry.notify(ActivityExecuted(self, [person], person))
        transaction.commit()
        localizer = request.localizer
        mail_template = site.get_mail_template('subscription_statement')
        subject = mail_template['subject']
        message = mail_template['template'].format(
            person=person,
            user_title=localizer.translate(
                _(getattr(person, 'user_title', ''))),
            login_url=request.resource_url(root, '@@login'),
            lac_title=request.root.title)
        alert('email', [site.get_site_sender()], [person.email],
              {'subject': subject, 'body': message})
        return {'person': person}
Example #9
0
def remove_expired_preregistration_callback(root, preregistration):
    remove_expired_preregistration(root, preregistration)
    oid = str(get_oid(preregistration))
    get_socket().send_pyobj(('ack', 'persistent_' + oid))
Example #10
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     oid = str(get_oid(context))
     get_socket().send_pyobj(('stop', 'persistent_' + oid))
     remove_expired_preregistration(root, context)
     return {}
Example #11
0
def remove_expired_preregistration_callback(root, preregistration):
    remove_expired_preregistration(root, preregistration)
    oid = str(get_oid(preregistration))
    get_socket().send_pyobj(('ack', 'persistent_' + oid))
Example #12
0
 def stop(self):
     # stop DelayedCallback
     get_socket().send_pyobj(('stop', self.event._p_oid))
Example #13
0
 def start(self, context, request, appstruct, **kw):
     root = getSite()
     oid = str(get_oid(context))
     get_socket().send_pyobj(('stop', 'persistent_' + oid))
     remove_expired_preregistration(root, context)
     return {}
Example #14
0
 def stop(self):
     get_socket().send_pyobj(('stop', self.event._p_oid))
Example #15
0
 def stop(self):
     # stop DelayedCallback
     get_socket().send_pyobj(('stop', self.event._p_oid))
Example #16
0
 def stop(self):
     # close ZMQStream
     get_socket().send_pyobj(('close', self.event._p_oid))
Example #17
0
def remove_expired_preregistration(root, preregistration):
    if preregistration.__parent__ is not None:
        oid = str(get_oid(preregistration))
        root.delfromproperty('preregistrations', preregistration)
        get_socket().send_pyobj(
            ('ack', 'persistent_' + oid))
Example #18
0
 def stop(self):
     get_socket().send_pyobj(('stop', self.event._p_oid))
Example #19
0
 def stop(self):
     # close ZMQStream
     get_socket().send_pyobj(('close', self.event._p_oid))
Example #20
0
def remove_expired_preregistration(root, preregistration):
    if preregistration.__parent__ is not None:
        oid = str(get_oid(preregistration))
        root.delfromproperty('preregistrations', preregistration)
        get_socket().send_pyobj(('ack', 'persistent_' + oid))