def setUp(self): x = meeplib.get_all_messages() print "Messages",x for message in x: meeplib.delete_message(message) x = meeplib.get_all_messages() print "Messages",x u = meeplib.User('foo', 'bar',-1) v = meeplib.User('foo2', 'bar2',-1) m = meeplib.Message('the title', 'the content', u,-1)
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return [ render_page('list_messages.html', messages=messages) ]
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return [render_page('list_messages.html', messages=messages)]
def test_add_reply(self): msg = meeplib.get_all_messages()[0] reply = "I'm a reply." msg.add_reply(reply) myreply = msg.replies assert len(myreply) == 1
def del_message(self, environ, start_response): #print environ['wsgi.input'] form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) #print form messages = meeplib.get_all_messages() s = "Yup" found = False for m in messages: if m.id == int(form['id'].value): if meeplib.get_curr_user() != m.author.username: s= "Nope" break if m.pID != "!": meeplib.delete_reply(m) meeplib.delete_message(m) found = True if found == True: break start_response("200 OK", [('Content-type', 'text/html')]) #s.append("<p><p><a href = '/m/list'>Return to Messages</a>") SaveMessages() return render_page('del_message.html', s = s)
def delete_message(self, environ, start_response): if self.username is None: headers = [('Content-type', 'text/html')] start_response("302 Found", headers) return ["You must be logged in to use this feature <p><a href='/login'>Log in</a><p><a href='/m/list'>Show messages</a>"] form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) msgid = int(form['id'].value) msg = meeplib.get_message(msgid) messages = meeplib.get_all_messages() if msg.parent == -1: for child in messages: if child.parent == msgid: child.parent = -1 else: for child in messages: if child.parent == msgid: child.parent = msg.parent meeplib.delete_message(msg) with con: cur.execute("DELETE FROM Messages WHERE ID = ?", (msgid,)) con.commit() #meeplib.save() headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 Found", headers) return ["message deleted"]
def test_for_message_existence(self): print "test for message existence" messages = meeplib.get_all_messages() for m in messages: print m.post print len(messages) assert len(messages) == 1 assert messages[0].title == 'the title' assert messages[0].post == 'the content' meeplib._reset()
def tearDown(self): m = meeplib.get_all_messages()[0] meeplib.delete_message(m) u = meeplib.get_all_users()[0] meeplib.delete_user(u) assert len(meeplib._messages) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0
def test_for_message_existence(self): print "test for message existence" messages = meeplib.get_all_messages() for m in messages: print m.post print len(messages) assert len(messages) == 1 assert messages[0].title == "the title" assert messages[0].post == "the content" meeplib._reset()
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x[0] x = meeplib.get_all_messages() assert len(x) == 1 m = x[0] assert m.author == u.id
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) != 0 u = meeplib.get_user('foo') x = meeplib.get_all_messages() assert len(x) != 0 m = x[len(x) - 1] assert m.author == u
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x[0] x = meeplib.get_all_messages() assert len(x) == 1 m = x[0] assert m.author == u
def list_messages(): try: if not meeplib._messages: return rpc_settings.list_no_messages response = "" for message in meeplib.get_all_messages(): response += "id: {0} \ntitle: {1}\n message: {2}\n\n".format(message.id, message.title, message.post) return response except: return rpc_settings.list_error
def list_messages(self, environ, start_response): user = self.authHandler(environ) messages = meeplib.get_all_messages() userIDs = meeplib.getUserIDs() start_response("200 OK", [('Content-type', 'text/html')]) return [ render_page('list_messages.html', user=user, messages=messages, userIDs=userIDs) ]
def test_message_ownership(self): users = meeplib.get_all_users() for u in users: print u.username assert len(users) == 1 #two hardcoded and one added above u = users[0] messages = meeplib.get_all_messages() assert len(messages) == 1 m = messages[0] assert m.author == u meeplib._reset()
def test_message_ownership(self): users = meeplib.get_all_users() for u in users: print u.username assert len(users) == 1 # two hardcoded and one added above u = users[0] messages = meeplib.get_all_messages() assert len(messages) == 1 m = messages[0] assert m.author == u meeplib._reset()
def list_messages(): try: if not meeplib._messages: return rpc_settings.list_no_messages response = "" for message in meeplib.get_all_messages(): response += "id: {0} \ntitle: {1}\n message: {2}\n\n".format( message.id, message.title, message.post) return response except: return rpc_settings.list_error
def delete_message_action(self, environ, start_response): print "deleteaction" print environ['wsgi.input'] form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) message = int(form['id'].value) messages = meeplib.get_all_messages() # meeplib.delete_message(messages[0]) meeplib.delete_message(messages[message]) headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 Found", headers) return ["message deleted"]
def delete_message_action(self, environ, start_response): print "deleteaction" print environ['wsgi.input'] form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) message=int(form['id'].value) messages = meeplib.get_all_messages() # meeplib.delete_message(messages[0]) meeplib.delete_message(messages[message]) headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 Found", headers) return ["message deleted"]
def test_tearDown(self): print "test teardown" users = meeplib.get_all_users() for user in users: meeplib.delete_user(user) print meeplib._user_ids messages = meeplib.get_all_messages() for m in messages: meeplib.delete_message(m) print len(meeplib._user_ids) assert len(meeplib._messages) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0 meeplib._reset()
def delete_message(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) id = form['id'].value mes = meeplib.get_all_messages() for m in mes: if (m.id == int(id)): meeplib.delete_message(m) headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 OK", headers) #print id return ["message deleted"]
def delete_message(self,environ,start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) id= form['id'].value mes = meeplib.get_all_messages() for m in mes: if(m.id == int(id)): meeplib.delete_message(m) headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 OK", headers) #print id return ["message deleted"]
def SaveMessages(): #Save Messages # filename = 'messages.pickle' fp = open(filename, 'w') m = meeplib.get_all_messages() for d in m: f = [d.title, d.post, d.author.username, d.pID, d.id] pickle.dump(f, fp) #f = d.replies #pickle.dump(f, fp) fp.close() return
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() s = [] for m in messages: s.append('id: %d<p>' % (m.id,)) s.append('title: %s<p>' % (m.title)) s.append('message: %s<p>' % (m.post)) s.append('author: %s<p>' % (m.author.username)) s.append('<hr>') s.append("<a href='../../'>index</a>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return ["".join(s)]
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() s = [] for m in messages: s.append('id: %d<p>' % (m.id,)) s.append('title: %s<p>' % (m.title)) s.append('message: %s<p>' % (m.post)) s.append('author: %s<p>' % (m.author.username)) s.append('<form action="delete_action" method="POST"><input type="hidden" name="messageID" value="%d"><input type="submit" value="Delete Message"></form>' % (m.id)) s.append('<hr>') s.append("<a href='../../'>index</a>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return ["".join(s)]
def list_messages(self, environ, start_response): user = meeplib.get_curr_user(); meeplib._reset() meeplib.set_curr_user(user) conn = sqlite3.connect('meep.db') c = conn.cursor() for row in c.execute("SELECT * FROM Message"): print row meeplib.Message(row[0], row[1], row[2], row[3]) messages = meeplib.get_all_messages() headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return [render_page('list_messages.html', messages=messages)]
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() s = [] for m in messages: s.append('id: %d<p>' % (m.id, )) s.append('title: %s<p>' % (m.title)) s.append('message: %s<p>' % (m.post)) s.append('author: %s<p>' % (m.author.username)) s.append( '<form action="delete_action" method="POST"><input type="hidden" name="messageID" value="%d"><input type="submit" value="Delete Message"></form>' % (m.id)) s.append('<hr>') s.append("<a href='../../'>index</a>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return ["".join(s)]
def list_messages(self, environ, start_response): # time.sleep(10) messages = meeplib.get_all_messages() ## s = [] ## s.append('<hr>') ## for m in messages: ## print m.id ## s.append('id: %d<p>' % (m.id,)) ## s.append('title: %s<p>' % (m.title)) ## s.append('message: %s<p>' % (m.post)) ## print "M",m ## try: ## s.append('author: %s<p>' % (m.author.username)) ## except: ## s.append('author: %s<p>' % (m.author)) ## ## ## ## ## ## s.append("<a href='/m/post_reply?id="+str(m.id)+"'>Reply</a><p>") ## if meeplib.has_replies(m.id): ## s.append('<dd>Replies:<hr />') ## for r in meeplib.get_replies(m.id): ## s.append('<dd>%s<p>' % (r)) ## s.append('</dd>') ## ## s.append('<hr>') # s.append("<form action='delete_action' method='POST'>Delete a Message?<br> Message ID: <input type='text' name='id'><input type='submit'>Delete</form>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) #s.append("<form action='search_action' method='POST'>Search for Messages?<br> Message ID: <input type='text' name='text'><input type='submit'>Delete</form>") return [ render_page('list_messages.html', messages=messages, meeplib=meeplib) ]
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() s = [] listed = set() for m in messages: if m.id not in listed: s.extend(retrieve_message(m)) curr_id = m.id deepest_node = m indent = 0 while True: for child in messages: if child.parent == curr_id and child.id not in listed: indent += 1 for x in xrange(0, indent): s.append('<ul>') s.extend(retrieve_message(child)) for y in xrange(0, indent): s.append('</ul>') listed.add(child.id) curr_id = child.id deepest_node = child curr_id = deepest_node.parent if curr_id == -1: break indent -= 1 deepest_node = meeplib.get_message(curr_id) listed.clear() s.append("<a href='../../'>index</a>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) print("".join(s)) return [str("".join(s))]
def list_messages(self, environ, start_response): messages = meeplib.get_all_messages() s = [] listed = set() for m in messages: if m.id not in listed: s.extend(retrieve_message(m)) curr_id = m.id deepest_node = m indent = 0 while True: for child in messages: if child.parent == curr_id and child.id not in listed: indent+=1 for x in xrange(0, indent): s.append('<ul>') s.extend(retrieve_message(child)) for y in xrange(0, indent): s.append('</ul>') listed.add(child.id) curr_id = child.id deepest_node = child curr_id = deepest_node.parent if curr_id == -1: break indent -= 1 deepest_node = meeplib.get_message(curr_id) listed.clear() s.append("<a href='../../'>index</a>") headers = [('Content-type', 'text/html')] start_response("200 OK", headers) print("".join(s)) return [str("".join(s))]
def delete_message(self, environ, start_response): if self.username is None: headers = [('Content-type', 'text/html')] start_response("302 Found", headers) return [ "You must be logged in to use this feature <p><a href='/login'>Log in</a><p><a href='/m/list'>Show messages</a>" ] form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) msgid = int(form['id'].value) msg = meeplib.get_message(msgid) messages = meeplib.get_all_messages() if msg.parent == -1: for child in messages: if child.parent == msgid: child.parent = -1 else: for child in messages: if child.parent == msgid: child.parent = msg.parent meeplib.delete_message(msg) with con: cur.execute("DELETE FROM Messages WHERE ID = ?", (msgid, )) con.commit() #meeplib.save() headers = [('Content-type', 'text/html')] headers.append(('Location', '/m/list')) start_response("302 Found", headers) return ["message deleted"]
def test_for_message_existence(self): x = meeplib.get_all_messages() print "num messages", x assert len(x) == 1 assert x[0].title == 'the title' assert x[0].post == 'the content'
def get_messages_length(): messages = meeplib.get_all_messages() return len(messages)
def test_delete_message(self): temp = meeplib.get_all_messages() msg = meeplib.get_all_messages()[0] meeplib.delete_message(msg) assert len(meeplib.get_all_messages()) < len(temp)
def list_messages(self, environ, start_response): user = self.authHandler(environ) messages = meeplib.get_all_messages() userIDs = meeplib.getUserIDs() start_response("200 OK", [('Content-type', 'text/html')]) return [ render_page('list_messages.html', user = user, messages = messages, userIDs = userIDs) ]
def test_for_message_existence(self): x = meeplib.get_all_messages() assert len(x) == 1 assert x[0].title == 'the title' assert x[0].post == 'the content'
def index(self, environ, start_response): headers = [('Content-type', 'text/html')] start_response('200 OK', headers) return [render_page('index.html', user=self.getUser(environ), \ messages=meeplib.get_all_messages())]
def setUp(self): u = meeplib.User('foo', 'bar') print "\n add m" m = meeplib.Message('the title', 'the content', u, -1, {}) print len(meeplib.get_all_messages())
def setUp(self): u = meeplib.User("foo", "bar") print "\n add m" m = meeplib.Message("the title", "the content", u, -1, {}) print len(meeplib.get_all_messages())
def test_for_message_existence(self): x = meeplib.get_all_messages() assert len(x) != 0 assert x[len(x)-1].title == 'the title' assert x[len(x)-1].post == 'the content'
def test_for_message_existence(self): x = meeplib.get_all_messages() assert len(x) == 1 assert x[0].title == "the title" assert x[0].post == "the content"