Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.392.391 Times

django-immutablefield 0.1.1

Company: Rob Madole
Date Added: December 02, 2013  |  Visits: 359

django-immutablefield

Report Broken Link
Printer Friendly Version


Product Homepage
Download (32 downloads)



django-immutablefield is inspired by a Google search that didn't turn up a reusable solution for making fields immutable inside of a Django model.<br /><br />Installing<br /><br />One of the following:<br /><br />Via the ole' standby:<br /><br />easy_install django-immutablefield<br /><br />Pip:<br /><br />pip install django-immutablefield<br /><br />To install directly from Bitbucket:<br /><br />pip install -e hg+http://bitbucket.org/robmadole/django-immutablefield#egg=django-immutablefield<br /><br />Hint<br /><br />You do not need to add anything into Django's INSTALLED_APPS<br /><br />What does it do<br /><br />Allows you to define certain fields as immutable inside of Django models.<br /><br />It works as a drop-in replacement for Django's own Model. This means you can ImmutableModel even if you don't specify ImmutableMeta.<br /><br />from django.db import models<br /><br />from immutablefield.models import ImmutableModel<br /><br />CruiseShip(ImmutableModel):<br /> name = models.CharField(max_length=50)<br /><br /> class ImmutableMeta:<br /> # After ya name a ship, you can't change it matey<br /> immutable = ['name']<br /><br /> def __unicode__(self):<br /> return u'%s' % self.name<br /><br />Now you can try with all your might, but the field won't change (within reason, sure this is Python we can do almost anything if we try hard enough)<br /><br />>>> queen_anne = CruiseShip.objects.create(name='Queen Anne')<br />< CruiseShip 'Queen Anne' ><br />>>> queen_anne.name = 'King George'<br />>>> queen_anne.name<br />'Queen Anne'<br /><br />You can make it complain<br /><br />Change the meta section to include quiet = False and it will raise a ValueError if an attempt is made to change this value<br /><br />class ImmutableMeta:<br /> # After ya name a ship, you can't change it matey<br /> immutable = ['name']<br /> quiet = False<br /><br />The error is raised as soon as you try and set the field, not when save() is called.<br /><br />>>> queen_anne = CruiseShip.objects.create(name='Queen Anne')<br />< CruiseShip 'Queen Anne'><br />>>> queen_anne.name = 'King George'<br />ValueError: name is immutable and cannot be changed<br /><br />Reference<br /><br />ImmutableMeta<br /><br /> Specify options that control how immutable fields are handled when subclassing the ImmutableModel class<br /><br /> immutable<br /><br /> Tell ImmutableModel which fields should not be allowed to change. This value must be a tuple or a list and contain the names of the fields as strings.:<br /><br /> class ImmutableMeta:<br /> immutable = ['my_special_id']<br /><br /> Specify multiple fields:<br /><br /> class ImmutableMeta:<br /> immutable = ['my_special_id', 'name', 'foreign_key']<br /><br /> quiet<br /><br /> If an attempt is made to change an immutable field, should we quietly prevent it.<br /><br /> Set this value to False to raise a ValueError when an immutable field is changed.:<br /><br /> class ImmutableMeta:<br /> immutable = ['my_special_id']<br /> quiet = False<br /><br />#md5=0701e924aa82265790cc72d1bbc4762b

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: 039name039 Anne Can039t Change Class Django Django Immutablefield False Field Fields Immutable Immutablefield Immutablemeta Immutablemodel Install Matey Quiet Special Valueerror
Users rating: 0/10

License: Freeware Size: 10.24 KB
USER REVIEWS
More Reviews or Write Review


DJANGO-IMMUTABLEFIELD RELATED
Utilities  -  django-honeypot 0.1.2
Django honeypot field utilities django-honeypot is a Django plugin that provides utilities for preventing automated form spam. Provides template tags, view decorators, and middleware to add and verify honeypot fields to...
10.24 KB  
Modules  -  javascript Timer 6.x-1.2
The javascript Timer module provides a timer api that can hook html elements to javascript widget objects. This is useful if you want a moving timer/clock or a widget that updates every second. It comes with widgets for a countdown timer, a...
20.48 KB  
Network & Internet  -  django-expire 1.0.1
django-expire is a Django application which provides authentication-based session expiration. To install this application into your project, first add it to your "INSTALLED_APPS" setting (and run "manage.py syncdb"):: ...
10.24 KB  
Network & Internet  -  django-factory_boy 0.1.6
When testing Django app, a common case is to create some data, then test app behavior around that test data. This is usually [done with fixtures][fixtures], but [this includes some pain][fixturepain]. [rbarrois/factory_boy][factory_boy]...
10.24 KB  
Network & Internet  -  django-composite-field 0.1
django-composite-field is a CompositeField implementation for the Django framework. #md5=f88a91adbbbde5d4de730e0086f40240
10.24 KB  
Site Security Tools  -  django-frontendadmin 0.4
django-frontendadmin is a set of template tags to allow an easy and unobtrusive way to edit model-data in the frontend of your page. Example project This package provides an easy example project, a weblog with comments. Here...
10.24 KB  
Network & Internet  -  django-publicmanager for Linux 0.9.2
django-publicmanager is a Django app that provides a custom queryset class and managers that handle the public availability of database objects. The classes provide a public method that filters by boolean is_public and date based pub_date...
10.24 KB  
Network & Internet  -  django-payfast 0.2.2
A pluggable Django application for integrating payfast.co.za payment system. Install $ pip install django-payfast or $ easy_install django-payfast or $ hg clone...
10.24 KB  
Programming  -  django-netcash 0.4.0
A pluggable Django application for integrating netcash.co.za payment system. Install $ pip install django-netcash or $ easy_install django-netcash or $ hg clone...
10.24 KB  
Network & Internet  -  django-page-cms 1.4.5
This Django CMS enable you to create and administrate hierarchical pages in a simple and powerful way. Django page CMS is based around a placeholders concept. A placeholder is special template tag that you use in your page templates....
1.83 MB  
NEW DOWNLOADS IN LINUX SOFTWARE, NETWORK & INTERNET
Linux Software  -  EasyEDA PCB Designer for Linux 2.0.0
EasyEDA, a great web based EDA(Electronics Design Automation) tool, online PCB tool, online PCB software for electronics engineers, educators, students, makers and enthusiasts. Theres no need to install any software. Just open EasyEDA in any...
34.4 MB  
Linux Software  -  wpCache® WordPress HTTP Cache 1.9
wpCache® is a high-performance, distributed object, caching system application, generic in nature, but intended for use in speeding up dynamic web applications, by decreasing database load time. wpCache® decreases dramatically the page...
3.51 MB  
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Network & Internet  -  Free WiFi Hotspot 3.3.1
Free WiFi Hotspot is a super easy solution to turn your laptop or notebook into a portable Wi-Fi hotspot, wirelessly sharing your internet connections like DSL, Cable, Bluetooth, Mobile Broadband Card, Dial-Up, etc. through the built-in wireless...
1.04 MB  
Network & Internet  -  Easy Uploads 1.8
Easy uploads is a file storage media streaming application designed by Filestreamers that allows you to upload, store, and stream your files from their virtually unlimited file storage server. Easy Uploads can backup,share, and stream your files...
615.97 KB  
Network & Internet  -  PacketFence ZEN 3.1.0
PacketFence is a fully supported, trusted, Free and Open Source network access control (NAC) system. Boosting an impressive feature set including a captive-portal for registration and remediation, centralized wired and wireless management, 802.1X...
1024 MB  
Network & Internet  -  django-dbstorage 1.3
A Django file storage backend for files in the database.
10.24 KB  
Network & Internet  -  SQL Inject Me 0.4.5
SQL Inject Me is a Firefox extension used to test for SQL Injection vulnerabilities. The tool works by submitting your HTML forms and substituting the form value with strings that are representative of an SQL Injection attack.
133.12 KB