예제 #1
0
def delete_comment(config, form, page):
    c = form['delete'].value
    page, query = page.split('?', 1)
    if not 'pd' in form:
        print """<form method="POST" action="%s">
    <input type="hidden" name="delete" value="%s">
    password:<input type="password" name="pd">
    <input type="submit" value="submit">
    </form><p>You are trying to delete:<p>""" \
        % (page, c)
        cmt = comments.readComment(c)
        cmt['filename'] = c
        print_comment(cmt)
    elif form['pd'].value == config['cmt_password']:
        print "deleting %s" % c
        os.unlink(c)
    else:
        print "<br /><h2>invalid password</h2>"
예제 #2
0
def delete_comment(config, form, page):
    c = form['delete'].value
    page, query = page.split('?', 1)
    if not 'pd' in form:
        print """<form method="POST" action="%s">
    <input type="hidden" name="delete" value="%s">
    password:<input type="password" name="pd">
    <input type="submit" value="submit">
    </form><p>You are trying to delete:<p>""" \
        % (page, c)
        cmt = comments.readComment(c)
        cmt['filename'] = c
        print_comment(cmt)
    elif form['pd'].value == config['cmt_password']:
        print "deleting %s" % c
        os.unlink(c)
    else:
        print "<br /><h2>invalid password</h2>"
예제 #3
0
def print_all_comments(comdir, ext):
    coms = []
    for root, dirs, files in os.walk(comdir):
        for f in files:
            if f.endswith(ext) and f != 'LATEST.cmt':
                fname = '%s/%s' % (root, f)
                c = comments.readComment(fname)
                c['filename'] = fname
                coms.append(c)
    print len(coms)
    try:
        coms = [(time.strptime(c['cmt_pubDate']), c) for c in coms] # DSU pattern
    except KeyError:
        print "<p><h3>comment %s has an error in it</h2>" % c['filename']
        return
    coms.sort()
    coms.reverse()
    coms = [c[1] for c in coms]
    print len(coms)
    for c in coms:
        print_comment(c)
예제 #4
0
def print_all_comments(comdir, ext):
    coms = []
    for root, dirs, files in os.walk(comdir):
        for f in files:
            if f.endswith(ext) and f != 'LATEST.cmt':
                fname = '%s/%s' % (root, f)
                c = comments.readComment(fname)
                c['filename'] = fname
                coms.append(c)
    print len(coms)
    try:
        coms = [(time.strptime(c['cmt_pubDate']), c)
                for c in coms]  # DSU pattern
    except KeyError:
        print "<p><h3>comment %s has an error in it</h2>" % c['filename']
        return
    coms.sort()
    coms.reverse()
    coms = [c[1] for c in coms]
    print len(coms)
    for c in coms:
        print_comment(c)
예제 #5
0
def edit_comment(config, form, page):
    c = form['edit'].value
    cmt = comments.readComment(c)
    page, query = page.split('?', 1)
    if not 'pd' in form:
        print """<form method="POST" action="%s">
    <input type="hidden" name="edit" value="%s">
    <table><tr><td> 
    Title:</td><td><input type="text" name="title" value="%s" size="50"></td></tr><tr><td>
    Author:</td><td><input type="text" name="author" value="%s" size="50"></td></tr><tr><td>
    Link:</td><td><input type="text" name="link" value="%s" size="50"></td></tr><tr><td>
    Date:</td><td><input type="text" name="pubDate" value="%s" size="50"></td></tr><tr><td>
    Text:</td><td><textarea rows="10" cols="50" name="description">%s</textarea></td></tr><tr valign="bottom"><td>
    <br><b>Password</b>:</td><td><input type="password" name="pd"></td></tr><tr><td>
    <input type="submit" value="submit"></td></tr>
    </table>""" % (page, c, cmt['cmt_title'], cmt['cmt_author'],
                   cmt['cmt_link'], cmt['cmt_pubDate'], cmt['cmt_description'])
    elif form['pd'].value == config['cmt_password']:
        print "updating %s" % c
        cmt = make_comment(form)
        write_comment(file(c, 'w'), cmt, config)
    else:
        print "<br /><h2>invalid password</h2>"
예제 #6
0
def edit_comment(config, form, page):
    c = form['edit'].value
    cmt = comments.readComment(c)
    page, query = page.split('?', 1)
    if not 'pd' in form:
        print """<form method="POST" action="%s">
    <input type="hidden" name="edit" value="%s">
    <table><tr><td> 
    Title:</td><td><input type="text" name="title" value="%s" size="50"></td></tr><tr><td>
    Author:</td><td><input type="text" name="author" value="%s" size="50"></td></tr><tr><td>
    Link:</td><td><input type="text" name="link" value="%s" size="50"></td></tr><tr><td>
    Date:</td><td><input type="text" name="pubDate" value="%s" size="50"></td></tr><tr><td>
    Text:</td><td><textarea rows="10" cols="50" name="description">%s</textarea></td></tr><tr valign="bottom"><td>
    <br><b>Password</b>:</td><td><input type="password" name="pd"></td></tr><tr><td>
    <input type="submit" value="submit"></td></tr>
    </table>""" % (page, c, cmt['cmt_title'], cmt['cmt_author'], 
        cmt['cmt_link'], cmt['cmt_pubDate'], cmt['cmt_description'])
    elif form['pd'].value == config['cmt_password']:
        print "updating %s" % c
        cmt = make_comment(form)
        write_comment(file(c, 'w'), cmt, config)
    else:
        print "<br /><h2>invalid password</h2>"