-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
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?
raicheff
Metadata
Metadata
Assignees
Labels
No labels