Ejemplo n.º 1
0
            
            if len(dists) != 1:
                form = add_zip4(form)
                return self.GET(form)
            
            dist = dists[0]    
            captcha = ('captcha' not in i) and writerep.get_captcha_src(dist)
            if captcha: 
                form = add_captcha(form, captcha)
                return self.GET(form) 
                
            msg_sent = writerep.writerep(district=dist, **i)
            if msg_sent: helpers.set_msg('Your message has been sent.')
            raise web.seeother('/writerep')
        else:
            return self.GET(form)        
            

class staticdata:
    def GET(self, path):
        if not web.config.debug:
            raise web.notfound

        assert '..' not in path, 'security'
        return file('data/' + path).read()
        
app = web.application(urls, globals())
settings.setup_session(app)
            
if __name__ == "__main__": app.run()
Ejemplo n.º 2
0
            ipaddr=web.ctx.env['REMOTE_ADDR'])

        return web.seeother('/%s' % (n,))
    
class view:
    def GET(self, n):
        res = db.select('pastes', where='id=$n', vars=locals())
        db.update('pastes', where='id=$n',vars=locals(), lastview=now_time())
        if res: 
            return render.view(res[0],n)
        else:
            return web.notfound()

class copy:
    def GET(self,n):
        title = session.get('title', '')
        name = session.get('name', '')
        print 'title, name: ', title, name, '<--'
        
        res = db.select('pastes', where='id=$n', vars=locals())
        if res: 
            return render.index(src=res[0].source, title=title, name=name)
        else:
            return web.notfound()
        
        
app = web.application(urls, globals())
setup_session(app)
application = app.wsgifunc()
if __name__ == "__main__": 
    app.run()