Пример #1
0
    def post(self, *args, **kwargs):
        public_key_id = PublicKey.encode(self.params.post['public_key'])

        try:
            key = PublicKey.get(public_key_id)
        except:
            key = PublicKey.create(public_key_id=public_key_id,
                                   raw=self.params.post['public_key'])

        return marshal_and_count('keys', key, f=self.params.fields)
Пример #2
0
    def wrapper(self, *args, **kwargs):
        parser.add_argument(header,
                            type=str,
                            location='headers',
                            help='Specify %s on headers' % header)

        args = parser.parse_args()

        if not (header in args and args[header] is not None):
            return abort(401)
        try:
            public_key = PublicKey.select().where(
                PublicKey.public_key_id == args[header]).get()
        except:
            return abort(401)

        return controller(self, public_key)