Пример #1
0
def listurl(_request):
    res=Response()
    rsslist=Rssurl.select()
    t=SimpleTemplate(file_path=relativepath('urllist.html'))
    body=t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Пример #2
0
def listurl(_request):
    res = Response()
    rsslist = Rssurl.select()
    t = SimpleTemplate(file_path=relativepath('urllist.html'))
    body = t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Пример #3
0
def login_form(_request, values={}, errors={}):
    body = base_body % ("${form.display(values, errors)}")
    res = Response()
    t = SimpleTemplate(body)
    values["password"] = ""
    body = t.render({"form": loginform, "values": values, "errors": errors})
    res.set_body(body)
    return res
Пример #4
0
def index(_request, foo="", d={"counter": 0}):
    body = base_body % ("<p>Logged in!</p>")
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d["counter"] += 1
    res.set_body(body)
    return res
Пример #5
0
def index(_request, d ={'counter':0}):
  body = """<html><body><p>${counter}</p></body></html>"""
  res = Response()
  t = SImpleTemplate(body)
  body = t.render(d)
  d['counter'] += 1
  res.set_body(body)
  return res
Пример #6
0
def get_add_form(values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath('form.html'))
    body = t.render({'message': 'RSS巡回用URLの追加',
                     'form': addform,
                     'values': values, 'errors': errors})
    res.set_body(body)
    return res
Пример #7
0
def get_add_form(values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    body=t.render({'message': u'RSS巡回用URLの追加',
                   'form':addform,
                   'values':values, 'errors':errors})
    res.set_body(body)
    return res
Пример #8
0
def index(_request, d={"counter": 0}):
    body = """<html><body><p>${counter}</p></body></html>"""
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d["counter"] += 1
    res.set_body(body)
    return res
Пример #9
0
def index(_request, foo='', d={'counter': '0'}):
    body = base_body % ('<p>Logged in!</p>')
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] = str(int(d['counter']) + 1)
    res.set_body(body)
    return res
Пример #10
0
def index(_request, d={'counter': '0'}):
    body = """<html><body><p>${counter}</p></body></html>"""
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] = str(int(d['counter']) + 1)
    res.set_body(body)
    return res
Пример #11
0
def login_form(_request, values={}, errors={}):
    body = base_body % ('${form.display(values, errors)}')
    res = Response()
    t = SimpleTemplate(body)
    values['password'] = ''
    body = t.render({'form': loginform, 'values': values, 'errors': errors})
    res.set_body(body)
    return res
Пример #12
0
def index(_request, d={'counter': '0'}):
    body = """<html><body><p>${counter}</p></body></html>"""
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] = '1'
    res.set_body(body)
    return res
Пример #13
0
def login_form(_request, values={}, errors={}):
    body = base_body % ('${form.display(values, errors)}')
    res = Response()
    t = SimpleTemplate(body)
    values['password'] = ''
    body = t.render({'form': loginform, 'values': values, 'errors': errors})
    res.set_body(body)
    return res
Пример #14
0
def logout(_request):
    body=get_htmltemplate() % ('<p>Logged out</p>')
    res=Response()
    c=SimpleCookie()
    c['authhash']=''
    res.set_header(*c.output().split(': '))
    res.set_body(body)
    return res
Пример #15
0
def index(_request, foo='', d={'counter': 0}):
    body = base_body % ('<p>Logged in!</p>')
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] += 1
    res.set_body(body)
    return res
Пример #16
0
def login_form(_request, values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    values['password']=''
    body=t.render({'form':loginform, 'values':values, 'errors':errors,
                   'message':u'ログイン'})
    res.set_body(body)
    return res
Пример #17
0
def get_add_form(values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    body = t.render({
        "message": u"RSS巡回用URLの追加",
        "form": addform,
        "values": values,
        "errors": errors
    })
    res.set_body(body)
    return res
Пример #18
0
def login_form(_request, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    values["password"] = ""
    body = t.render({
        "form": loginform,
        "values": values,
        "errors": errors,
        "message": u"ログイン"
    })
    res.set_body(body)
    return res
Пример #19
0
def add(_request, title="", url=""):
    res = Response()
    values, errors = addform.validate({"title": title, "url": url})
    if [x for x in Rssurl.select(url=url)]:
        errors["url"] = u"このURLは登録済みです"
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを追加しました"})
    res.set_body(body)
    return res
Пример #20
0
def login_form(_request, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath('form.html'))
    values['password'] = ''
    body = t.render({
        'form': loginform,
        'values': values,
        'errors': errors,
        'message': u'ログイン'
    })
    res.set_body(body)
    return res
Пример #21
0
def add(_request, title='', url=''):
    res = Response()
    values, errors = addform.validate({'title': title, 'url': url})
    if [ x for x in Rssurl.select(url=url)]:
        errors['url'] = "このURLは登録済みです"
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t = SimpleTemplate(file_path=relativepath('posted.html'))
    body = t.render({'message': '巡回用URLを追加しました'})
    res.set_body(body)
    return res
Пример #22
0
def get_edit_form(item_id, values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values={'item_id':item_id, 'title':item.title, 'url':item.url}
    body=t.render({'message': u'RSS巡回用URLの編集',
                   'form':editform,
                   'values':values, 'errors':errors})
    res.set_body(body)
    return res
Пример #23
0
def add(_request, title='', url=''):
    res=Response()
    values, errors=addform.validate({'title':title, 'url':url})
    if [ x for x in Rssurl.select(url=url)]:
        errors['url']=u'このURLは登録済みです'
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを追加しました'})
    res.set_body(body)
    return res
Пример #24
0
def get_edit_form(item_id, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath('form.html'))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values = {'item_id': item_id, 'title':item.title, 'url': item.url}
    body = t.render({'message': 'RSS巡回用URLの編集',
                     'form': editform,
                     'values': values, 'errors': errors})
    res.set_body(body)
    return res
Пример #25
0
def index(_request):
    rsslist = []
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    res = Response()
    p = path.join(path.dirname(__file__), 'rsslist.html')
    t = SimpleTemplate(file_path=p)
    body = t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Пример #26
0
def edit(_request, item_id, title='', url=''):
    res=Response()
    values, errors=editform.validate({'item_id':item_id,
                            'title':title, 'url':url})
    if errors:
        return get_edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title=title
        item.url=url
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを編集しました'})
    res.set_body(body)
    return res
Пример #27
0
def index(_request):
    rsslist=[]
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    
    res=Response()
    p=path.join(path.dirname(__file__), 'rsslist.html')
    t=SimpleTemplate(file_path=p)
    body=t.render({'rsslist':rsslist[:20]})
    res.set_body(body)
    return res
Пример #28
0
def edit_form(_request, item_id, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values = {"item_id": item_id, "title": item.title, "url": item.url}
    body = t.render({
        "message": u"RSS巡回用URLの編集",
        "form": editform,
        "values": values,
        "errors": errors
    })
    res.set_body(body)
    return res
Пример #29
0
def edit(_request, item_id, title="", url=""):
    res = Response()
    values, errors = editform.validate({
        "item_id": item_id,
        "title": title,
        "url": url
    })
    if errors:
        return edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title = title
        item.url = url
        item.update()
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを編集しました"})
    res.set_body(body)
    return res
Пример #30
0
 def wrapper(_request, *args, **kws):
     if self.checkfunc(_request):
         return func(_request=_request, *args, **kws)
     else:
         res = Response()
         res.status = 302
         res.set_header('Location', self.loginpath)
         res.set_body('')
         return res
Пример #31
0
def login(_request, username="", password=""):
    res = Response()
    values, errors = loginform.validate({
        "username": username,
        "password": password
    })
    if errors or fixeduser != username or fixedpass != password:
        return login_form(_request, values, errors)

    c = SimpleCookie()
    m = md5.md5(username + ":" + password)
    c["authhash"] = m.hexdigest()
    c["authhash"]["expires"] = "Thu, 1-Jan-3000 00:00:00 GMT"
    res.set_header(*c.output().split(": "))
    res.status = 302
    res.set_header("Location", "/")
    res.set_body("")
    return res
Пример #32
0
def login(_request, username='', password=''):
    res = Response()
    values, errors = loginform.validate({
        'username': username,
        'password': password
    })
    if errors or fixeduser != username or fixedpass != password:
        return login_form(_request, values, errors)

    c = SimpleCookie()
    m = md5.md5(username + ':' + password)
    c['authhash'] = m.hexdigest()
    c['authhash']['expires'] = 'Thu, 1-Jan-2030 00:00:00 GMT'
    res.set_header(*c.output().split(': '))
    res.status = 302
    res.set_header('Location', '/')
    res.set_body('')
    return res
Пример #33
0
def login(_request, username='', password=''):
    res = Response()
    values, errors = loginform.validate({'username': username,
                                         'password': password})
    if errors or fixeduser != username or fixedpass != password:
        return login_form(_request, values, errors)
    c = SimpleCookie()
    m = hashlib.md5((username+':'+password).encode('utf-8'))
    c['authhash'] = m.hexdigest()
    c['authhash']['expires'] = 'Thu, 1-Jan-2030 00:00:00 GMT'
    res.set_header(*c.output().split(': '))
    res.status = 302
    res.set_header('Location', '/')
    res.set_body('')
    return res
Пример #34
0
def logout(_request):
    body = base_body % ('<p>Logged out</p>')
    res = Response()
    c = SimpleCookie()
    c['authhash'] = ''
    res.set_header(*c.output().split(': '))
    res.set_body(body)
    return res
Пример #35
0
def logout(_request):
    body = base_body % ("<p>Logged out</p>")
    res = Response()
    c = SimpleCookie()
    c["authhash"] = ""
    res.set_header(*c.output().split(': '))
    res.set_body(body)
    return res
Пример #36
0
 def wrapper(_request, *args, **kws):
     if self.checkfunc(_request):
         return func(_request=_request, *args, **kws)
     else:
         res=Response()
         res.status=302
         res.set_header('Location', self.loginpath)
         res.set_body('')
         return res
Пример #37
0
def index(_request, name='', body='', submit=''):
    res = Response()
    t = SimpleTemplate(htmlbody)
    body = t.render({'name': name, 'body': body})
    res.set_body(body)
    return res
Пример #38
0
p = path.join(path.dirname(__file__), "editform.html")

if not f.getvalue("posted"):
    id = f.getvalue("id")
    rss = Rssurl(id=int(id))
    value_dic.update({"title": rss.title, "url": rss.url, "item_id": id})
else:
    id = f.getvalue("id")
    title = unicode(f.getvalue("title", ""), "utf-8", "ignore")
    url = unicode(f.getvalue("url", ""), "utf-8", "ignore")
    value_dic.update({"title": title, "url": url, "item_id": id})
    if not title:
        errors["title"] = u"タイトルを入力してください"
    if not url.startswith("http://"):
        errors["url"] = u"正しいURLを入力してください"

    if not errors:
        rss = Rssurl(id=int(f.getvalue("id")))
        rss.title = unicode(f.getvalue("title", ""), "utf-8", "ignore")
        rss.url = f.getvalue("url", "")
        rss.update()
        p = path.join(path.dirname(__file__), "posted.html")
        value_dic["message"] = u"RSS取得を編集しました"

t = SimpleTemplate(file_path=p)
res = Response()
body = t.render(value_dic)
res.set_body(body)
print res
Пример #39
0
except:
    pass

req=Request()
f=req.form
value_dic={'message':'', 'title':'', 'url':'','bookmarks':''}

if f.has_key('post'):
    if f.getvalue('title', '') and f.getvalue('url', ''):
        cur.execute("""INSERT INTO bookmark(title, url) VALUES(?, ?)""",
                    (f.getvalue('title', ''), f.getvalue('url', '')))
        con.commit()
    else:
        value_dic['message']=u'タイトルとURLは必須項目です'
        value_dic['title']=f.getvalue('title', '')
        value_dic['url']=f.getvalue('url', '')

listbody=''
cur.execute("SELECT title, url FROM bookmark")
for item in cur.fetchall():
    listbody+="""<dt>%s</dt><dd>%s</dd>\n"""%(item)
listbody="""<ul>\n%s</ul>"""%listbody
value_dic['bookmarks']=listbody

res=Response()
f=open(path.join(path.dirname(__file__), 'bookmarkform.html'))
t=Template(unicode(f.read(), 'utf-8', 'ignore'))
body=t.substitute(value_dic)
res.set_body(body)
print res
Пример #40
0
    </div>
    <script src="../js-dir/createInput.js">
    </script>
</body>
</html>
"""

cook = SimpleCookie()
cook.load(os.environ.get("HTTP_COOKIE", ""))
req = Request()
user = None
family = None
first = None
if "user" in cook.keys():
    user = str(cook.get("user")).split("=")[1]

if user is None:
    raise Exception("username is Bad")

db = db_exe()
info = db.account_get_check(user)

first = info[3]
family = info[2]

html = html_ % (family, first, user)
res = Response()
res.set_body(html)
print(cook.output())
print(str(res))
radio_parts = """
<input type="radio" name="language" value="{0}" />{0}
<div style="border-left: solid {1}em red; ">{1}</div>
"""

lang_dic = {}
try:
    with open("./favorite_langage.dat", "rb") as f:
        lang_dic = pickle.load(f)
except:
    pass

content = ""
req = Request()
if "language" in req.form:
    lang = req.form["language"].value
    test = req.form
    lang_dic[lang] = lang_dic.get(lang, 0) + 1
    with open("./favorite_langage.dat", "wb") as f:
        pickle.dump(lang_dic, f)

for lang in ["perl", "PHP", "Python", "Ruby"]:
    num = lang_dic.get(lang, 0)
    content += radio_parts.format(lang, num)

res = Response()
body = form_body.format(content)
res.set_body(get_htmltemplate().format(body))
print(res)
print(req.form)
print("\r\n")
Пример #42
0
    print res

req = Request()

con = MySQLdb.connect(host = 'localhost', db = 'usermanage', user = '******',
        passwd = 'python', charset = 'utf8')
cur = con.cursor(MySQLdb.cursors.DictCursor)

str = req.form.getvalue('custname', 'none')
radio = req.form.getvalue('cust', 'none')

template_path = '/var/www/html/cpy/result.html'

if str == "none":
    body = u"テキストフィールドに検索する文字を入力してください"
    res = Response()
    res.set_body(get_htmltemplate() % body)
    print res

elif radio == "custini":
    cur.execute("""SELECT * FROM main WHERE custini = '%s' FOR UPDATE""" % str)
    con.commit()
    temp = cur.fetchall()
    if temp:
        item = temp[0]
        t = SimpleTemplate(file_path = template_path)
        body = t.render(item)
        res = Response()
        res.set_body(body)
        print res
    else:
Пример #43
0
con = sqlite3.connect("./dbfile.dat")
cur = con.cursor()

try:
    cur.execute("""CREATE TABLE language_pole(
                   name text, value int);""")
except:
    pass

req = Request()
if "language" in req.form:
    incrementvalue(cur, req.form["language"].value)

lang_dic = {}
cur.execute("""SELECT name, value FROM language_pole;""")
for res in cur.fetchall():
    lang_dic[res[0]] = res[1]

content = ""
for lang in ["Perl", "PHP", "Python", "Ruby"]:
    num = lang_dic.get(lang, 0)
    content += radio_partu.format(lang, lang, num, num)

con.commit()

res = Response()
body = form_body.format(content)
res.set_body(get_htmltemplate("軽量言語アンケート DB版").format(body))
print(res)
Пример #44
0
radio_parts=u"""
<input type="radio" name="language" value="%s" />%s
<div style="border-left: solid %sem red; ">%s</div>
"""

lang_dic={}
try:
    f=open('./favorite_langage.dat')
    lang_dic=pickle.load(f)
except IOError:
    pass

content=""
req=Request()
if req.form.has_key('language'):
    lang=req.form['language'].value
    lang_dic[lang]=lang_dic.get(lang, 0)+1

f=open('./favorite_langage.dat', 'w')
pickle.dump(lang_dic, f)

for lang in ['Perl', 'PHP', 'Python', 'Ruby']:
    num=lang_dic.get(lang, 0)
    content+=radio_parts%(lang, lang, num, num)

res=Response()
body=form_body%content
res.set_body(get_htmltemplate()%body)
print res
Пример #45
0
db = db_exe()
db.account_table()
input_name = req.form["username"].value
input_pass = req.form["password"].value
content = ""
if db.account_check(input_name, input_pass):
    ac_info = db.account_get_check(input_name)
    familyname = str(ac_info[2])
    firstname = str(ac_info[3])
    age = str(ac_info[4])

    cook["user"] = input_name
    cook["user"]["path"] = "/"

    cook["family"] = familyname
    cook["family"]["path"] = "/"

    cook["first"] = firstname
    cook["first"]["path"] = "/"

    content = true_body

else:
    content = (html_body % false_body)

res = Response()
res.set_body(content)
print(cook.output())
print(str(res))
Пример #46
0
def notapplicable():
    body = u"該当がありません"
    res = Response()
    res.set_body(get_htmltemplate() % body)
    print res
Пример #47
0
lang_dic = {}
try:
    if os.path.exists('./favorite_language.dat'):
        with open('./favorite_language.dat', 'rb') as f:
            lang_dic = pickle.load(f)
        
except IOError:
    pass


content = ""
req = Request()
if 'language' in req.form:
    lang = req.form['language'].value
    lang_dic[lang] = lang_dic.get(lang, 0) + 1

with open('favorite_language.dat', 'wb') as f:
    pickle.dump(lang_dic, f)

for lang in ['Perl', 'PHP', 'Python', 'Ruby']:
    num = lang_dic.get(lang, 0)
    content += radio_parts.format(lang=lang, num=num)

res = Response()
body = form_body.format(lang=content)
res.set_body(get_htmltemplate().format(body))


print(res.make_output())
Пример #48
0
cgitb.enable()

form_body = u"""
    <form method="post" action="/cgi-bin/rssreader1.py">
        RSSのURL:
        <input type="text" size="40" name="url" value="%s" />
        <input type="submit" />
    </form>"""

rss_parts = u"""
<h3><a href="%(link)s">%(title)s</a></h1>
<p>%(description)s</p>
"""

content = u"URLを入力してください"
req = Request()
if req.form.has_key('url'):
    try:
        rss_list = parse_rss(req.form['url'].value)
        content = ''
        for d in rss_list:
            content += rss_parts % d
    except:
        pass

res = Response()
body = form_body % req.form.getvalue('url', '')
body += content
res.set_body(get_htmltemplate() % body)
print res
Пример #49
0
def index(_request, name='', body='', submit=''):
    res=Response()
    t=SimpleTemplate(htmlbody)
    body=t.render({'name':name, 'body':body})
    res.set_body(body)
    return res