I'd like to know why rev property of the couchdb.mapping.Document class is read-only attribute. Even id attribute can be set, and I need in my project to create a new Document with rev, which I obtain from CouchDB view. I know that rev is generated in CouchDB, but that's a pity that creators didn't predict such an exception. Moreover, in my humble opinion there should be a get method for the Document class that could obtain many ids as a paramter.
Mostly because this is system internal field, that not supposed to be
touched by clients. Accidental his changing may create unexpectable
conflict situations.
To create mapping.Document instance based on view result you have two ways:
1. Use ViewField to gain result data and Document class as result row wrapper.
2. Wrap view result manually by Document class on instance
initialization. Document revision would be automatically set by `_rev`
key parameter.
On Tue, Jul 17, 2012 at 5:51 PM, adam.cajf <adam.c...@gmail.com> wrote:
> I'd like to know why rev property of the couchdb.mapping.Document class is
> read-only attribute. Even id attribute can be set, and I need in my project
> to create a new Document with rev, which I obtain from CouchDB view. I know
> that rev is generated in CouchDB, but that's a pity that creators didn't
> predict such an exception. Moreover, in my humble opinion there should be a
> get method for the Document class that could obtain many ids as a paramter.
> --
> You received this message because you are subscribed to the Google Groups
> "CouchDB-Python" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/couchdb-python/-/t0XgDS2BQBkJ.
> To post to this group, send email to couchdb-python@googlegroups.com.
> To unsubscribe from this group, send email to
> couchdb-python+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/couchdb-python?hl=en.
I have another case... There is REST API. Let's assume that user send a document to be updated with the rev parameter. Then if it was possible to set rev in Document and there was a conflict I could receive from couchdb the exception:
On Tuesday, July 17, 2012 4:48:59 PM UTC+2, Kxepal wrote:
> Hi Adam!
> Mostly because this is system internal field, that not supposed to be > touched by clients. Accidental his changing may create unexpectable > conflict situations. > To create mapping.Document instance based on view result you have two > ways: > 1. Use ViewField to gain result data and Document class as result row > wrapper. > 2. Wrap view result manually by Document class on instance > initialization. Document revision would be automatically set by `_rev` > key parameter.
> -- > ,,,^..^,,,
> On Tue, Jul 17, 2012 at 5:51 PM, adam.cajf <adam.c...@gmail.com> wrote: > > I'd like to know why rev property of the couchdb.mapping.Document class > is > > read-only attribute. Even id attribute can be set, and I need in my > project > > to create a new Document with rev, which I obtain from CouchDB view. I > know > > that rev is generated in CouchDB, but that's a pity that creators didn't > > predict such an exception. Moreover, in my humble opinion there should > be a > > get method for the Document class that could obtain many ids as a > paramter.
> > -- > > You received this message because you are subscribed to the Google > Groups > > "CouchDB-Python" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/couchdb-python/-/t0XgDS2BQBkJ. > > To post to this group, send email to couchdb-python@googlegroups.com. > > To unsubscribe from this group, send email to > > couchdb-python+unsubscribe@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/couchdb-python?hl=en.
On Wed, Jul 18, 2012 at 8:09 PM, adam.cajf <adam.c...@gmail.com> wrote:
> I have another case...
> There is REST API. Let's assume that user send a document to be updated with
> the rev parameter. Then if it was possible to set rev in Document and there
> was a conflict I could receive from couchdb the exception
The base logic is that on conflict situation you need to fetch latest
version and update his data from outdated one if you'd like to force
override data. However, you're still able to set revision by accessing
to Mapping internals:
doc._data['_rev'] = newrev
This is not very correct, because for most conflicts better to analyze
both documents and decide how to merge their data, but if you're sure
and really want just to override new document version by old one you'd
need to explicitly make a hack to note that behavior for others -
sounds quite fair.
On Wed, Jul 18, 2012 at 8:09 PM, adam.cajf <adam.c...@gmail.com> wrote:
> Hi Kxepal,
> Thank you for your answer.
> I have another case...
> There is REST API. Let's assume that user send a document to be updated with
> the rev parameter. Then if it was possible to set rev in Document and there
> was a conflict I could receive from couchdb the exception:
> and I would like to have access to this exception and not checking manually
> if rev in the document in couchdb is equal to the rev given by user.
> On Tuesday, July 17, 2012 4:48:59 PM UTC+2, Kxepal wrote:
>> Hi Adam!
>> Mostly because this is system internal field, that not supposed to be
>> touched by clients. Accidental his changing may create unexpectable
>> conflict situations.
>> To create mapping.Document instance based on view result you have two
>> ways:
>> 1. Use ViewField to gain result data and Document class as result row
>> wrapper.
>> 2. Wrap view result manually by Document class on instance
>> initialization. Document revision would be automatically set by `_rev`
>> key parameter.
>> --
>> ,,,^..^,,,
>> On Tue, Jul 17, 2012 at 5:51 PM, adam.cajf <adam.c...@gmail.com> wrote:
>> > I'd like to know why rev property of the couchdb.mapping.Document class
>> > is
>> > read-only attribute. Even id attribute can be set, and I need in my
>> > project
>> > to create a new Document with rev, which I obtain from CouchDB view. I
>> > know
>> > that rev is generated in CouchDB, but that's a pity that creators didn't
>> > predict such an exception. Moreover, in my humble opinion there should
>> > be a
>> > get method for the Document class that could obtain many ids as a
>> > paramter.
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "CouchDB-Python" group.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msg/couchdb-python/-/t0XgDS2BQBkJ.
>> > To post to this group, send email to couchdb-python@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > couchdb-python+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/couchdb-python?hl=en.
> To post to this group, send email to couchdb-python@googlegroups.com.
> To unsubscribe from this group, send email to
> couchdb-python+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/couchdb-python?hl=en.