This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
django_dynproxy
===============

Dynamic proxy models for Django

With django_dynproxy, you can dynamically modify a Django proxy model by :
* hiding one or many fields (from the concrete parent model)
* making mandatory one or many fields (who are not mandatory in the concrete parent model)

This can be useful when you want to use inheritance in your code, but not in your database

WARNING : THIS IS AN ALPHA RELEASE. NOT RECOMMENDED FOR PRODUCTION USE

Requirements :
--------------

django>=1.4.3

Installation :
--------------

pip install django_dynproxy

Usage :
---------

1) Create a concrete model

2) Create a Django proxy model deriving from the concrete model

3) Define a metaclass using dynproxy_metaclass_factory and specify :
- which base fields you want to exclude from your proxy model
- which non-mandatory base fields you want to be mandatory your proxy model

4) Add the __metaclass__ to your proxy model class


Sample :
---------

from dynproxy.utils import dynproxy_metaclass_factory

TRAVELER_TYPE_PILOT = '1'
TRAVELER_TYPE_PASSENGER = '2'

TRAVELER_TYPES = (
(TRAVELER_TYPE_PILOT,_(u"Pilot")),
(TRAVELER_TYPE_PASSENGER,_(u"Passenger"))
)

class Traveler(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
type = models.CharField(max_length=200,choices=TRAVELER_TYPES)
passport_number = models.CharField(max_length=200,blank=True)
trigram = models.CharField(max_length=200,blank=True)
pilot_category = models.ForeignKey(PilotCategory,null=True,blank=True)


def __unicode__(self):
return "%s %s" % (self.first_name,self.last_name)

def traveler_manager_factory(traveler_type):
class _TravelerManager(Manager):
def get_query_set(self):
return super(_TravelerManager,self).get_query_set().filter(type=traveler_type)
return _TravelerManager

PilotManager = traveler_manager_factory(TRAVELER_TYPE_PILOT)
PassengerManager = traveler_manager_factory(TRAVELER_TYPE_PASSENGER)


PilotMetaclass = dynproxy_metaclass_factory(
mandatory_fields=['trigram','pilot_category'],
fields_to_exclude=['passport_number']
)

PassengerMetaclass = dynproxy_metaclass_factory(
mandatory_fields = ['passport_number'],
fields_to_exclude =['trigram','pilot_category']
)


class Pilot(Traveler):
__metaclass__ = PilotMetaclass
objects = PilotManager()
class Meta:
proxy = True

class Passenger(Traveler):
__metaclass__ = PassengerMetaclass
objects = PassengerManager()
class Meta:
proxy = True
Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_dynproxy-0.2.0.zip (3.3 kB) Copy SHA256 Checksum SHA256 Source Jan 21, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting