예제 #1
0
    def post_setpe(self, token, password, confirm):
        try:
            self.context.auth.setpw(token, password, confirm)
        except UserError as err:
            return bobo.redirect('setpw?token=%s&%s' %
                                 (token, urllib.parse.quote(str(err))))

        return bobo.redirect('login')
예제 #2
0
    def post_login(self, email, password):
        try:
            user = self.context.auth.login_creds(email, password)
        except UserError as err:
            response = bobo.redirect('/auth/login?message=' +
                                     urllib.parse.quote(str(err)))
        else:
            response = bobo.redirect('/')
            jwtauth.save(response,
                         self.context.auth.secret,
                         uid=user.id,
                         generation=user.generation)

        return response
예제 #3
0
def quote(quote_id):
    template = template_loader.load('quote.html')
    quote = Quotes.get_by_id(int(quote_id))
    # post-hoc attempt at geocoding based on the city and state
    if quote and quote.location=='0.0,0.0':
        address = quote.city+', '+quote.state
        address = address.replace(' ', '+')
        url="http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false" % address
        try:
            # some queries to Google aren't returning data, or are timing out,
            # which causes the errors we'd been seeing. Wrapping a try around
            # it insulates us from the error.
            response = urlfetch.fetch(url, deadline=10)
            jsongeocode = response.content
            geocode = json.loads(jsongeocode)
            quote.location.lat = geocode['results'][0]['geometry']['location']['lat']
            quote.location.lon = geocode['results'][0]['geometry']['location']['lng']
            quote.put()
        except: pass
    # Test if the quote exists, and if it is marked as 'safe' (the default). 
    if quote and quote.safe:
        return template(master=master, quote=quote)
    # Otherwise, redirect to the homepage.
    else:
         return bobo.redirect('/')
예제 #4
0
def quote(quote_id):
    template = template_loader.load('quote.html')
    quote = Quotes.get_by_id(int(quote_id))
    # post-hoc attempt at geocoding based on the city and state
    if quote and quote.location == '0.0,0.0':
        address = quote.city + ', ' + quote.state
        address = address.replace(' ', '+')
        url = "http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false" % address
        try:
            # some queries to Google aren't returning data, or are timing out,
            # which causes the errors we'd been seeing. Wrapping a try around
            # it insulates us from the error.
            response = urlfetch.fetch(url, deadline=10)
            jsongeocode = response.content
            geocode = json.loads(jsongeocode)
            quote.location.lat = geocode['results'][0]['geometry']['location'][
                'lat']
            quote.location.lon = geocode['results'][0]['geometry']['location'][
                'lng']
            quote.put()
        except:
            pass
    # Test if the quote exists, and if it is marked as 'safe' (the default).
    if quote and quote.safe:
        return template(master=master, quote=quote)
    # Otherwise, redirect to the homepage.
    else:
        return bobo.redirect('/')
예제 #5
0
def index(bobo_request):
    t = db.table("access")
    t.insert({
        "date": datetime.datetime.now().timetuple()[:3],
        "ip": bobo_request.remote_addr
    })
    return bobo.redirect(url='/static/main/main1.html')
예제 #6
0
def add(bobo_request):
	doc = {}
	for k in bobo_request.POST:
		doc[k] = bobo_request.POST[k]
	
	col = get_collection()
	col.insert(doc)
	return bobo.redirect('/')
예제 #7
0
def add(quote, name, city, state):
    rand = random.random()
    new_quote = Quotes(quote=quote,
                       name=name,
                       city=city,
                       state=state,
                       rand=rand,
                       location='0,0')
    new_quote.put()
    return bobo.redirect('/q/' + str(new_quote.key().id()))
예제 #8
0
def add(quote, name, city, state, lat, lon, errormsg):
    rand = random.random()
    # Note: we're not doing any server-side validation (other than that
    # enforced by the data model), so we're a bit over-reliant on the 
    # client side validation. A user who has JS turned off and submits bad
    # data would see an unfriendly error message.
    new_quote = Quotes(quote=quote, name=name, city=city,
                       state=state, rand=rand, location=lat+','+lon,
                      errormsg=errormsg)
    new_quote.put()
    # after crrating the quote, redirect to the new quote's page. 
    return bobo.redirect('/q/'+str(new_quote.key().id()))
예제 #9
0
def show_article(title):
    sql_db = query.DB(SQLDB_PATH)
    article = sql_db.search('blog', ('title', title))
    if len(article) == 0:
        sql_db.close()
        return bobo.redirect('/')
    else:
        html = ''
        with open(cdr + '/template/show.html', 'r', encoding='utf-8') as show:
            html = show.read()
            m = re.search('{article_my}', html)
            html = html[:m.span()[0]] + next(wrap_article_result(article))['content']+\
                html[m.span()[1]:]
        sql_db.close()
        return html
예제 #10
0
def add(quote, name, city, state, lat, lon, errormsg):
    rand = random.random()
    # Note: we're not doing any server-side validation (other than that
    # enforced by the data model), so we're a bit over-reliant on the
    # client side validation. A user who has JS turned off and submits bad
    # data would see an unfriendly error message.
    new_quote = Quotes(quote=quote,
                       name=name,
                       city=city,
                       state=state,
                       rand=rand,
                       location=lat + ',' + lon,
                       errormsg=errormsg)
    new_quote.put()
    # after crrating the quote, redirect to the new quote's page.
    return bobo.redirect('/q/' + str(new_quote.key().id()))
예제 #11
0
 def post_request(self, email, name):
     try:
         message = self.context.auth.request(email, name,
                                             self.base.request.host_url)
     except UserError as err:
         return bobo.redirect('/auth/request?message=' +
                              urllib.parse.quote(str(err)))
     else:
         return template('message.html').render(
             title=self.context.title,
             heading="Thank you.",
             message="""
             Thank you for your request to use %s.
             Your request will be reviewed and, if approved, you
             will recieve an email with a link to set your
             password.""" % self.context.title,
         )
예제 #12
0
파일: __init__.py 프로젝트: zc/persona
    def run_app(env, start):
        request = webob.Request(env)

        token = request.cookies.get(TOKEN)
        old_email = email = None
        if token:
            try:
                email = serializer.loads(token)
            except itsdangerous.BadTimeSignature:
                pass # just don't log them in
            else:
                old_email = env.get('REMOTE_USER')
                env['REMOTE_USER'] = email

        try:
            if env['PATH_INFO'].startswith(prefix):
                return persona_app(env, start)
            else:
                needs_login = []
                def start_response(status, headers, exc_info=None):
                    if status.startswith("401 "):
                        needs_login.append(0)
                    else:
                        start(status, headers, exc_info)
                it = app(env, start_response)
                if needs_login:
                    return bobo.redirect(
                        prefix+'/login.html?came_from='+env['PATH_INFO']
                        )(env, start)
                else:
                    return it
        finally:
            if email:
                if old_email:
                    env['REMOTE_USER'] = old_email
                else:
                    del env['REMOTE_USER']
예제 #13
0
def login(bobo_request, where=None):
    if bobo_request.remote_user:
        return bobo.redirect(where or bobo_request.relative_url('.'))
    return webob.Response(status=401)
예제 #14
0
def query(short):
    if short in tcache:
        return bobo.redirect(str(tcache.get_value(short)))
    else:
        return webob.Response("not found, sorry", status=404)
예제 #15
0
 def logout(self):
     response = bobo.redirect('/auth/login')
     response.set_cookie(jwtauth.TOKEN, '')
     return response
예제 #16
0
파일: fswikia.py 프로젝트: jean/bobo
def save(bobo_request, name, body):
    with open(os.path.join(top, name), "wb") as f:
        f.write(body.encode('UTF-8'))
    return bobo.redirect(bobo_request.path_url, 303)
예제 #17
0
파일: fswikia.py 프로젝트: kilink/bobo
def authenticated(self, request, func):
    if not request.remote_user:
        return bobo.redirect(login_url(request))
예제 #18
0
def save(bobo_request, name, body):
    with open(os.path.join(top, name), "wb") as f:
        f.write(body.encode('UTF-8'))
    return bobo.redirect(bobo_request.path_url, 303)
예제 #19
0
 def login(self, request):
     return bobo.redirect('/auth/login')
예제 #20
0
def add(quote, name, city, state):
    rand = random.random()
    new_quote = Quotes(quote=quote, name=name, city=city,
                       state=state, rand=rand, location='0,0')
    new_quote.put()
    return bobo.redirect('/q/'+str(new_quote.key().id()))
예제 #21
0
def redirect():
    return bobo.redirect('/')
예제 #22
0
파일: fswiki.py 프로젝트: jean/bobo
def save(bobo_request, name, body):
    open(os.path.join(top, name), 'w').write(body)
    return bobo.redirect(bobo_request.path_url, 303)
예제 #23
0
파일: fswikia.py 프로젝트: kilink/bobo
def login(bobo_request, where=None):
    if bobo_request.remote_user:
        return bobo.redirect(where or bobo_request.relative_url('.'))
    return webob.Response(status=401)
예제 #24
0
def checker(inst, request, func):
    email = zc.wsgisessions.sessions.get(request, __name__, 'email')
    if not email:
        return bobo.redirect("/login.html")
예제 #25
0
def logout(bobo_request, where=None):
    response = bobo.redirect(where or bobo_request.relative_url('.'))
    response.delete_cookie('wiki')
    return response
예제 #26
0
def authenticated(self, request, func):
    if not request.remote_user:
        return bobo.redirect(login_url(request))
예제 #27
0
def save(bobo_request, name, body):
    open(os.path.join(top, name), 'w').write(body)
    return bobo.redirect(bobo_request.path_url, 303)
예제 #28
0
def lp(bobo_request, text):
	from subprocess import Popen
	from shlex import split
	open('tempfile','w').write('\n'+text.encode('ascii', 'replace'))
	Popen(split('lp tempfile -d Brother_QL-580N')).wait()
	return bobo.redirect('/printed')
예제 #29
0
파일: fswikia.py 프로젝트: kilink/bobo
def logout(bobo_request, where=None):
    response = bobo.redirect(where or bobo_request.relative_url('.'))
    response.delete_cookie('wiki')
    return response
예제 #30
0
 def base(self, bobo_request):
     return bobo.redirect(bobo_request.url + '/')
예제 #31
0
 def login(*_):
     return bobo.redirect(no_site_url)
예제 #32
0
파일: boboserver.py 프로젝트: kilink/bobo
 def base(self, bobo_request):
     return bobo.redirect(bobo_request.url+'/')
예제 #33
0
파일: index.py 프로젝트: thinserver/WebSC
def favicon():
	return bobo.redirect('/img/favicon.ico')