Beispiel #1
0
 def new_context(self, request=None, config=None, session=None):
     context = WebExecutionContext()
     context.set_config(config or self.config)
     context.set_system_control(self.system_control)
     context.set_request(request or self.request)
     with context:
         context.set_session(session or self.session)
     return context
Beispiel #2
0
 def handle_request(self, request):
     context = WebExecutionContext.get_context()
     vassert( context.session is UserSessionStub.session )  # By the time user code executes, the session is set
     vassert( monitor.times_called == 1 )                      # The database has been committed
     vassert( not context.session.last_activity_time_set )     
     vassert( not UserSessionStub.session.key_is_set )
     return Response()
Beispiel #3
0
    def assemble(self, login_bookmark=None, get_queues=None):
        self.get_queues = get_queues
        self.web_session = WebExecutionContext.get_context().session
        self.first_log_in = ViewPreCondition(
            LoginSession.for_current_session().is_logged_in,
            exception=Detour(login_bookmark))

        self.workflow_interface = WorkflowInterface()
        self.inbox = Inbox(self.get_queues())

        inbox_view_factory = self.define_view('/', title=_('Inbox'))
        inbox_view_factory.set_slot('main_slot',
                                    InboxWidget.factory(self.inbox))

        task_view_factory = self.define_view('/task',
                                             view_class=TaskView,
                                             task=PersistedField(
                                                 Task, required=True))
        task_view_factory.add_precondition(self.first_log_in)
        inbox_view_factory.add_precondition(self.first_log_in)

        self.define_transition(self.workflow_interface.events.take_task,
                               inbox_view_factory, task_view_factory)
        self.define_transition(self.workflow_interface.events.go_to_task,
                               inbox_view_factory, task_view_factory)
        self.define_transition(self.workflow_interface.events.defer_task,
                               task_view_factory, inbox_view_factory)
        self.define_transition(self.workflow_interface.events.release_task,
                               task_view_factory, inbox_view_factory)
Beispiel #4
0
 def get_widget_class_for(self, task):
     config = WebExecutionContext.get_context().config
     for widget_class in config.workflowui.task_widgets:
         if issubclass(widget_class,
                       TaskWidget) and widget_class.displays(task):
             return widget_class
     raise ProgrammerError('no Widget found to display %s' % task)
Beispiel #5
0
 def i18nise_filename(self, for_default_locale):
     current_locale = WebExecutionContext.get_context().interface_locale
     head, tail = os.path.splitext(for_default_locale)
     head, d = os.path.splitext(head)
     for_current_locale = head+'.%s' % current_locale+d+tail
     if os.path.isfile(for_current_locale):
         return for_current_locale
     return for_default_locale
Beispiel #6
0
    def __init__(self, view, account_management_interface):
        super(RegistrationPendingWidget, self).__init__(view)
        config = WebExecutionContext.get_context().config
        self.add_child(P(view, text=_('There is a registration pending for email address "%s".') % account_management_interface.email))
        self.add_child(P(view, text=_('Before you can log in using it, you need to act on the automated email '\
                                      'sent to that address. It looks like you did not do that.')))
        self.add_child(P(view, text=_('You should receive the automated email anything between a minute to an hour after '\
                                      'registration. Sometimes though, your email software may mistakenly identify our '\
                                      'email as junk email. If this happens it will be hidden away in a "junk email" '\
                                      'folder or just not shown to you.')))
        self.add_child(P(view, text=_('You can have the email re-sent to you by clicking on the button below.')))
        self.add_child(P(view, text=_('Before you do that, however, please make sure that your email system will allow '\
                                      'emails from "%s" through to you.') % config.accounts.admin_email))

        self.add_child(RegistrationPendingForm(view))
Beispiel #7
0
    def with_languages(self):
        """Populates this Menu with a MenuItem for each available language.

           Answers the same Menu.

           .. versionadded: 3.2
        """
        current_url = Url.get_current_url()
        context = WebExecutionContext.get_context()
        supported_locales = ReahlEgg.get_languages_supported_by_all(
            context.config.reahlsystem.root_egg)
        for locale in supported_locales:
            try:
                language_name = Locale.parse(locale).display_name
            except UnknownLocaleError:
                language_name = locale

            bookmark = self.view.as_bookmark(description=language_name,
                                             locale=locale)
            bookmark.exact = True
            self.add_bookmark(bookmark)
        return self
Beispiel #8
0
 def new_view(self):
     current_path = Url(WebExecutionContext.get_context().request.url).path
     view = UrlBoundView(self.user_interface, current_path, 'A view', {})
     return view
Beispiel #9
0
 def persisted_file_class(self):
     config = WebExecutionContext.get_context().config
     return config.web.persisted_file_class
Beispiel #10
0
 def filesystem_path(self, relative_path):
     context = WebExecutionContext.get_context()
     static_root = context.config.web.static_root
     if relative_path.endswith('/'):
        relative_path += 'index.d.html'
     return self.i18nise_filename(os.path.join(static_root, *relative_path.split('/')))