Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > OOP noob question: Mixin properties

Thread Tools

OOP noob question: Mixin properties

Micky Hulse
Posts: n/a
Dear Python Santa gurus, ;D

I have this Django mixin:


....which is used to override render_to_response() so I can output a
JSON response (the above code is pretty much straight from the Django
docs: <>).

The JSONResponseMixin() gets added to my view class like so:

class Api(JSONResponseMixin, BaseDetailView):
# ...

Within my the file, at the top of the file, I've added these

CACHE_TIMEOUT = 86400 # 24 hours.
CACHE_NAME = 'ad_manager_api'


I'd like to convert those constants to properties and make my
JSONResponseMixin() class more generic and portable.

Django aside, could someone provide OOP Python examples of how I could
instantiate a mixin Class and set/override its properties before
passing data to said mixin?

I hope you don't mind that this question involves Django... I'm just
looking to improve my core Python skills (so, generic Python examples
would be cool).

Many thanks in advance!

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: OOP noob question: Mixin properties Micky Hulse Python 2 12-14-2012 07:01 PM
Re: OOP noob question: Mixin properties Micky Hulse Python 0 12-13-2012 08:51 PM
Here a noob, there a noob.... JimDoire MCSE 0 04-10-2008 07:23 PM
How to use dynamic properties? <-- Noob Sean Schertell Python 1 01-23-2007 08:17 AM
mixin class Udo Gleich Python 5 07-31-2003 03:42 AM