UserType object on wsexpose: 'UuidType' object has no attribute '__name__'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
WSME |
Fix Released
|
Undecided
|
Lucas Alvares Gomes |
Bug Description
Using an UserType instance with the wsexpose decorator in WSME will fail with:
Traceback (most recent call last):
File "/usr/local/
pecan.
File "/usr/local/
from_args = args_from_
File "/usr/local/
"unable to convert to %s" % argdef.
AttributeError: 'UuidType' object has no attribute '__name__'
To fix it, the the args_from_args() function at wsme/rest/args.py should check whether the argument type is an object instance of UserType before trying to access it's __name___ attribute.
My new user type Implementation looks like:
class UuidType(
"""A simple UUID type."""
basetype = wtypes.text
name = 'uuid'
@staticmethod
def validate(value):
if not utils.is_
raise exception.
return value
@staticmethod
def frombasetype(
return UuidType.
uuid_type = UuidType()
On the controller I've something like:
class FakeController(
@wsme_
def get_one(self, obj_uuid):
....
I can use my new type as the type of the attributes of my API object class, e.g:
class Object(
uuid = uuid_type
But I also would like to use it on the wsexpose decorator, just like I do with native types as int, bool etc...
Versions:
pecan (0.4.2)
WSME (0.5b6)
Changed in wsme: | |
assignee: | nobody → Lucas Alvares Gomes (lucasagomes) |
Changed in wsme: | |
status: | New → In Progress |
Changed in wsme: | |
milestone: | none → 0.8.0 |
status: | Fix Committed → Fix Released |
Reviewed: https:/ /review. openstack. org/64715 /git.openstack. org/cgit/ stackforge/ wsme/commit/ ?id=228bfbd084f f2c4653740696d2 6ed10748aaa33c
Committed: https:/
Submitter: Jenkins
Branch: master
commit 228bfbd084ff2c4 653740696d26ed1 0748aaa33c
Author: Lucas Alvares Gomes <email address hidden>
Date: Thu Jan 2 19:25:45 2014 +0000
args_ from_args( ) to work with an instance of UserType
When the args_from_args() function fails to convert a value to a certain
type it tries to get the name of that type by using the __name__ attribute
of that type, UserType object instances doesn't have the __name__
attribute so the function fails when it tries to access it, this patch
makes WSME to check if it's an UserType instance before getting it's name.
Change-Id: If78ce0e6429974 21c97559cc28604 421f5c03922
Closes-Bug: #1265590