hacknight
hacknight copied to clipboard
Models need __repr__ methods
All models need to implement __repr__ to aid in debugging. The output from this method should be like this:
<(Model) (id) (title) [of (parent)]>
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>
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.
Got it. does parent actually mean baseclass(db.model, BaseMixin) or something else ?
Parent is container. There's a coaster ticket about changing the term. Need migrations again.