Skip to content

AttributeError: 'Request' object has no attribute 'swagger_data' #29

@ArktinenSieni

Description

@ArktinenSieni
2016-11-16T13:57:46.813518+00:00 app[web.1]:     app_id = self.request.swagger_data['appid']
2016-11-16T13:57:46.813524+00:00 app[web.1]: AttributeError: 'Request' object has no attribute 'swagger_data'

Does anyone know what's going on?

This works

    @view_config(route_name='configurationkeys_for_app', request_method="GET")
    def configurationkeys_GET(self):
        """ List all configurationkeys with GET method """
        app_id = self.request.swagger_data['id']
        if Application.get(app_id) is None:
            print_log(datetime.datetime.now(), 'GET', '/applications/%s/configurationkeys'\
                % app_id, 'Get configurationkeys', 'Failed')
            return self.createResponse(None, 400)
        app_conf_keys = ConfigurationKey.query().join(Application).filter(Application.id == app_id)
        return list(map(lambda _: _.as_dict(), app_conf_keys))

And this doesn't

    @view_config(route_name='configurationkey', request_method="GET")
    def configurationkeys_GET_one(self):
        """ Find and return one configurationkey by id with GET method """
        app_id = self.request.swagger_data['appid']
        confkey_id = self.request.swagger_data['ckid']
        confkey = get_conf_key_by_appid_and_ckid(app_id, confkey_id)
        if confkey is None:
            print_log(datetime.datetime.now(), 'GET',\
                '/applications/%s/configurationkeys/' % app_id
                + str(confkey_id), 'Get one configurationkey', 'Failed')
            return self.createResponse(None, 400)
        return confkey.as_dict()

Added routes are:

    config.add_route('configurationkeys_for_app', '/applications/{id}/configurationkeys')
    config.add_route('configurationkey', '/applications/{appid}/configurationkeys/{ckid}')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions