Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useful __repr__() methods to Model & Result #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rcoup
Copy link

@rcoup rcoup commented Feb 7, 2018

Fix for #12

Uses Model.fields[0] by default, but can be overridden via Model.repr_field

eg.

>>> r = chargebee.Subscription.list({})[0]
>>> r
<chargebee.Result: customer;subscription>
>>> r.customer
<chargebee.Customer: id=1mk51RNQdn96z7hT6>
>>> r.subscription
<chargebee.Subscription: id=1mkVvvHQiQMbLBBf>
>>> r.customer.billing_address
<chargebee.BillingAddress: zip=None>

@rcoup
Copy link
Author

rcoup commented Feb 7, 2018

I went through the models and set repr_field on anything where fields[0] was obviously not useful (eg. last_name), but there might be better options.

@vikiuvb
Copy link
Contributor

vikiuvb commented Feb 19, 2018

@rcoup Thanks for your contributions to our Python API library. We are planning to change repr() to render in the format '<modelName #id at #objectId> JSON: #response'. Will it work for you?

@rcoup
Copy link
Author

rcoup commented Feb 19, 2018

@vikiuvb can you paste in an example? Feels like the entire JSON is too verbose to put in a repr string?

@rcoup
Copy link
Author

rcoup commented May 24, 2019

has been updated against master ~2.6.4.

Any chance of some attention?

@rcoup
Copy link
Author

rcoup commented Jan 20, 2020

Updated again against 2.7.1

Uses the Model.fields[0] by default, but can be overridden via `Model.repr_field`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants