hacknight icon indicating copy to clipboard operation
hacknight copied to clipboard

Models need __repr__ methods

Open jace opened this issue 12 years ago • 4 comments

All models need to implement __repr__ to aid in debugging. The output from this method should be like this:

<(Model) (id) (title) [of (parent)]>

jace avatar Jan 14 '13 20:01 jace

Example

Participant has parent db.model & BaseMixin. I feel we should add all attributes in __repr__.

<Participant user_id: xxxxxxx, user: User Object .., event_id: 3, event: Event Object so on inherits db.model, BaseMixin>

kracekumar avatar Jan 15 '13 19:01 kracekumar

repr is meant to be a debugging aid so you can see what you got when you do a query.all(). Anything more than id, name and title is too much detail. The repr needn't be eval ready code.

jace avatar Jan 15 '13 19:01 jace

Got it. does parent actually mean baseclass(db.model, BaseMixin) or something else ?

kracekumar avatar Jan 15 '13 19:01 kracekumar

Parent is container. There's a coaster ticket about changing the term. Need migrations again.

jace avatar Jan 15 '13 19:01 jace