예제 #1
0
#!/usr/bin/python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb
cgitb.enable()

value_dic = {'rsslist': [x for x in Rssurl.select(order_by='id')]}

res = Response()
p = path.join(path.dirname(__file__), 'urllist.html')
t = SimpleTemplate(file_path=p)
body = t.render(value_dic)
res.set_body(body)

print res
예제 #2
0
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb; cgitb.enable()

errors = {}
value_dic = {'errors': errors, 'title': '', 'url': '', 'item_id': ''}

req = Request()
f = req.form

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 = f.getvalue('title')
        rss.url = f.getvalue('url')
        rss.update()
예제 #3
0
#!/usr/bin/python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
from rssparser import parse_rss
import cgitb
cgitb.enable()

rsslist = []
try:
    # TODO: 実装
    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)

print res
예제 #4
0
파일: listurl.py 프로젝트: siguremon/pyweb
#!/usr/bin/env python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb; cgitb.enable()

value_dic = {'rsslist' : [x for x in Rssurl.select(order_by = 'id')]}

res = Response()
p = path.join(path.dirname(__file__), 'urllist.html')
t =  SimpleTemplate(file_path = p)
body = t.render(value_dic)
res.set_body(body)
print res

예제 #5
0
파일: addurl.py 프로젝트: siguremon/pyweb
cgitb.enable()

errors = {}
value_dic = {"errors": errors, "title": "", "url": "", "item_id": ""}

req = Request()
f = req.form

if f.getvalue("posted"):
    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 [x for x in Rssurl.select(url=url)]:
        errors["url"] = u"このURLは登録済みです"
    if not errors:
        Rssurl(title=title, url=url)
        p = path.join(path.dirname(__file__), "posted.html")
        value_dic["message"] = u"RSS取得URLを追加しました"

res = Response()
p = path.join(path.dirname(__file__), "addform.html")
t = SimpleTemplate(file_path=p)
body = t.render(value_dic)
res.set_body(body)
print res
예제 #6
0
#!/usr/bin/env python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
from rssparser import parse_rss
import cgitb; cgitb.enable()

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)
print res

예제 #7
0
from os import path
from httphandler import Request, Response
import cgitb
cgitb.enable()

errors = {}
value_dic = {'errors': errors, 'title': '', 'url': '', 'item_id': ''}

req = Request()
f = req.form

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 = f.getvalue('url', '')
    value_dic.update({'title': title, 'url': url, 'item_id': id})
    if not title:
        errors['title'] = u"たいとるをにゅうりょくしてね!"
    if not url.startswith('http://'):
        errors["url"] = u"ただしいゆーあーるえるをにゅうりょくしてね!"
    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()
예제 #8
0
from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb
cgitb.enable()

value_dic = {'errors': "", 'title': '', 'url': '', 'item_id': ''}

req = Request()
f = req.form

p = path.join(path.dirname(__file__), 'deleteform.html')

id = f.getvalue("id")
rss = Rssurl(id=int(id))

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')
    rss = Rssurl(id=int(f.getvalue('id')))
    rss.delete()
    p = path.join(path.dirname(__file__), "posted.html")
    value_dic["message"] = u"RSS取得URLをさくじょしたお!"

t = SimpleTemplate(file_path=p)
res = Response()
body = t.render(value_dic)
예제 #9
0
#! /usr/bin/env python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb

cgitb.enable()

value_dic = {"rsslist": [x for x in Rssurl.select(order_by="id")]}

res = Response()
p = path.join(path.dirname(__file__), "urllist.html")
t = SimpleTemplate(file_path=p)
body = t.render(value_dic)
res.set_body(body)

print res
예제 #10
0
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb; cgitb.enable()

errors = {}
value_dic = {'errors': errors, 'title':'', 'url': '', 'item_id':''}

req = Request()
f = req.form

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 = f.getvalue('title', '')
    url = f.getvalue('url', '')
    value_dic.update({'title': title, 'url': url, 'item_id': id})
    if not title:
        errors['title'] = 'タイトルを入力してください。'
    if not url:
        errors['title'] = '正しいURLを入力してください。'
    if not errors:
        rss = Rssurl(id=int(f.getvalue('id')))
        rss.title = title
        rss.url = url
        rss.upate()
예제 #11
0
from os import path
from httphandler import Request, Response
import cgitb
cgitb.enable()

errors = {}
value_dic = {'errors': errors, 'title': '', 'url': '', 'item_id': ''}

req = Request()
f = req.form

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 = f.getvalue('title')
        rss.url = f.getvalue('url')
        rss.update()
예제 #12
0
#!/home/minori/.pyenv/shims/python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
import cgitb; cgitb.enable()

value_dic = {"rsslist":[x for x in Rssurl.select(order_by = "id")]}

res = Response()
p = path.join(path.dirname(__file__), "urllist.html")
t = SimpleTemplate(file_path = p)
body = t.render(value_dic)
res.set_body(body)
print res

예제 #13
0
#!/home/minori/.pyenv/shims/python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
from rssparser import parse_rss
import cgitb
cgitb.enable()

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)
print res
예제 #14
0
cgitb.enable()

errors = {}
value_dic = {'errors': errors, 'title': '', 'url': '', 'item_id': ''}

req = Request()
f = req.form

p = path.join(path.dirname(__file__), 'addform.html')

if f.getvalue('posted'):
    title = unicode(f.getvalue('title', ''), "utf-8", "ignore")
    url = f.getvalue('url', '')
    value_dic.update({'title': title, 'url': url})
    if not title:
        errors['title'] = u"たいとるをにゅうりょくしてね!"
    if not url.startswith('http://'):
        errors["url"] = u"ただしいゆーあーるえるをにゅうりょくしてね!"
    if [x for x in Rssurl.select(url=url)]:
        errors["url"] = u"もう登録してあるやつやで"
    if not errors:
        Rssurl(title=title, url=url)
        p = path.join(path.dirname(__file__), "posted.html")
        value_dic["message"] = u"RSS取得URLをついかしたお!"

t = SimpleTemplate(file_path=p)
res = Response()
body = t.render(value_dic)
res.set_body(body)
print res
예제 #15
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from rssparser import parse_rss
from httphandler import Request, Response
import cgitb; cgitb.enable()


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)
print(res)
예제 #16
0
from os import path
from httphandler import Request, Response
import cgitb
cgitb.enable()

errors = {}
value_dic = {"errors": errors, "title": "", "url": "", "item_id": ""}

req = Request()
f = req.form

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", "")
예제 #17
0
from os import path
from httphandler import Request, Response

import cgitb; cgitb.enable()

errors = {}
value_dic = {"errors":errors, "title":"", "url":"", "item_id":""}

req = Request()
f = req.form

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://") or url.startswith("https://")):
        errors["url"] = u"正しいURLを入力してください"
    if not errors:
        rss = Rssurl(id = int(f.getvalue("id")))
        rss.title = f.getvalue("title")
        rss.url = f.getvalue("url")
        rss.update()