Complex type with nested user type validation issues

15 views
Skip to first unread message

brandon logan

unread,
Sep 10, 2014, 8:12:33 PM9/10/14
to pytho...@googlegroups.com
I'm having an issue where incoming validation of a complex type with a nested user type (IPv4Address) is failing validation when it is a correct ipv4 address.  I am using using WSME 0.6.1 and python 2.7.6.

Complex Types:
class VIP(wtypes.Base):
    ip_address
= wtypes.wsattr(wtypes.IPv4AddressType)


class LoadBalancer(wtypes.Base):
    vip
= wtypes.wsattr(VIP, mandatory=True)

Controllers:
@pecan.wsexpose(v1types.LoadBalancer, body=v1types.LoadBalancer)
def post(self, load_balancer):
   
return load_balancer


When doing a POST to the correct resource with this body:

{"vip": {"ip_address": "10.0.0.1"}}

I am getting this error:

{
debuginfo
: null
faultcode
: "Server"
faultstring
: "Value should be IPv4 format"
}


it looks like in the fromjson method when it starts validating the actual ip "10.0.0.1" it is sending an instantiation of the IPv4AddressType instead of the actual ip address "10.0.0.1" to wsme.types.validate_value.  Am I doing something wrong or is this a bug?  The stack trace did not yield anymore information, unless you want the actual methods called.  I can provide that if needed.

Thanks,
Brandon

brandon logan

unread,
Sep 10, 2014, 8:18:17 PM9/10/14
to pytho...@googlegroups.com
Since I decided I would be smart for a change and test this out with any nesting, the validation below fails even if VIP is removed and LoadBalancer becomes this:

class LoadBalancer(wtypes.Base):
    ip_address
= wtypes.wsattr(wtypes.IPv4AddressType)


Controller method and decorators stay the same.

I must be doing something wrong.

Thanks,
Brandon

brandon logan

unread,
Sep 11, 2014, 2:36:49 AM9/11/14
to pytho...@googlegroups.com
As I suspected it was me.  You're supposed to instantiate the type: wtypes.IPv4AddressType()

There, however, does appear to be a bug with the validate method of the IPv4AddressType.  Looks like that method is supposed to return the value but it doesn't return anything.

Thanks,
Brandon
Reply all
Reply to author
Forward
0 new messages