Esempio n. 1
0
    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)
Esempio n. 2
0
    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) ]
Esempio n. 3
0
    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)]
Esempio n. 4
0
    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
Esempio n. 5
0
    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)
Esempio n. 6
0
    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"]
Esempio n. 7
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()
Esempio n. 8
0
    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
Esempio n. 9
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()
Esempio n. 10
0
    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
Esempio n. 11
0
    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
Esempio n. 12
0
    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
Esempio n. 13
0
    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
Esempio n. 14
0
    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
Esempio n. 15
0
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
Esempio n. 16
0
 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)
     ]
Esempio n. 17
0
 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()
Esempio n. 18
0
 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()
Esempio n. 19
0
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
Esempio n. 20
0
    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"]
Esempio n. 21
0
    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"]
Esempio n. 22
0
 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()
Esempio n. 23
0
    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"]
Esempio n. 24
0
 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()
Esempio n. 25
0
    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"]
Esempio n. 26
0
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
Esempio n. 27
0
    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)]
Esempio n. 28
0
    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)]
Esempio n. 29
0
    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)]
Esempio n. 30
0
    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)]
Esempio n. 31
0
    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)
        ]
Esempio n. 32
0
    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))]
Esempio n. 33
0
    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))]
Esempio n. 34
0
    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) ]
Esempio n. 35
0
    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"]
Esempio n. 36
0
 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'
Esempio n. 37
0
def get_messages_length():
    messages = meeplib.get_all_messages()
    return len(messages)
Esempio n. 38
0
 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)
Esempio n. 39
0
 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) ]
Esempio n. 40
0
def get_messages_length():
    messages = meeplib.get_all_messages()
    return len(messages)
Esempio n. 41
0
 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'
Esempio n. 42
0
 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())]
Esempio n. 43
0
 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())
Esempio n. 44
0
 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())]
Esempio n. 45
0
 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())
Esempio n. 46
0
 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'
Esempio n. 47
0
 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"