this script give me a memory error in parse()...what is a memory error and how can i fix it?

import cgi

class COM:
    def __init__(self):
        f=open('C:/site/commentlog.txt', 'r')
        self.lines=f.readlines()      
        f.close()


    def writecom(self, post):
        f=open('C:/site/commentlog.txt', 'a')
        f.write(post)
        f.close()

    def getcom(self):
        try:
            form=cgi.FieldStorage()
            q=form.getvalue("posts")
            if q:
                writecom(q)
                return q
        except:
            return 0


    def parse(self, post):
        b=[]
        while post>65:
            c=post[:64]
            post=post[64:]
            b.append(c)
        b.append(post)
        return b
        

    def postline(self, post):
        print "<textarea readonly name=\"posts\" rows=\"10\" cols=\"65\">"
        print post
        print "</textarea>"
    
    def postlines(self, posts):
        print "<textarea readonly name=\"posts\" rows=\"10\" cols=\"65\">"
        for line in posts:
            print line
        print "</textarea>"
    def main(self):
        self.getcom()
        self.postit()
        if self.lines:
            
            for a in self.lines:
                if a>65:
                    b=self.parse(a)
                    self.postlines(b)
                else:
                    self.postline(a)
        else:
            pass
        print "</body>"
        print "</html>"
            



    def postit(self):
        print "Content-type: text/html\r\n\r\n"
        print "<style type=\"text/css\">"
        print "h2 {"
        print "color : green;"
        print "}"
        print "textarea {"
        print "  color : black;"
        print "  background-color : #00f000;"
        print "}"
        print "body {"
        print "  background-color : black; } "
        print "</style>"
        print "<html>"
        print "<head>"
        print "<img src=\"  \" width=\"240\" height=\"230\" align=\"right\">"
        print "</head>"
        print "<body>"
        print "<h2>This is my second page anyone can post comments anonymously<br>"
        print "<form action=\"comments.py.py\" method=\"POST\">"
        print "<textarea name=\"posts\" rows=\"10\" cols=\"65\">"
        print "</textarea>"
        print "<input type=\"submit\" value=\"post\">"
        print "</form>"
        print "<hr>"



c=COM()
c.main()

Recommended Answers

All 3 Replies

Define "memory error". How about pasting your traceback.

nevermind i got it i forgot to specify len(post) in parse

nevermind i got it i forgot to specify len(post) in parse

Thanks for letting us know!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.