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

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

Serving Software Downloads in 976 Categories, Downloaded 29.548.881 Times

EAV-Django 1.4.2

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

EAV-Django

Report Broken Link
Printer Friendly Version


Product Homepage
Download (17 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
Games  -  ABCville What Is That - Learn Names of Objects Found in School 1.2
ABCville What Is That is a fun and educational way for kids and preschoolers to learn names of objects found in and around school from eraser to school bus. The pictures of objects will be shown so kids can easily remember them. Other Top...
2.7 MB  
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  
Games  -  ABCville - Learning Game for Kids 2.5
ABCville is a fun educational game for kids. Kids can learn to remember names of objects, the questions will show up randomly from A to Z. For example, pick an object that starts with the letter A, the answer is Apple, but the next time he...
9.1 MB  
Education  -  My First Sounds Baby picture and sound dictionary 1.0.1
Is your child ready to go to a preschool or kindergarten? Has your child reached the age where its time to let them identify and learn the names of objects by their sounds? My First Sounds Baby Sound Dictionary is a perfect way to teach them! This...
50.2 MB  
Productivity  -  ATM_Pin_Generator 1.0.0.1
This app will generate a PIN number which having 4 number long and also include three different level which will define a strongness of your PIN number. Requirements: Windows Phone 8.1, Windows Phone 8
1024 KB  
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  
NEW DOWNLOADS IN PROGRAMMING, SPECIALIZED TOOLS
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
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  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Specialized Tools  -  wolfSSL 3.10.2
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
2.73 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  -  Jigs Persistent Objects (JPO) 0.2
Welcome to the Java Persistent Objects (JPO) project site. This site is dedicated to Java developers attempting to find a simple solution to object persistence in a relational database (or object-relational mapping). Get the latest...
1.4 MB