GoogleCloudPlatform/gcloud-python — pull request #445 by dhermes (2014-12-19 05:14:03+00:00)
Title: DISCUSSION PR: Re-writing Entity to subclass object instead of dict.

This fixes #396, but I am happy to close it if there are issues with it. (Hence the **DISCUSSION** in the description.)

It is a first-step towards the discussion in #336 with @elibixby and @proppy.

The `Entity` class doesn't attempt to be a dictionary, rather it provides `__getitem__` (and `set` and `del`) semantics and `update_properties` and `clear_properties` methods for updating the properties and leaving the rest of the entity alone.

The long term goal is to provide a way to do something like:
```python
>>> e1 = Entity('SomeKind', 1, prop1=u'foo', prop2=u'bar')
>>> e1

>>> e2 = Entity('SomeKind', 1, {'prop1': u'foo', 'prop2': u'bar'})
>>> e2

>>> e1 == e2
True
>>> e_partial = Entity('ParentKind', 1, 'ChildKind', prop=True)
>>> e_partial

```
and I think to get there this is necessary to separate the property data (as `_data`) from the other metadata.

I am still trying to figure out a way to squeeze in "special" keyword arguments like

- `key`
- `dataset` (#444 may make this unnecessary if we take it a bit further)
- `exclude_from_indexes` (as a power-user feature, it may not be necessary to put this in the constructor)

but that is outside the scope of this PR / discussion.