Revision history [back]

click to hide/show revision 1
initial version

How to filter project name from the object returned?

{u'63f94f0b93524abe9fbf419bac2a0daf': <tenant {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'alt_demo',="" u'id':="" u'63f94f0b93524abe9fbf419bac2a0daf'}&gt;,="" u'66d219e9f37244b2a6b0a24d55bbbbbe':="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'demo',="" u'id':="" u'66d219e9f37244b2a6b0a24d55bbbbbe'}&gt;,="" u'6906db4d7e464777bb88300bbc38c8d6':="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'service',="" u'id':="" u'6906db4d7e464777bb88300bbc38c8d6'}&gt;,="" u'77d80df5c1444a7cae3f7add5baafb1f':="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'invisible_to_admin',="" u'id':="" u'77d80df5c1444a7cae3f7add5baafb1f'}&gt;,="" u'c5885810a9694d68a06942d90e5ba0a0':="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'admin',="" u'id':="" u'c5885810a9694d68a06942d90e5ba0a0'}&gt;}<="" p="">

From this how can i access all the names of the projects ? I want only the names alt_demo , demo, invisible_to_admin, admin to be stored in a list

How to filter project name from the object returned?

{u'63f94f0b93524abe9fbf419bac2a0daf': <tenant [<tenant {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'alt_demo',="" u'id':="" u'63f94f0b93524abe9fbf419bac2a0daf'}&gt;,="" u'66d219e9f37244b2a6b0a24d55bbbbbe':="" '63f94f0b93524abe9fbf419bac2a0daf'}&gt;,="" <tenant="" {u'enabled':="" true,="" u'description':="" u'description'="" none,="" u'name':="" u'demo',="" u'id':="" u'66d219e9f37244b2a6b0a24d55bbbbbe'}&gt;,="" u'6906db4d7e464777bb88300bbc38c8d6':="" <tenant="" {u'enabled':="" u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'service',="" u'id':="" u'6906db4d7e464777bb88300bbc38c8d6'}&gt;,="" u'77d80df5c1444a7cae3f7add5baafb1f':="" u'6906db4d7464777bb88300bbc38c8d6'}&gt;,="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'nme':="" u'invisible_to_admin',="" u'id':="" u'77d80df5c1444a7cae3f7add5baafb1f'}&gt;,="" u'c5885810a9694d68a06942d90e5ba0a0':="" <tenant="" <tenat="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'admin',="" u'id':="" u'c5885810a9694d68a06942d90e5ba0a0'}&gt;}<="" u'c58858109694d68a06942d90e5ba0a0'}&gt;]<="" p="">

From this how can i access all the names of the projects ? I want only the names alt_demo , demo, service, invisible_to_admin, admin to be stored in a list

How to filter project name from the object returned?

[<tenant {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'alt_demo',="" u'id':="" '63f94f0b93524abe9fbf419bac2a0daf'}&gt;,="" <tenant="" {u'enabled':="" true,="" u'description'="" none,="" u'name':="" u'demo',="" u'id':="" u'66d219e9f37244b2a6b0a24d55bbbbbe'}&gt;,="" <tenant="" u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'service',="" u'id':="" u'6906db4d7464777bb88300bbc38c8d6'}&gt;,="" <tenant="" {u'enabled':="" true,="" u'description':="" none,="" u'nme':="" u'invisible_to_admin',="" u'id':="" u'77d80df5c1444a7cae3f7add5baafb1f'}&gt;,="" <tenat="" {u'enabled':="" true,="" u'description':="" none,="" u'name':="" u'admin',="" u'id':="" u'c58858109694d68a06942d90e5ba0a0'}&gt;]<="" p="">

From this how can i access all the names of the projects ? I want only the names alt_demo , demo, service, invisible_to_admin, admin to be stored in a list

[<Tenant {u'enabled': True, u'description': None, u'name': u'alt_demo', u'id': '63f94f0b93524abe9fbf419bac2a0daf'}>, <Tenant {u'enabled': True, u'description' None, u'name': u'demo', u'id': u'66d219e9f37244b2a6b0a24d55bbbbbe'}>, <Tenant u'enabled': True, u'description': None, u'name': u'service', u'id': u'6906db4d7464777bb88300bbc38c8d6'}>, <Tenant {u'enabled': True, u'description': None, u'nme': u'invisible_to_admin', u'id': u'77d80df5c1444a7cae3f7add5baafb1f'}>, <Tenat {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'c58858109694d68a06942d90e5ba0a0'}>]

How to filter project name from the object returned?

 From this how can i access all the names of the projects ? I want only the names alt_demo , demo, service,  invisible_to_admin, admin  to be stored in a list 

 [<Tenant {u'enabled': True, u'description': None, u'name': u'alt_demo', u'id': '63f94f0b93524abe9fbf419bac2a0daf'}>, u'63f94f0b93524abe9fbf419bac2a0daf'}>, 
<Tenant {u'enabled': True, u'description' u'description': None, u'name': u'demo', u'id': u'66d219e9f37244b2a6b0a24d55bbbbbe'}>, u'66d219e9f37244b2a6b0a24d55bbbbbe'}>,
<Tenant u'enabled': {u'enabled': True, u'description': None, u'name': u'service', u'id': u'6906db4d7464777bb88300bbc38c8d6'}>, u'6906db4d7e464777bb88300bbc38c8d6'}>,
<Tenant {u'enabled': True, u'description': None, u'nme': u'name': u'invisible_to_admin', u'id': u'77d80df5c1444a7cae3f7add5baafb1f'}>, <Tenat 
<Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'c58858109694d68a06942d90e5ba0a0'}>]
u'c5885810a9694d68a06942d90e5ba0a0'}>]


    This is my code:
    project = forms.ChoiceField(label=_("Project"),
                                    required=True)

        def __init__(self, request, *args, **kwargs):
            super(CreateAlarmInfoAction, self).__init__(request,
                                                        *args, **kwargs)
            self.fields['project'].choices = (
                self.get_project_list_choices(request))

        def get_project_list_choices(self, request):
            project_choices = [('', _("Select a Project"))]
            for project in self._get_projects(request):
                for obj in range(len(project)):
                    project_choices.append(project[obj].id, project[obj].name)

        def _get_projects(self, request):
            projects = []
            try:
                projects = api.keystone.tenant_list(request)
            except Exception:
                msg = _('Project list cannot be retrieved.')
                exceptions.handle(request, msg)
            return projects

How to filter project name from the object returned?

    From this how can i access all the names of the projects ? I want only the names alt_demo , demo, service,  invisible_to_admin, admin  to be stored in a list 

       [<Tenant {u'enabled': True, u'description': None, u'name': u'alt_demo', u'id': u'63f94f0b93524abe9fbf419bac2a0daf'}>, 
<Tenant {u'enabled': True, u'description': None, u'name': u'demo', u'id': u'66d219e9f37244b2a6b0a24d55bbbbbe'}>,
<Tenant {u'enabled': True, u'description': None, u'name': u'service', u'id': u'6906db4d7e464777bb88300bbc38c8d6'}>,
<Tenant {u'enabled': True, u'description': None, u'name': u'invisible_to_admin', u'id': u'77d80df5c1444a7cae3f7add5baafb1f'}>, 
<Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'c5885810a9694d68a06942d90e5ba0a0'}>]


    This is my code:
    project = forms.ChoiceField(label=_("Project"),
                                    required=True)

        def __init__(self, request, *args, **kwargs):
            super(CreateAlarmInfoAction, self).__init__(request,
                                                        *args, **kwargs)
            self.fields['project'].choices = (
                self.get_project_list_choices(request))

        def get_project_list_choices(self, request):
            project_choices = [('', _("Select a Project"))]
            for project in self._get_projects(request):
                for obj in range(len(project)):
                    project_choices.append(project[obj].id, project[obj].name)

        def _get_projects(self, request):
            projects = []
            try:
                projects = api.keystone.tenant_list(request)
            except Exception:
                msg = _('Project list cannot be retrieved.')
                exceptions.handle(request, msg)
            return projects

The append part isnt working fine.