messages: refactoring and REST API 

Refactoring of the messages module. An api.py file has been created in order to interact with the database. Also a restful.py file has been created so that messages can have a REST API.
1: D100 Docstring missing
34:6: E126 continuation line over-indented for hanging indent
49:29: E126 continuation line over-indented for hanging indent
62:1: F401 'get_detailed_page_tabs' imported but unused
72:1: E302 expected 2 blank lines, found 1
72: D101 Docstring missing
74:77: E502 the backslash is redundant between brackets
75:79: E502 the backslash is redundant between brackets
78: D400 First line should end with '.', not 'r'
78: D205 Blank line missing between one-line summary and description
105:16: E127 continuation line over-indented for visual indent
125:17: F999 redefinition of unused 'action' from line 70
128:17: F999 redefinition of unused 'action' from line 70
141:61: E225 missing whitespace around operator
192:25: F841 local variable 'n' is assigned to but never used
211:34: E201 whitespace after '{'
211:57: E203 whitespace before ':'
212:57: E203 whitespace before ':'
212:69: E261 at least two spaces before inline comment
213:57: E203 whitespace before ':'
214:57: E203 whitespace before ':'
215:57: E203 whitespace before ':'
216:57: E203 whitespace before ':'
216:67: E261 at least two spaces before inline comment
217:57: E203 whitespace before ':'
251:5: E303 too many blank lines (2)
251: D202 No blank lines allowed *after* method docstring, found 1
251: D205 Blank line missing between one-line summary and description
258: D290 White spaces around docstring should be trimmed.
258: D400 First line should end with '.', not 'm'
281:16: E127 continuation line over-indented for visual indent
301:17: F999 redefinition of unused 'action' from line 70
304:17: F841 local variable 'act' is assigned to but never used
373:63: E127 continuation line over-indented for visual indent
416:41: E128 continuation line under-indented for visual indent
417:41: E128 continuation line under-indented for visual indent
418:41: E128 continuation line under-indented for visual indent
456:26: E703 statement ends with a semicolon
535: D205 Blank line missing between one-line summary and description
547:16: E127 continuation line over-indented for visual indent
548:16: E127 continuation line over-indented for visual indent
557:9: E303 too many blank lines (2)
586:19: E126 continuation line over-indented for hanging indent
590:35: E231 missing whitespace after ','
593:30: E201 whitespace after '{'
593:53: E203 whitespace before ':'
594:53: E203 whitespace before ':'
595:53: E203 whitespace before ':'
596:53: E203 whitespace before ':'
597:53: E203 whitespace before ':'
598:53: E203 whitespace before ':'
598:63: E261 at least two spaces before inline comment
599:53: E203 whitespace before ':'
612:64: F841 local variable 'e' is assigned to but never used
625: D401 First line should be imperative: 'Thi', not 'This'
625: D290 White spaces around docstring should be trimmed.
625: D400 First line should end with '.', not 'g'
625: D205 Blank line missing between one-line summary and description
633:26: E261 at least two spaces before inline comment
634:32: E261 at least two spaces before inline comment
635:33: E113 unexpected indentation
638:47: E261 at least two spaces before inline comment
652: D401 First line should be imperative: 'Return', not 'Returns'
652: D400 First line should end with '.', not 'e'
652: D205 Blank line missing between one-line summary and description
663:9: F841 local variable 'uid' is assigned to but never used
664:9: F841 local variable 'user_info' is assigned to but never used
669:74: E502 the backslash is redundant between brackets
670:62: E502 the backslash is redundant between brackets
670:39: E221 multiple spaces before operator
681: D200 One-line docstring should not occupy 3 lines
698:13: F999 redefinition of unused 'action' from line 70
709:44: E203 whitespace before ':'
724:9: F841 local variable 'myQuery' is assigned to but never used
734:13: F999 redefinition of unused 'action' from line 70
755:36: E126 continuation line over-indented for hanging indent
765:22: E211 whitespace before '('
781: D400 First line should end with '.', not ')'
789:37: W602 deprecated form of raising exception
807:32: E203 whitespace before ':'
815: D102 Docstring missing
828:9: F841 local variable 't' is assigned to but never used
829:15: E221 multiple spaces before operator
840:9: F841 local variable 'nbFields' is assigned to but never used
846:24: E126 continuation line over-indented for hanging indent
846:35: E203 whitespace before ':'
847:31: E203 whitespace before ':'
848:30: E203 whitespace before ':'
849:30: E203 whitespace before ':'
850:23: E126 continuation line over-indented for hanging indent
852:59: E231 missing whitespace after ','
855:47: E231 missing whitespace after ','
856:52: E231 missing whitespace after ','
863:18: E126 continuation line over-indented for hanging indent
863:20: E251 unexpected spaces around keyword / parameter equals
863:22: E251 unexpected spaces around keyword / parameter equals
864:24: E251 unexpected spaces around keyword / parameter equals
864:26: E251 unexpected spaces around keyword / parameter equals
865:16: E126 continuation line over-indented for hanging indent
867: D401 First line should be imperative: 'Return', not 'Returns'
867: D200 One-line docstring should not occupy 3 lines
899: D102 Docstring missing
932:45: E127 continuation line over-indented for visual indent
941:62: E203 whitespace before ':'
941:109: E203 whitespace before ':'
941:129: E203 whitespace before ','
942:48: E126 continuation line over-indented for hanging indent
945:41: E128 continuation line under-indented for visual indent
950:62: E203 whitespace before ':'
950:109: E203 whitespace before ':'
950:129: E203 whitespace before ','
951:48: E126 continuation line over-indented for hanging indent
954:41: E128 continuation line under-indented for visual indent
964:62: E203 whitespace before ':'
964:109: E203 whitespace before ':'
964:129: E203 whitespace before ','
965:45: E126 continuation line over-indented for hanging indent
974:27: E225 missing whitespace around operator