<s> """<STR_LIT>""" <EOL> from models . post import Post <EOL> from models . proposal import Proposal <EOL> from models . vote import Vote <EOL> from modules . util import omit <EOL> import rethinkdb as r <EOL> def instance ( data ) : <EOL> """<STR_LIT>""" <EOL> if data . get ( '<STR_LIT>' ) == '<STR_LIT>' : <EOL> return Proposal ( data ) <EOL> if data . get ( '<STR_LIT>' ) == '<STR_LIT>' : <EOL> return Vote ( data ) <EOL> return Post ( data ) <EOL> def get_post_facade ( db_conn , post_id ) : <EOL> """<STR_LIT>""" <EOL> data = Post . table . get ( post_id ) . run ( db_conn ) <EOL> return instance ( data ) <EOL> def get_posts_facade ( db_conn , limit = <NUM_LIT:10> , skip = <NUM_LIT:0> , ** params ) : <EOL> """<STR_LIT>""" <EOL> data = ( Post . table <EOL> . filter ( params ) <EOL> . order_by ( r . asc ( '<STR_LIT>' ) ) <EOL> . skip ( skip ) <EOL> . limit ( limit ) <EOL> . run ( db_conn ) ) <EOL> return [ instance ( d ) for d in data ] <EOL> def create_post_facade ( db_conn , data ) : <EOL> """<STR_LIT>""" <EOL> data = omit ( data , ( '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> model = instance ( data ) <EOL> return model . save ( db_conn ) <EOL> def instance_post_facade ( data ) : <EOL> """<STR_LIT>""" <EOL> data = omit ( data , ( '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return instance ( data ) </s>
