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.147.358 Times

EAV-Django 1.4.2

Company: Andrey Mikhaylenko
Date Added: July 06, 2013  |  Visits: 443

EAV-Django

Report Broken Link
Printer Friendly Version


Product Homepage
Download (40 downloads)



EAV-Django is a reusable Django app that provides an implementation of the Entity-Attribute-Value data model.<br /><br /> Entity-Attribute-Value model (EAV), also known as object-attribute-value model and open schema which is used in circumstances where the number of attributes (properties, parameters) that can be used to describe a thing (an "entity" or "object") is potentially very vast, but the number that will actually apply to a given entity is relatively modest.<br /><br />EAV-Django works fine with traditional RDBMS (tested on SQLite and MySQL).<br />Priorities<br /><br />The application grew from an online shop project, so it is pretty practical and not just an academic exercise. The main priorities were:<br /><br /> 1. flexibility of data,<br /> 2. efficiency of queries, and<br /> 3. maximum maintainability without editing the code.<br /><br />Of course this implies trade-offs, and the goal was to find the least harmful combination for the general case.<br />Features<br /><br />All provided models are abstract, i.e. EAV-Django does not store any information in its own tables. Instead, it provides a basis for your own models which will have support for EAV out of the box.<br /><br />The EAV API includes:<br /><br /> * Create/update/access: model instances provide standart API for both "real" fields and EAV attributes. The abstraction, however, does not stand in your way and provides means to deal with the underlying stuff.<br /> * Query: BaseEntityManager includes uniform approach in filter() and exclude() to query "real" and EAV attributes.<br /> * Customizable schemata for attributes.<br /> * Admin: all dynamic attributes can be represented and modified in the Django admin with no or little effort (using eav.admin.BaseEntityAdmin). Schemata can be edited separately, as ordinary Django model objects.<br /> * Facets: facet search is an important feature of online shops, catalogues, etc. Basically you will need a form representing a certain subset of model attributes with appropriate widgets and choices so that the user can choose desirable values of some properties, submit the form and get a list of matching items. In general case django-filter would do, but it won't work with EAV, so EAV-Django provides a complete set of tools for that.<br /><br />Examples<br /><br />Let's define an EAV-friendly model, create an EAV attribute and see how it behaves. By "EAV attributes" I mean those stored in the database as separate objects but accessed and searched in such a way as if they were columns in the entity's table:<br /><br />from django.db import models<br />from eav.models import BaseEntity, BaseSchema, BaseAttribute<br /><br />class Fruit(BaseEntity):<br /> title = models.CharField(max_length=50)<br /><br />class Schema(BaseSchema):<br /> pass<br /><br />class Attr(BaseAttribute):<br /> schema = models.ForeignKey(Schema, related_name='attrs')<br /><br /># in Python shell:<br /><br /># define attribute named "colour"<br />>>> colour = Schema.objects.create(<br />... title = 'Colour',<br />... name = 'colour', # omit to populate/slugify from title<br />... datatype = Schema.TYPE_TEXT<br />... )<br /><br /># create an entity<br />>>> e = Fruit.objects.create(title='Apple', colour='green')<br /><br /># define "real" and EAV attributes the same way<br />>>> e.title<br />'Apple'<br />>>> e.colour<br />'green'<br /><br />>>> e.save() # deals with EAV attributes automatically<br /><br /># list EAV attributes as Attr instances<br />>>> e.attrs.all()<br />[]<br /><br /># search by an EAV attribute as if it was an ordinary field<br />>>> Fruit.objects.filter(colour='yellow')<br />[]<br /><br /># all compound lookups are supported<br />>>> Fruit.objects.filter(colour__contains='yell')<br />[]<br /><br />Note that we can access, modify and query colour as if it was a true Entity field, but at the same time its name, type and even existance are completely defined by a Schema instance. A Schema object can be understood as a class, and related Attr objects are its instances. In other words, Schema objects are like CharField, IntegerField and such, only defined on data level, not hard-coded in Python. And they can be "instantiated" for any Entity (unless you put custom constraints which are outside of EAV-Django's area of responsibility).<br /><br />The names of attributes are defined in related schemata. This can lead to fears that once a name is changed, the code is going to break. Actually this is not the case as names are only directly used for manual lookups. In all other cases the lookups are constructed without hard-coded names, and the EAV objects are interlinked by primary keys, not by names. The names are present if forms, but the forms are generated depending on current state of metadata, so you can safely rename the schemata. What you can break from the admin interface is the types. If you change the data type of a schema, all its attributes will remain the same but will use another column to store their values. When you restore the data type, previously stored values are visible again.<br /><br />See tests for more examples.<br />Data types<br /><br />Metadata-driven structure extends flexibility but implies some trade-offs. One of them is increased number of JOINs (and, therefore, slower queries). Another is fewer data types. Theoretically, we can support all data types available for a storage, but in practice it would mean creating many columns per attribute with just a few being used -- exactly what we were trying to avoid by using EAV. This is why EAV-Django only supports some basic types (though you can extend this list if needed):<br /><br /> * Schema.TYPE_TEXT, a TextField;<br /> * Schema.TYPE_FLOAT, a FloatField;<br /> * Schema.TYPE_DATE, a DateField;<br /> * Schema.TYPE_BOOL, a NullBooleanField;<br /> * Schema.TYPE_MANY for multiple choices (i.e. lists of values).<br /><br />All EAV attributes are stored as records in a table with unique combinations of references to entities and schemata. (Entity is referenced through the contenttypes framework, schema is referenced via foreign key.) In other words, there can be only one attribute with given entity and schema. The schema is a definition of attribute. The schema defines name, title, data type and a number of other properties which apply to any attribute of this schema. When we access or search EAV attributes, the EAV machinery always uses schemata as attributes metadata. Why? Because the attribute's name is stored in related schema, and the value is stored in a column of the attributes table. We don't know which column it is until we look at metadata.<br /><br />In the example provided above we've only played with a text attribute. All other types behave exactly the same except for TYPE_MANY. The many-to-many is a special case as it involves an extra model for choices. EAV-Django provides an abstract model but requires you to define a concrete model (e.g. Choice), and point to it from the attribute model (i.e. put foreign key named "choice"). The Choice model will also have to point at Schema. Check the tests for an example.<br /><br />#md5=d0a4d63b44e3be7278ed66c8a2906b72

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: Attribute Attributes Define Defined Eavdjango Lookups Model Names Number Objects Related Schema Schemata Stored Title Types
Users rating: 0/10

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


EAV-DJANGO RELATED
Utilities  -  ORE (Ontology Rule Editor) 3.3
ORE (Ontology Rule Editor) is a platform-independent application to manage the use of inference rules defined on a model represented by an ontology. ORE offers a easy, well-guided and intiutive GUI to define and test these inference rules.
28.43 MB  
HTML Utilities  -  django-secretballot 0.2.3
django-secretballot Django voting application that allows voting without a logged in user. Provides abstract base model for types that the user wishes to allow voting on as well as related utilities including generic views to...
10.24 KB  
Modules  -  WYSIWYG Filter 7.x-1.6-rc2
The WYSIWYG Filter module provides an input filter that allows site administrators configure which HTML elements, attributes and style properties are allowed. It also may add rel="nofollow" to posted links based on filter options. It can do so...
20.48 KB  
Network & Internet  -  django-autofixture 0.2.2
django-autofixture is a Django app that aims to provide a simple way of loading masses of randomly generated test data into your development database. You can use a management command to load test data through command line. Its named...
20.48 KB  
Programming  -  Dacomasy 1.5.550
A database content management system for website content that uses XML files to define the management interface for tables in a database systems schemata. Designed to run on PHP 5.
627.41 KB  
Miscellaneous  -  Attributes WithProtection without pain 1.0
This script enables proper protection of attributes that are mangled with Pythons privacy indicator: the single underscore _. WithProtection can be used as a base class for all classes that want true protection of user defined attributes mangled...
 
Network & Internet  -  django-adminfiles 0.5.1
For each model you'd like to use the django-adminfiles picker with, inherit that model's admin options class from adminfiles.admin.FilePickerAdmin instead of the usual django.contrib.admin.ModelAdmin, and set the adminfiles_fields attribute to a...
61.44 KB  
Programming  -  MooseX::Getopt 0.20
MooseX::Getopt is a role which provides an alternate constructor for creating objects using parameters passed in from the command line. This module attempts to DWIM as much as possible with the command line params by introspecting your...
30.72 KB  
Networking Tools  -  LDAP User Management System 0.4
LDAP User Management System (LUMS) provides a set of basic LDAP API functions for PHP and a strong configuration language. The project can then be used to create Web services or can be used in any PHP script. The language allows the...
122.88 KB  
Development Tools  -  VOLUME ENCLOSED BY A TRIANGULATED SURFACE 1.0
Gets the Volume enclosed by the surface defined by p,t,tnorm. The surface must be closed and manifold, there is no check for this.The algorithm compute the volume of 3 tetraedrons for each triangle. The normals orientation define the sign of...
614.4 KB  
NEW DOWNLOADS IN PROGRAMMING, SPECIALIZED TOOLS
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Specialized Tools  -  SIMRI 2.0
SIMRI: a versatile and interactive Magnetic Resonance Imaging (MRI) simulator.Such a simulator is a command line software written in C that reproduces the physical phenomenas encountered during an MRI acquisition to produce a realistic MRI image.
6.39 MB  
Specialized Tools  -  Java Web Start Plugin for Eclipse 1.2.1
Java Web Start Plugin for Eclipse (WS4E) helps you to deploy your Java application through Java Web Start. With WS4E, Developers with very little knowledge can deploy their applications with just a few clicks. For advanced developers, WS4E is...
204.8 KB  
Specialized Tools  -  TUGGO for Linux 1.0.0
TUGGO is a website management system allowing anyone to easily create their own website without any code knowledge.
942.08 KB  
Specialized Tools  -  Parcels for Linux 1.0
Web documents that look similar often use different HTML tags to achieve their layout effect. These tags often make it difficult for a machine to find text or images of interest. PARCELS is a backend system [Java] designed to...
1.14 MB  
Specialized Tools  -  django-test-extensions 0.10
PyUnit provides a basic set of assertions which can get you started with unit testing python, but it???*a*?s always useful to have more. Django also has a few specific requirements and common patterns when it comes to testing. This set of classes...
20.48 KB