Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

OOP noob question: Mixin properties

 
 
Micky Hulse
Guest
Posts: n/a
 
      12-13-2012
Dear Python Santa gurus, ;D

I have this Django mixin:

<https://github.com/registerguard/django-ad-manager/blob/8628bfe70f6ca68cb7b0373cee7da52613c7531a/ad_manager/mixins.py>

....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: <https://docs.djangoproject.com/en/1.3/topics/class-based-views/#more-than-just-html>).

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

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

Within my the mixins.py file, at the top of the file, I've added these
constants:

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

Question(s):

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!

Cheers,
Micky
 
Reply With Quote
 
 
 
Reply

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



Advertisments