From kxepal on May 13, 2010 04:41:32
What steps will reproduce the problem? 1. Create about 30 types of document schemes
2. Add about 10-15 views for each document schema
3. Try to sync views with couchdb via couchdb.design.ViewDefinition.sync_many What is the expected output? What do you see instead? I expected way to sync all views by document class. Something like:
couchdb.design.ViewDefinition.sync_many(db,[Couteragents, Orders, Cars, ...])
Instead I must describe each view for each document:
couchdb.design.ViewDefinition.sync_many(db,
[Counteragents.by_name, Counteragents.list, Counteragents.by_discount,
Counteragents.by_car, Counteragents.address_info, ..., Cars.by_model,
Cars.list, Cars.by_year, Cars.by_owner, ...]
) What version of the product are you using? On what operating system? Linux 2.6.32.11-calculate, couchdb 0.11.0, couchdb-python 0.7.1@33d71d3080ba Please provide any additional information below. I see two problems there:
- When I'm adding new view or removing old one I must also check up for
sync_many call and add/remove view to/from second argument.
- I may suddenly forget for some view and I will have an error. With more
than 30 views it's an easy.
I don't see this method bad, but there must be much more easy solution to
sync up all Document views.
For now, we're using such solution:
from couchdb.mapping import Document,ViewField
class DocumentWhichKnowsOwnViews(Document):
@classmethod
def list_views(cls):
return filter(lambda value: isinstance(value, ViewField),
cls.dict.values())
than all other documents are derived from DocumentWhichKnowsOwnViews and then:
couchdb.design.ViewDefinition.sync_many(db,[
Counteragents.list_views(),
Orders.list_views(),
...#etc
])
Not great solution, but it's solving this problem. And it will be great to
have such functionality by default.
Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=127
From kxepal on May 13, 2010 04:41:32
What steps will reproduce the problem? 1. Create about 30 types of document schemes
2. Add about 10-15 views for each document schema
3. Try to sync views with couchdb via couchdb.design.ViewDefinition.sync_many What is the expected output? What do you see instead? I expected way to sync all views by document class. Something like:
couchdb.design.ViewDefinition.sync_many(db,[Couteragents, Orders, Cars, ...])
Instead I must describe each view for each document:
couchdb.design.ViewDefinition.sync_many(db,
[Counteragents.by_name, Counteragents.list, Counteragents.by_discount,
Counteragents.by_car, Counteragents.address_info, ..., Cars.by_model,
Cars.list, Cars.by_year, Cars.by_owner, ...]
) What version of the product are you using? On what operating system? Linux 2.6.32.11-calculate, couchdb 0.11.0, couchdb-python 0.7.1@33d71d3080ba Please provide any additional information below. I see two problems there:
sync_many call and add/remove view to/from second argument.
than 30 views it's an easy.
I don't see this method bad, but there must be much more easy solution to
sync up all Document views.
For now, we're using such solution:
from couchdb.mapping import Document,ViewField
class DocumentWhichKnowsOwnViews(Document):
@classmethod
def list_views(cls):
return filter(lambda value: isinstance(value, ViewField),
cls.dict.values())
than all other documents are derived from DocumentWhichKnowsOwnViews and then:
couchdb.design.ViewDefinition.sync_many(db,[
Counteragents.list_views(),
Orders.list_views(),
...#etc
])
Not great solution, but it's solving this problem. And it will be great to
have such functionality by default.
Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=127