Commits

Roman Tolkachyov committed 92f1144

Real division of doc and value in ViewResoult

  • Participants
  • Parent commits 8369444

Comments (0)

Files changed (2)

File easycouch/couch.py

 	def view(self, design, view_name, **kwarg):
 		view_name = "_design/%s/_view/%s" % (design, view_name)
 		return self.db.view(view_name, wrapper = EasyRow(self), **kwarg)
+	
+	def raw_view(self, view_path, **kwarg):
+		return self.db.view(view_path, wrapper = EasyRow(self), **kwarg)
 
 	def get_viewdef(self, design, name):
 		return self.view_defs[design][name]
 		reduce_func = None
 		map_func = None
 		if fname[-7:] == "_reduce":
-			lines[0] = "def fun(key, values, rereduce):\n"
+			lines[0] = "def fun(keys, values, rereduce):\n"
 			reduce_func = "".join(lines)
 			fname = fname[:-7]
 		elif fname[-4:] == "_map":

File easycouch/view.py

 		self.couch = couch
 	
 	def __call__(self, row):
-		doctype = row['value']['doctype']
-		mapper = self.couch.get_mapper(doctype)
-		doc = mapper.to_obj(row['value'])
+		doc_data = row['value']
+		if row.has_key('doc'):
+			doc_data = row['doc']
+		if isinstance(doc_data, dict) and doc_data.has_key('doctype'):
+			doctype = doc_data['doctype']
+			mapper = self.couch.get_mapper(doctype)
+			doc = mapper.to_obj(doc_data)
+		else:
+			doc = row['value']
+		if row.has_key('doc') and row['value'] != None:
+			return row['key'], doc, row['value']
 		return row['key'], doc
 
 class ViewDefenition(object):