#NEWLINE# def create_new_room( self , room ) : #NEWLINE# #INDENT# self . db . request ( 'POST' , ( '/%s_rooms/' % self . couchdb_prefix ) , body = room ) #NEWLINE# self . db . request ( 'PUT' , ( '/%s_room_%s_messages' % ( self . couchdb_prefix , room [ 'num_id' ] ) ) ) #NEWLINE# self . db . request ( 'PUT' , ( '/%s_room_%s_messages/_design/messages/' % ( self . couchdb_prefix , room [ 'num_id' ] ) ) , body = { #NEWLINE# #INDENT# '_id' : '_design/by_date' , #NEWLINE# 'language' : 'javascript' , #NEWLINE# 'views' : { #NEWLINE# #INDENT# 'by_date' : { #NEWLINE# #INDENT# 'map' : 'function (doc) { emit(doc["date"], doc); }' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . db . request ( 'PUT' , ( '/%s_room_%s_messages/_design/highlight/' % ( room . couchdb_prefix , room [ 'num_id' ] ) ) , body = { #NEWLINE# #INDENT# '_id' : '_design/user_by_message' , #NEWLINE# 'language' : 'javascript' , #NEWLINE# 'views' : { #NEWLINE# #INDENT# 'user_by_message' : { #NEWLINE# #INDENT# 'map' : 'function (doc) { emit(doc["num_id"], doc["user"]); }' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# return room [ 'num_id' ]