• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.get_logged_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tvb.interfaces.web.controllers.common.get_logged_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_logged_user函数的具体用法?Python get_logged_user怎么用?Python get_logged_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_logged_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: profile

    def profile(self, logout=False, save=False, **data):
        """
        Display current user's profile page.
        On POST: logout, or save password/email.
        """
        if cherrypy.request.method == "POST" and logout:
            raise cherrypy.HTTPRedirect("/user/logout")
        template_specification = dict(mainContent="profile", title="User Profile")
        user = common.get_logged_user()

        if cherrypy.request.method == "POST" and save:
            try:
                form = EditUserForm()
                data = form.to_python(data)
                if data.get(KEY_PASSWORD):
                    user.password = md5(data[KEY_PASSWORD]).hexdigest()
                if data.get(KEY_EMAIL):
                    user.email = data[KEY_EMAIL]
                old_password = None
                if data.get("old_password"):
                    old_password = md5(data["old_password"]).hexdigest()
                self.user_service.edit_user(user, old_password)
                if old_password:
                    common.set_info_message("Changes Submitted!")
                else:
                    common.set_info_message("Submitted!  No password changed.")
            except formencode.Invalid, excep:
                template_specification[common.KEY_ERRORS] = excep.unpack_errors()
            except UsernameException, excep:
                self.logger.exception(excep)
                user = common.get_logged_user()
                common.add2session(common.KEY_USER, self.user_service.get_user_by_id(user.id))
                common.set_error_message("Could not save changes. Probably wrong old password!!")
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:33,代码来源:users_controller.py


示例2: submit

    def submit(self, dynamic_gid, dynamic_name):
        if dao.get_dynamic_by_name(dynamic_name):
            return {'saved': False, 'msg': 'There is another configuration with the same name'}

        dynamic = self.get_cached_dynamic(dynamic_gid)
        model = dynamic.model
        integrator = dynamic.integrator

        model_parameters = []

        for name in model.ui_configurable_parameters:
            value = getattr(model, name)[0]
            model_parameters.append((name, value))

        entity = tvb.core.entities.model.Dynamic(
            dynamic_name,
            common.get_logged_user().id,
            model.__class__.__name__,
            json.dumps(model_parameters),
            integrator.__class__.__name__,
            None
            # todo: serialize integrator parameters
            # json.dumps(integrator.raw_ui_integrator_parameters)
        )

        dao.store_entity(entity)
        return {'saved': True}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:27,代码来源:dynamic_model_controller.py


示例3: index

    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        des = SerializationManager(burst_config)

        connectivity = des.get_connectivity()

        if connectivity is None:
            msg = 'You have to select a connectivity before setting up the region Model. '
            common.set_error_message(msg)
            raise ValueError(msg)

        params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        params.update({
            'title': 'Model parameters',
            'mainContent': 'burst/model_param_region',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/modelparameters/regions/submit_model_parameters',
            'dynamics': dynamics,
            'dynamics_json': self._dynamics_json(dynamics),
            'initial_dynamic_ids': json.dumps(burst_config.dynamic_ids)
        })

        return self.fill_default_attributes(params, 'regionmodel')
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:31,代码来源:region_model_parameters_controller.py


示例4: index

    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        des = SerializationManager(burst_config)

        connectivity = des.get_connectivity()
        params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        params.update(
            {
                "title": "Model parameters",
                "mainContent": "burst/model_param_region",
                "isSingleMode": True,
                "submit_parameters_url": "/burst/modelparameters/regions/submit_model_parameters",
                "dynamics": dynamics,
                "dynamics_json": self._dynamics_json(dynamics),
                "initial_dynamic_ids": json.dumps(burst_config.dynamic_ids),
            }
        )

        return self.fill_default_attributes(params, "regionmodel")
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:27,代码来源:region_model_parameters_controller.py


示例5: launch_burst

    def launch_burst(self, launch_mode, burst_name, **data):
        """
        Do the actual burst launch, using the configuration saved in current session.
        :param launch_mode: new/branch/continue
        :param burst_name: user-given burst name. It can be empty (case in which we will fill with simulation_x)
        :param data: kwargs for simulation input parameters.
        """
        data = json.loads(data['simulator_parameters'])
        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)

        ## Validate new burst-name
        if launch_mode == LAUNCH_NEW and burst_name != 'none_undefined':
            validation_result = self._is_burst_name_ok(burst_name)
            if validation_result is True:
                burst_config.name = burst_name
            else:
                return {'error': validation_result}

        ## Fill all parameters 
        user_id = common.get_logged_user().id
        data[common.KEY_ADAPTER] = self.cached_simulator_algorithm_id
        burst_config.update_simulator_configuration(data)
        burst_config.fk_project = common.get_current_project().id

        ## Do the asynchronous launch
        try:
            burst_id, burst_name = self.burst_service.launch_burst(burst_config, 0, self.cached_simulator_algorithm_id,
                                                                   user_id, launch_mode)
            return {'id': burst_id, 'name': burst_name}
        except BurstServiceException, e:
            self.logger.exception("Could not launch burst!")
            return {'error': e.message}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:32,代码来源:burst_controller.py


示例6: invokeadaptermethod

    def invokeadaptermethod(self, adapter_id, method_name, **data):
        """
        Public web method, to be used when invoking specific 
        methods from external Adapters/Algorithms.
        """
        algo_group = self.flow_service.get_algo_group_by_identifier(adapter_id)
        try:
            adapter_instance = self.flow_service.build_adapter_instance(algo_group)
            result = self.flow_service.fire_operation(adapter_instance, common.get_logged_user(),
                                                      common.get_current_project().id, method_name, **data)
            common.set_info_message("Submit OK!")
            if isinstance(adapter_instance, ABCDisplayer) and isinstance(result, dict):
                common.pop_message_from_session()
                result[ABCDisplayer.KEY_IS_ADAPTER] = True
                result[common.KEY_DISPLAY_MENU] = True
                result[common.KEY_OPERATION_ID] = adapter_instance.operation_id
                result[common.KEY_ADAPTER] = adapter_id
                if KEY_CONTROLLS not in result:
                    result[KEY_CONTROLLS] = None
                self._populate_section(algo_group, result)
                return self.fill_default_attributes(result, algo_group.displayname)

        except OperationException, excep:
            common.set_warning_message('Problem when submitting data!')
            self.logger.error("Invalid method, or wrong  parameters when invoking external method on post!")
            self.logger.exception(excep)
开发者ID:rajul,项目名称:tvb-framework,代码行数:26,代码来源:flow_controller.py


示例7: store_exploration_section

    def store_exploration_section(self, val_range, step, dt_group_guid):
        """
        Launching method for further simulations.
        """
        range_list = [float(num) for num in val_range.split(",")]
        step_list = [float(num) for num in step.split(",")]

        datatype_group_ob = ProjectService().get_datatypegroup_by_gid(dt_group_guid)
        operation_grp = datatype_group_ob.parent_operation_group
        operation_obj = self.flow_service.load_operation(datatype_group_ob.fk_from_operation)
        parameters = json.loads(operation_obj.parameters)

        range1name, range1_dict = json.loads(operation_grp.range1)
        range2name, range2_dict = json.loads(operation_grp.range2)
        parameters[RANGE_PARAMETER_1] = range1name
        parameters[RANGE_PARAMETER_2] = range2name

        ##change the existing simulator parameters to be min max step types
        range1_dict = {constants.ATT_MINVALUE: range_list[0],
                       constants.ATT_MAXVALUE: range_list[1],
                       constants.ATT_STEP: step_list[0]}
        range2_dict = {constants.ATT_MINVALUE: range_list[2],
                       constants.ATT_MAXVALUE: range_list[3],
                       constants.ATT_STEP: step_list[1]}
        parameters[range1name] = json.dumps(range1_dict)  # this is for the x axis parameter
        parameters[range2name] = json.dumps(range2_dict)  # this is for the y axis parameter

        OperationService().group_operation_launch(common.get_logged_user().id, common.get_current_project().id,
                                                  operation_obj.algorithm.id, operation_obj.algorithm.fk_category,
                                                  datatype_group_ob, **parameters)

        return [True, 'Stored the exploration material successfully']
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:32,代码来源:flow_controller.py


示例8: usermanagement

    def usermanagement(self, cancel=False, page=1, do_persist=False, **data):
        """
        Display a table used for user management.
        """
        if cancel:
            raise cherrypy.HTTPRedirect('/user/profile')

        page = int(page)
        if cherrypy.request.method == 'POST' and do_persist:
            not_deleted = 0
            for key in data:
                user_id = int(key.split('_')[1])
                if 'delete_' in key:
                    self.user_service.delete_user(user_id)
                if ("role_" in key) and not (("delete_" + str(user_id)) in data):
                    valid = ("validate_" + str(user_id)) in data
                    user = self.user_service.get_user_by_id(user_id)
                    user.role = data[key]
                    user.validated = valid
                    self.user_service.edit_user(user)
                    not_deleted += 1
            # The entire current page was deleted, go to previous page
            if not_deleted == 0 and page > 1:
                page -= 1

        admin_ = common.get_logged_user().username
        user_list, pages_no = self.user_service.retrieve_all_users(admin_, page)
        template_specification = dict(mainContent="user_management", title="Users management", page_number=page,
                                      total_pages=pages_no, userList=user_list, allRoles=UserService.USER_ROLES,
                                      data={})
        return self.fill_default_attributes(template_specification)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:31,代码来源:users_controller.py


示例9: execute_post

    def execute_post(self, project_id, submit_url, step_key, algorithm, **data):
        """ Execute HTTP POST on a generic step."""
        errors = None
        adapter_instance = ABCAdapter.build_adapter(algorithm)

        try:
            result = self.flow_service.fire_operation(adapter_instance, common.get_logged_user(), project_id, **data)

            # Store input data in session, for informing user of it.
            step = self.flow_service.get_category_by_id(step_key)
            if not step.rawinput:
                self.context.add_adapter_to_session(None, None, copy.deepcopy(data))

            if isinstance(adapter_instance, ABCDisplayer):
                if isinstance(result, dict):
                    result[common.KEY_OPERATION_ID] = adapter_instance.operation_id
                    return result
                else:
                    common.set_error_message("Invalid result returned from Displayer! Dictionary is expected!")
            else:
                if isinstance(result, list):
                    result = "Launched %s operations." % len(result)
                common.set_important_message(str(result))
        except formencode.Invalid, excep:
            errors = excep.unpack_errors()
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:25,代码来源:flow_controller.py


示例10: storeresultfigure

 def storeresultfigure(self, img_type, **kwargs):
     """Create preview for current displayed canvas and 
     store image in current session, for future comparison."""
     project = common.get_current_project()
     user = common.get_logged_user()
     operation_id = kwargs.get("operationId")
     suggested_name = kwargs.get("suggestedName")
     self.figure_service.store_result_figure(project, user, img_type, kwargs['export_data'],
                                             image_name=suggested_name, operation_id=operation_id)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:9,代码来源:figure_controller.py


示例11: getmemberspage

 def getmemberspage(self, page, project_id=None):
     """Retrieve a new page of Project members."""
     current_name = common.get_logged_user().username
     all_users, members, _ = self.user_service.get_users_for_project(current_name, project_id, int(page))
     edit_enabled = True
     if project_id is not None:
         current_project = self.project_service.find_project(project_id)
         edit_enabled = (current_name == current_project.administrator.username)
     return dict(usersList=all_users, usersMembers=[m.id for m in members],
                 usersCurrentPage=page, editUsersEnabled=edit_enabled)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:10,代码来源:project_controller.py


示例12: switch_online_help

    def switch_online_help(self):
        """
        Switch flag that displays online helps
        """
        user = common.get_logged_user()

        # Change OnlineHelp Active flag and save user
        user.switch_online_help_state()
        self.user_service.edit_user(user)
        raise cherrypy.HTTPRedirect("/user/profile")
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:10,代码来源:users_controller.py


示例13: editresultfigures

    def editresultfigures(self, remove_figure=False, rename_session=False, remove_session=False, **data):
        """
        This method knows how to handle the following actions:
        remove figure, update figure, remove session and update session.
        """
        project = common.get_current_project()
        user = common.get_logged_user()

        redirect_url = '/project/figure/displayresultfigures'
        if "selected_session" in data and data["selected_session"] is not None and len(data["selected_session"]):
            redirect_url += '/' + data["selected_session"]
            del data["selected_session"]
        figure_id = None
        if "figure_id" in data:
            figure_id = data["figure_id"]
            del data["figure_id"]

        if cherrypy.request.method == 'POST' and rename_session:
            successfully_updated = True
            if "old_session_name" in data and "new_session_name" in data:
                figures_dict, _ = self.figure_service.retrieve_result_figures(project, user, data["old_session_name"])
                for _key, value in figures_dict.iteritems():
                    for figure in value:
                        new_data = {"name": figure.name, "session_name": data["new_session_name"]}
                        success = self._update_figure(figure.id, **new_data)
                        if not success:
                            successfully_updated = False
                if successfully_updated:
                    common.set_info_message("The session was successfully updated!")
                else:
                    common.set_error_message("The session was not successfully updated! "
                                             "There could be some figures that still refer to the old session.")
        elif cherrypy.request.method == 'POST' and remove_session:
            successfully_removed = True
            if "old_session_name" in data:
                figures_dict, _ = self.figure_service.retrieve_result_figures(project, user, data["old_session_name"])
                for _key, value in figures_dict.iteritems():
                    for figure in value:
                        success = self.figure_service.remove_result_figure(figure.id)
                        if not success:
                            successfully_removed = False
                if successfully_removed:
                    common.set_info_message("The session was removed successfully!")
                else:
                    common.set_error_message("The session was not entirely removed!")
        elif cherrypy.request.method == 'POST' and remove_figure and figure_id is not None:
            success = self.figure_service.remove_result_figure(figure_id)
            if success:
                common.set_info_message("Figure removed successfully!")
            else:
                common.set_error_message("Figure could not be removed!")
        elif figure_id is not None:
            self._update_figure(figure_id, **data)
        raise cherrypy.HTTPRedirect(redirect_url)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:54,代码来源:figure_controller.py


示例14: create_stimulus

 def create_stimulus(self):
     """
     Creates a stimulus from the given data.
     """
     context = common.get_from_session(KEY_REGION_CONTEXT)
     local_connectivity_creator = self.get_creator_and_interface(REGION_STIMULUS_CREATOR_MODULE,
                                                                 REGION_STIMULUS_CREATOR_CLASS, StimuliRegion())[0]
     context.equation_kwargs.update({'weight': json.dumps(context.get_weights())})
     self.flow_service.fire_operation(local_connectivity_creator, common.get_logged_user(),
                                      common.get_current_project().id, **context.equation_kwargs)
     common.set_important_message("The operation for creating the stimulus was successfully launched.")
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:11,代码来源:region_stimulus_controller.py


示例15: projectupload

 def projectupload(self, **data):
     """Upload Project from TVB ZIP."""
     self.logger.debug("Uploading ..." + str(data))
     try:
         upload_param = "uploadedfile"
         if upload_param in data and data[upload_param]:
             import_service = ImportService()
             import_service.import_project_structure(data[upload_param], common.get_logged_user().id)
     except ServicesBaseException, excep:
         self.logger.warning(excep.message)
         common.set_error_message(excep.message)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:11,代码来源:project_controller.py


示例16: profile

    def profile(self, logout=False, save=False, **data):
        """
        Display current user's profile page.
        On POST: logout, or save password/email.
        """
        if cherrypy.request.method == 'POST' and logout:
            raise cherrypy.HTTPRedirect('/user/logout')
        template_specification = dict(mainContent="profile", title="User Profile")
        user = common.get_logged_user()

        if cherrypy.request.method == 'POST' and save:
            try:
                form = EditUserForm()
                data = form.to_python(data)
                if data.get(KEY_PASSWORD):
                    user.password = md5(data[KEY_PASSWORD]).hexdigest()
                if data.get(KEY_EMAIL):
                    user.email = data[KEY_EMAIL]
                old_password = None
                if data.get('old_password'):
                    old_password = md5(data['old_password']).hexdigest()
                self.user_service.edit_user(user, old_password)
                if old_password:
                    common.set_info_message("Changes Submitted!")
                else:
                    common.set_info_message("Submitted!  No password changed.")
            except formencode.Invalid as excep:
                template_specification[common.KEY_ERRORS] = excep.unpack_errors()
            except UsernameException as excep:
                self.logger.exception(excep)
                user = common.get_logged_user()
                common.add2session(common.KEY_USER, self.user_service.get_user_by_id(user.id))
                common.set_error_message("Could not save changes. Probably wrong old password!!")
        else:
            #Update session user since disk size might have changed from last time to profile.
            user = self.user_service.get_user_by_id(user.id)
            common.add2session(common.KEY_USER, user)

        template_specification['user_used_disk_human'] = format_bytes_human(
            self.user_service.compute_user_generated_disk_size(user.id))
        return self.fill_default_attributes(template_specification)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:41,代码来源:users_controller.py


示例17: create_local_connectivity

 def create_local_connectivity(self, **kwargs):
     """
     Used for creating and storing a local connectivity.
     """
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     local_connectivity_creator = self.get_creator_and_interface(LOCAL_CONN_CREATOR_MODULE,
                                                                 LOCAL_CONN_CREATOR_CLASS, LocalConnectivity())[0]
     self.flow_service.fire_operation(local_connectivity_creator, common.get_logged_user(),
                                      common.get_current_project().id, **kwargs)
     common.set_important_message("The operation for creating the local connectivity was successfully launched.")
     context.reset()
     return self.step_1()
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:12,代码来源:local_connectivity_controller.py


示例18: __get_operations_filters

    def __get_operations_filters(self):
        """
        Filters for VIEW_ALL_OPERATIONS page.
        Get from session currently selected filters, or build a new set of filters.
        """
        session_filtes = common.get_from_session(self.KEY_OPERATION_FILTERS)
        if session_filtes:
            return session_filtes

        else:
            sim_group = self.flow_service.get_algorithm_by_module_and_class(SIMULATOR_MODULE, SIMULATOR_CLASS)[1]
            new_filters = StaticFiltersFactory.build_operations_filters(sim_group, common.get_logged_user().id)
            common.add2session(self.KEY_OPERATION_FILTERS, new_filters)
            return new_filters
开发者ID:unimauro,项目名称:tvb-framework,代码行数:14,代码来源:project_controller.py


示例19: _populate_user_and_project

    def _populate_user_and_project(self, template_dictionary, escape_db_operations=False):
        """
         Populate the template dictionary with current logged user (from session).
         """
        logged_user = common.get_logged_user()
        template_dictionary[common.KEY_USER] = logged_user
        show_help = logged_user is not None and logged_user.is_online_help_active()
        template_dictionary[common.KEY_SHOW_ONLINE_HELP] = show_help

        project = common.get_current_project()
        template_dictionary[common.KEY_PROJECT] = project
        if project is not None and not escape_db_operations:
            self.update_operations_count()
        return template_dictionary
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:14,代码来源:base_controller.py


示例20: displayresultfigures

 def displayresultfigures(self, selected_session='all_sessions'):
     """ Collect and display saved previews, grouped by session."""
     project = common.get_current_project()
     user = common.get_logged_user()
     data, all_sessions_info = self.figure_service.retrieve_result_figures(project, user, selected_session)
     manage_figure_title = "Figures for " + str(selected_session) + " category"
     if selected_session == 'all_sessions':
         manage_figure_title = "Figures for all categories"
     template_specification = dict(mainContent="project/figures_display", title="Stored Visualizer Previews",
                                   controlPage=None, displayControl=False, selected_sessions_data=data,
                                   all_sessions_info=all_sessions_info, selected_session=selected_session,
                                   manageFigureTitle=manage_figure_title)
     template_specification = self.fill_default_attributes(template_specification, subsection='figures')
     return template_specification
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:14,代码来源:figure_controller.py



注:本文中的tvb.interfaces.web.controllers.common.get_logged_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.set_error_message函数代码示例发布时间:2022-05-27
下一篇:
Python common.get_from_session函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap