You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Be able to easily deserialise Model objects from cache responses #13
Accessing eg. my_customer.values is a reasonable way of serialising a model object for eg. caching locally in memcache or redis.
But after retrieving from the cache, deserialising could be easier. Objects without nested subtypes are available via chargebee.Card.construct(values). But currently to get a Customer model instance back from a cache result (.values object), you need to jump through hoops:
my_customer = chargebee.Customer.construct(values,
# need to pass in the subtypes to be deserialized properly
# I got these from chargebee/result.py
sub_types={
'billing_address' : chargebee.Customer.BillingAddress,
'contacts' : chargebee.Customer.Contact,
'payment_method' : chargebee.Customer.PaymentMethod
}
)
Simple-ish solution could be to override construct() in models with subtypes, and move the hardcoded stuff from result.py into the model.
More complex would be for .construct() or a metaclass could find the sub-types?
Activity