fork download
  1. diff --git a/pyon/datastore/couchdb/couchdb_config.py b/pyon/datastore/couchdb/couchdb_config.py
  2. index 92be764..49b7dd6 100644
  3. --- a/pyon/datastore/couchdb/couchdb_config.py
  4. +++ b/pyon/datastore/couchdb/couchdb_config.py
  5. @@ -2,7 +2,6 @@
  6.  
  7. __author__ = 'Thomas R. Lennan, Michael Meisinger'
  8. __license__ = 'Apache 2.0'
  9. -
  10. COUCHDB_CONFIGS = {
  11. 'object_store':{
  12. 'views': ['object','association']
  13. @@ -13,6 +12,9 @@ COUCHDB_CONFIGS = {
  14. 'directory_store':{
  15. 'views': ['directory']
  16. },
  17. + 'dm_datastore':{
  18. + 'views': ['posts']
  19. + },
  20. 'all':{
  21. 'views': ['object', 'resource', 'association', 'directory']
  22. }
  23. @@ -148,10 +150,25 @@ function(doc) {
  24. }""",
  25. },
  26. },
  27. + 'posts':{
  28. + 'index':{
  29. + 'map':"""
  30. +function(doc) {
  31. + if(doc.type=="post") {
  32. + emit([doc._id,0],doc)
  33. + } else if (doc.type == "comment") {
  34. + emit([doc.post, 1], doc)
  35. + }
  36. +}"""
  37. + }
  38. + }
  39. }
  40.  
  41. def get_couchdb_views(config):
  42. - store_config = COUCHDB_CONFIGS[config]
  43. + if config in COUCHDB_CONFIGS:
  44. + store_config = COUCHDB_CONFIGS[config]
  45. + else:
  46. + store_config = COUCHDB_CONFIGS['all']
  47. views = store_config['views']
  48. res_views = {}
  49. for view in views:
  50. diff --git a/pyon/datastore/couchdb/couchdb_datastore.py b/pyon/datastore/couchdb/couchdb_datastore.py
  51. index 648c46c..44d6ff0 100644
  52. --- a/pyon/datastore/couchdb/couchdb_datastore.py
  53. +++ b/pyon/datastore/couchdb/couchdb_datastore.py
  54. @@ -574,7 +574,9 @@ class CouchDB_DataStore(DataStore):
  55. def _define_views(self, datastore_name=""):
  56. if not datastore_name:
  57. datastore_name = self.datastore_name
  58. - for design, viewdef in self.couchdb_views.iteritems():
  59. +
  60. + views = get_couchdb_views(datastore_name)
  61. + for design, viewdef in views.iteritems():
  62. self._define_view(design, viewdef, datastore_name=datastore_name)
  63.  
  64. def _define_view(self, design, viewdef, datastore_name=""):
  65. @@ -591,8 +593,8 @@ class CouchDB_DataStore(DataStore):
  66. if not datastore_name:
  67. datastore_name = self.datastore_name
  68. db = self.server[datastore_name]
  69. -
  70. - for design, viewdef in self.couchdb_views.iteritems():
  71. + views = get_couchdb_views(datastore_name)
  72. + for design, viewdef in views.iteritems():
  73. for viewname in viewdef:
  74. try:
  75. rows = db.view("_design/%s/_view/%s" % (design, viewname))
  76.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty