jur9526 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Strip dict interface from mapping.Mapping #174

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
`mapping.Mapping` class is emulating dict interface with `__*item__` methods 
proxying it to underlying _data attribute. But this is not helpful and in some 
cases produces weird behavior.

For example Django's template language resolves variables like this `{{ foo.bar 
}}` first of all like foo['bar'] and than `foo.bar`. When `foo` is 
mapping.Mapping/mapping.Document instance it resolves as raw value from `_data` 
and not high-level wrapped attribute as expected.

I think that `mapping.Mapping` doesn't have to be dict-like object. It has 
`unwrap()` method that gets access to raw data if its needed. And there is 
`client.Doсument` with such interface.

Patch with tests is attached.

Original issue reported on code.google.com by daevaorn on 14 Mar 2011 at 12:33

Attachments:

GoogleCodeExporter commented 9 years ago
I strongly disagree. What you mean to say is it's not helpful _to you_. There 
are many of us who strongly depend upon the interchangeability of dicts and 
Mapping objects when porting old code to use the Mapping interface.

Original comment by bgam...@gmail.com on 9 May 2011 at 2:43

GoogleCodeExporter commented 9 years ago
Yes, it will break all my code too(: 
What about cyrillic and other non-ascii document field names? This patch breaks 
access to fields by their "true" names, not object ones. No more iteration over 
available fields forces to create own filter over all Mapping attributes for 
searching Field instances.

Original comment by kxepal on 9 May 2011 at 3:03

GoogleCodeExporter commented 9 years ago
It seems clear that this would be an unacceptable change.

Original comment by djc.ochtman on 6 Jul 2014 at 12:13