gnowledge/gstudio — pull request #285 by AvadootNachankar (2014-03-18 19:20:11+00:00)
Title: Implemented - get_possible_attributes() function and history creation/updation for GTriple documents

**Functionalities implemented**

1. History (version-files) gets created for GTriple (GRelation/GAttribute) documents
- Built-in save() function overridden to provide Revision Control System (RCS) implementation that handles version-files creation/updation
- By default, sets name for GAttribute/GRelation documents (provided in save() function)

2. Implementation of get_possible_attributes()
- Implemented in two parts:
1) get_possible_attributes() defined in Node class
- Returns possible attributes (user-defined using AttributeType) for a node
- Accepts parameter as either ObjectId of GSystemType or list of them for the given node (generally member_of field). [NOTE: type_of consideration is not done in this commit, very soon will be implemented!]
- Returns a dictionary where key is name of the attribute and value is list that contains two elements - first data-type of attribute and the other actual value of attribute (by default it's None)

2) append_attribute() defined in AttributeType class
- It's a recursive function that appends values to dictionary variable (possible_attributes); those values are nothing but key-value pair that is specified in above point.
- Accepts parameters: attribute-type-id, possible-attributes-dict, attribute-value (only while editing GSystem, otherwise None), and inner-attribute-dict (that is passed only when complex-data-type for given attrbute-type-id is found and to be specific when data-type is dict)

**Files added/modified**

1) models.py file modified

- GTriple class updated:
- save() function added along with default values for name field of both GAttribute and GRelation document

- GAttribute class updated:
- attribute_type data-type changed from ObjectId to DBRef of AttributeType class
- Added: use_autorefs = True # To support Embedding of Documents

- Node class updated:
- get_possible_attribute() function added

- AttributeType class updated:
- complex_data_type field added (data-type: [unicode])
- append_attribute() static-function added

2) add_fields_to_existing_documents.py file modified

- To add complex_data_type field to existing AttributeType documents

- Done necessary changes to few commands as well in order to avoid reflecting changes in GRelation/GAttribute class documents'.

3) update_attribute_type.py file added

- To change the value from ObjectId to DBref of AttributeType for attribute_type field of existing GAttribute documents

- Also creates history (version-file) for respective GAttribute documents

NOTE - Please fire the following commands:
```
python manage.py add_fields_to_existing_documents
python manage.py update_attribute_type
```