Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
rcoup wants to merge 2 commits into
chargebee:master from
koordinates:repr-methods
Open

Add useful __repr__() methods to Model & Result #22
rcoup wants to merge 2 commits into
chargebee:master from
koordinates:repr-methods

Conversation

@rcoup

@rcoup rcoup commented Feb 7, 2018

Copy link
Copy Markdown

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 commented Feb 7, 2018

Copy link
Copy Markdown
Author

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 commented Feb 19, 2018

Copy link
Copy Markdown
Contributor

@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 commented Feb 19, 2018

Copy link
Copy Markdown
Author

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

rcoup commented May 24, 2019

Copy link
Copy Markdown
Author

has been updated against master ~2.6.4.

Any chance of some attention?

rcoup commented Jan 20, 2020

Copy link
Copy Markdown
Author

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /