当前位置: 首页>>代码示例>>Python>>正文


Python dicts.merge函数代码示例

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


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

示例1: select

  def select(self, request, view, redirect,
             page_name=None, params=None, filter=None):
    """Displays a list page allowing the user to select an entity.

    After having selected the Scope, the user is redirected to the
    'create a new entity' page with the scope_path set appropriately.

    Params usage:
      The params dictionary is also passed to getListContent from
        the helper.list module, please refer to its docstring also.
      The params dictionary is passed to self._list as well, refer
        to its docstring for details on how it uses it.

    Args:
      request: the standard Django HTTP request object
      view: the view for which to generate the select page
      redirect: the redirect to use
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      filter: a filter that all displayed entities should satisfy
    """

    params = dicts.merge(params, view.getParams())
    params = dicts.merge(params, self._params)
    params['list_action'] = (redirect, self._params)
    params['list_description'] = self.DEF_CREATE_INSTRUCTION_MSG_FMT % (
        params['name'], self._params['name'])

    content = helper.lists.getListContent(request, params, filter=filter)
    contents = [content]

    return self._list(request, params, contents, page_name)
开发者ID:ajaksu,项目名称:Melange,代码行数:32,代码来源:base.py

示例2: testMergeWhenBothSubListsAndDictsArePresent

  def testMergeWhenBothSubListsAndDictsArePresent(self):
    """Tests that lists and dicts can not be merged.
    """
    #do not merge lists and dicts and sub_merge is True
    target = self.dummy_dict.copy()
    target.update({'foo': {'alpha': 1, 'beta': 2}})
    updates = {'foo':['gamma', 'delta']}
    expected = target
    self.assertEqual(dicts.merge(target, updates), expected)

    target = self.dummy_dict.copy()
    target.update({'foo':['gamma', 'delta']})
    updates = {'foo': {'alpha': 1, 'beta': 2}}
    expected = target
    self.assertEqual(dicts.merge(target, updates), expected)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:15,代码来源:test_dicts.py

示例3: testMergeWhenBothSubListsAndDictsArePresent

    def testMergeWhenBothSubListsAndDictsArePresent(self):
        """Tests that lists and dicts can not be merged.
    """
        # do not merge lists and dicts and sub_merge is True
        target = self.dummy_dict.copy()
        target.update({"foo": {"alpha": 1, "beta": 2}})
        updates = {"foo": ["gamma", "delta"]}
        expected = target
        self.assertEqual(dicts.merge(target, updates), expected)

        target = self.dummy_dict.copy()
        target.update({"foo": ["gamma", "delta"]})
        updates = {"foo": {"alpha": 1, "beta": 2}}
        expected = target
        self.assertEqual(dicts.merge(target, updates), expected)
开发者ID:praveen97uma,项目名称:GSoC-Docs,代码行数:15,代码来源:test_dicts.py

示例4: create

  def create(self, request, access_type,
             page_name=None, params=None, **kwargs):
    """Displays the create page for this entity type.

    Params usage:
      The params dictionary is passed on to edit, see the docstring
      for edit on how it uses it.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: not used for create()
    """

    new_params = dicts.merge(params, self._params)

    # redirect to scope selection view
    if ('scope_view' in new_params) and ('scope_path' not in kwargs):
      view = new_params['scope_view'].view
      redirect = new_params['scope_redirect']
      return self.select(request, view, redirect,
                         params=params, page_name=page_name, **kwargs)

    params = new_params

    context = helper.responses.getUniversalContext(request)
    helper.responses.useJavaScript(context, params['js_uses_all'])
    context['page_name'] = page_name

    if request.method == 'POST':
      return self.createPost(request, context, params)
    else:
      return self.createGet(request, context, params, kwargs)
开发者ID:ajaksu,项目名称:Melange,代码行数:35,代码来源:base.py

示例5: listPublic

  def listPublic(self, request, access_type, page_name=None,
                 params=None, filter=None, **kwargs):
    """See base.View.list.
    """

    account = accounts.getCurrentAccount()
    user = user_logic.logic.getForAccount(account) if account else None

    try:
      rights = self._params['rights']
      rights.setCurrentUser(account, user)
      rights.checkIsHost()
      is_host = True
    except out_of_band.Error:
      is_host = False

    params = params.copy()

    if is_host:
      params['list_action'] = (redirects.getAdminRedirect, params)
    else:
      params['list_action'] = (redirects.getPublicRedirect, params)

    new_filter = {}

    new_filter['scope_path'] = kwargs['scope_path']
    new_filter['status'] = 'active'
    filter = dicts.merge(filter, new_filter)

    content = lists.getListContent(request, params, filter)
    contents = [content]

    return self._list(request, params, contents, page_name)
开发者ID:jamslevy,项目名称:gsoc,代码行数:33,代码来源:organization.py

示例6: getSidebarMenus

  def getSidebarMenus(self, id, user, params=None):
    """See base.View.getSidebarMenus.

    Returns a custom sidebar entry for the 'site' singleton.
    """

    entity = self._logic.getSingleton()

    submenus = document_view.view.getMenusForScope(entity, self._params)

    try:
      rights = self._params['rights']
      rights.setCurrentUser(id, user)
      rights.checkIsHost()
      is_host = True
    except out_of_band.Error:
      is_host = False

    if is_host:
      submenus += [(redirects.getCreateDocumentRedirect(entity, 'site'),
          "Create a New Document", 'any_access')]

      submenus += [(redirects.getListDocumentsRedirect(entity, 'site'),
          "List Documents", 'any_access')]
    submenus += [('/priority_group/list', "List Priority Groups", 'edit')]
    submenus += [('/job/list', "List Jobs", 'edit')]

    new_params = {}
    new_params['sidebar_additional'] = submenus

    params = dicts.merge(params, new_params)
    return super(View, self).getSidebarMenus(id, user, params=params)
开发者ID:ajaksu,项目名称:Melange,代码行数:32,代码来源:site.py

示例7: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the mentor View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = gci_access.GCIChecker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkIsMyActiveRole', gci_mentor_logic.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasRoleForScope',
                         gci_org_admin_logic.logic)]
    rights['accept_invite'] = [
        ('checkIsMyRequestWithStatus', [['group_accepted']]),
        ('checkIsNotStudentForProgramOfOrgInRequest',
         [gci_org_logic.logic, gci_student_logic.logic])]
    rights['request'] = [
        ('checkIsNotStudentForProgramOfOrg',
         [gci_org_logic.logic, gci_student_logic.logic]),
        ('checkCanMakeRequestToGroup', gci_org_logic.logic)]
    rights['process_request'] = [
        ('checkCanProcessRequest', [[gci_org_admin_logic.logic]])]
    rights['manage'] = [
        ('checkIsAllowedToManageRole', [gci_mentor_logic.logic,
                                        gci_org_admin_logic.logic])]
    rights['list_mentor_tasks'] = [
        ('checkCanOpenTaskList', [gci_mentor_logic.logic, 'gci/mentor']),
        ('checkIsAfterEvent', ['accepted_organization_announced_deadline',
                               '__all__', gci_program_logic.logic])]

    new_params = {}
    new_params['logic'] = soc.modules.gci.logic.models.mentor.logic
    new_params['group_logic'] = gci_org_logic.logic
    new_params['group_view'] = gci_org_view.view
    new_params['rights'] = rights

    new_params['scope_view'] = gci_org_view

    new_params['name'] = "GCI Mentor"
    new_params['module_name'] = "mentor"
    new_params['sidebar_grouping'] = 'Organizations'

    new_params['module_package'] = 'soc.modules.gci.views.models'
    new_params['url_name'] = 'gci/mentor'

    new_params['role'] = 'gci/mentor'

    patterns = []
    patterns += [
        (r'^%(url_name)s/(?P<access_type>list_mentor_tasks)/%(key_fields)s$',
        '%(module_package)s.%(module_name)s.list_mentor_tasks',
        'List Mentor tasks')]

    new_params['extra_django_patterns'] = patterns

    params = dicts.merge(params, new_params, sub_merge=True)

    super(View, self).__init__(params=params)
开发者ID:SRabbelier,项目名称:Melange,代码行数:60,代码来源:mentor.py

示例8: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    new_params = {}
    new_params['logic'] = student_project_logic
    new_params['name'] = "Student Project"
    new_params['url_name'] = "student_project"

    patterns = [
        (r'^%(url_name)s/(?P<access_type>manage_overview)/%(scope)s$',
        'soc.views.models.%(module_name)s.manage_overview',
        'Overview of %(name_plural)s to Manage for'),
        (r'^%(url_name)s/(?P<access_type>manage)/%(key_fields)s$',
        'soc.views.models.%(module_name)s.manage',
        'Manage %(name)s'),
        (r'^%(url_name)s/(?P<access_type>st_edit)/%(key_fields)s$',
        'soc.views.models.%(module_name)s.st_edit',
        'Edit my %(name)s'),
    ]

    new_params['extra_django_patterns'] = patterns

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
开发者ID:SRabbelier,项目名称:Melange,代码行数:30,代码来源:student_project.py

示例9: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['any_access'] = ['allow']
    rights['show'] = [('checkIsSurveyReadable', project_survey_logic)]
    rights['create'] = ['checkIsUser']
    rights['edit'] = [('checkIsSurveyWritable', project_survey_logic)]
    rights['delete'] = [('checkIsSurveyWritable', project_survey_logic)]
    rights['list'] = ['checkDocumentList']
    rights['pick'] = ['checkDocumentPick']

    new_params = {}
    new_params['logic'] = project_survey_logic
    new_params['rights'] = rights

    new_params['name'] = "Project Survey"

    new_params['extra_dynaexclude'] = ['taking_access']

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
开发者ID:ajaksu,项目名称:Melange,代码行数:28,代码来源:project_survey.py

示例10: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['any_access'] = ['allow']
    rights['show'] = [('checkIsSurveyReadable', grading_survey_logic)]
    rights['create'] = ['checkIsUser']
    rights['edit'] = [('checkIsSurveyWritable', grading_survey_logic)]
    rights['delete'] = [('checkIsSurveyWritable', grading_survey_logic)]
    rights['list'] = ['checkDocumentList']
    rights['pick'] = ['checkDocumentPick']

    new_params = {}
    new_params['logic'] = grading_survey_logic
    new_params['rights'] = rights

    new_params['extra_django_patterns'] = [
        (r'^%(url_name)s/(?P<access_type>activate)/%(scope)s$',
         'soc.views.models.%(module_name)s.activate',
         'Activate grades for %(name)s')]

    new_params['name'] = "Grading Project Survey"

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
开发者ID:ajaksu,项目名称:Melange,代码行数:31,代码来源:grading_project_survey.py

示例11: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the work_submission.

    Params:
      params: a dict with params for this View
    """

    rights = gci_access.GCIChecker(params)
    rights['any_access'] = ['allow']
    rights['download_blob'] = ['allow']

    new_params = {}
    new_params['logic'] = soc.modules.gci.logic.models.work_submission.logic
    new_params['rights'] = rights

    new_params['name'] = "Work Submission"
    new_params['module_name'] = "work_submission"

    new_params['module_package'] = 'soc.modules.gci.views.models'
    new_params['url_name'] = 'gci/work_submission'

    patterns = []
    patterns += [
        (r'^%(url_name)s/(?P<access_type>download_blob)$',
        '%(module_package)s.%(module_name)s.download_blob',
        'Download the blob'),
        ]

    new_params['extra_django_patterns'] = patterns

    params = dicts.merge(params, new_params, sub_merge=True)

    super(View, self).__init__(params=params)
开发者ID:SRabbelier,项目名称:Melange,代码行数:33,代码来源:work_submission.py

示例12: getSidebarMenus

  def getSidebarMenus(self, id, user, params=None):
    """See base.View.getSidebarMenus.

    Returns a custom sidebar entry for the 'site' singleton.
    """

    entity = site_logic.getSingleton()

    submenus = document_view.view.getMenusForScope(entity, self._params)

    try:
      rights = self._params['rights']
      rights.setCurrentUser(id, user)
      rights.checkIsHost()
      is_host = True
    except out_of_band.Error:
      is_host = False

    if is_host:
      submenus += [(redirects.getCreateDocumentRedirect(entity, 'site'),
          "Create a New Document", 'any_access')]

      submenus += [(redirects.getListDocumentsRedirect(entity, 'site'),
          "List Documents", 'any_access')]

    if entity.cse_key:
      # only add the search entry if a key is defined
      submenus += [('/site/search', 'Search', 'any_access')]

    new_params = {}
    new_params['sidebar_additional'] = submenus

    params = dicts.merge(params, new_params)
    return super(View, self).getSidebarMenus(id, user, params=params)
开发者ID:SRabbelier,项目名称:Melange,代码行数:34,代码来源:site.py

示例13: listPublic

  def listPublic(self, request, access_type, page_name=None,
                 params=None, filter=None, **kwargs):
    """See base.View.list.
    """

    account = accounts.getCurrentAccount()
    user = user_logic.logic.getForAccount(account) if account else None

    try:
      rights = self._params['rights']
      rights.setCurrentUser(account, user)
      rights.checkIsHost()
      is_host = True
    except out_of_band.Error:
      is_host = False

    params = params.copy()

    if is_host:
      params['public_row_extra'] = lambda entity: {
          'link': redirects.getAdminRedirect(entity, params)
      }
    else:
      params['public_row_extra'] = lambda entity: {
          'link': redirects.getPublicRedirect(entity, params)
      }

    new_filter = {}

    new_filter['scope_path'] = kwargs['scope_path']
    new_filter['status'] = 'active'
    filter = dicts.merge(filter, new_filter)

    return self.list(request, 'allow', page_name=page_name,
                      params=params, filter=filter)
开发者ID:SRabbelier,项目名称:Melange,代码行数:35,代码来源:organization.py

示例14: __init__

  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)

    new_params = {}
    new_params['rights'] = rights
    new_params['logic'] = job_logic

    new_params['name'] = "Job"

    new_params['no_create_raw'] = True
    new_params['no_create_with_scope'] = True
    new_params['no_create_with_key_fields'] = True

    new_params['extra_dynaexclude'] = ['key_data', 'text_data']

    new_params['edit_dynaproperties'] = {
      'task': forms.CharField(widget=widgets.PlainTextWidget()),
      }

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
开发者ID:ajaksu,项目名称:Melange,代码行数:29,代码来源:job.py

示例15: _list

  def _list(self, request, params, contents, page_name, context=None):
    """Returns the list page for the specified contents.

    Args:
      request: the standard Django HTTP request object
      params: a dict with params for this View
      contents: a list of content dicts
      page_name: the page name displayed in templates as page and header title
      context: the context for this page

    Params usage:
      list_template: The list_template value is used as template for
        to display the list of all entities for this View.
    """

    context = dicts.merge(context,
        helper.responses.getUniversalContext(request))
    helper.responses.useJavaScript(context, params['js_uses_all'])
    context['page_name'] = page_name
    context['list'] = soc.logic.lists.Lists(contents)

    context['list_msg'] = params.get('list_msg', None)
    context['no_lists_msg'] = params.get('no_lists_msg', None)

    template = params['list_template']

    return helper.responses.respond(request, template, context)
开发者ID:SRabbelier,项目名称:Melange,代码行数:27,代码来源:base.py


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