def invite(self): if request.POST: who = request.params['who'] c.code = ''.join(random.choice(string.letters + string.digits) for i in xrange(32)) invite = Invite(who, c.code) Session.begin() Session.add(invite) Session.commit() return render('/display-invite.html') else: return render('/create-invite.html')
def index(self): c.cname = "music" c.cdesc = "a collection of requests to manipulate, broadcast, and augment the 'music' database" c.methods = [{'n':'addtracks','d':'add tracks living in the music directory.'}, {'n':'addmeta','d':'for all tracks that have been added, add in metadata from musicbrainz.'} ] return render('describe_controller.mako')
def index(self): # Return a rendered template #return render('/init.mako') # or, return a response #qc.autoset('sb_address') c.sb_address=qc.query('sb_address') c.sb_port=qc.query('sb_port') return render('init_index.mako')
def index(self): c.cname = "queries" c.cdesc = "a collection of prepacked queries that will return json" c.methods = [{'n':'getFriends','d':'add tracks living in the music directory.'}, {'n':'getLocalMusic','d':'A list of tracks on this computer.'}, {'n':'getFriendsMusic','d':'A list of tracks on friends computers.'} ] return render('describe_controller.mako')
def pp2(self): artists = Session.query(Artist) tracks = Session.query(Track) paths = [] for r in tracks: paths.append( os.path.join('.media', r.filepath )) return render('/hello2.html')
def index(self): # Return a rendered template #return render('/friends.mako') # or, return a response c.cname = "friends" c.cdesc = "a collection of requests to manipulate, broadcast, and augment the 'friends' database" c.methods = [{'n':'addknown','d':'adds a seed friend at swiftway'}, {'n':'list','d':'list current friends'}, {'n':'friendallknown','d':'add currently known server to friends'}, {'n':'annoucetoall','d':'::stub::'}, {'n':'hearabout','d':'called by a remote serve to announce itself'} ] return render('describe_controller.mako')
def index(self): # Return a rendered template # return render('/plug.mako') # or, return a responsels t w = sh.wrap("config") d = w.queryToDict( "select plugin.name as name, user.name as uname from plugin, user where user.id = plugin.user;" ) print d c.pluglist = map(lambda x: str(x["name"]), d) c.plugnames = map(lambda x: str(x["uname"]), d) c.cname = "plug" c.cdesc = "Plugin html interface" c.methods = [{"n": "blank", "d": "none yet"}] jsfiles = ["jquery"] rendered0 = sh.sourced_js(jsfiles, True) rendered = rendered0 + render("/plug_list.mako") rendered = rendered + render("/describe_controller.mako") return rendered
def index(self): c.playsEver, c.ipsEver = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).one() c.plays7d, c.ips7d = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=7)).one() c.plays24h, c.ips24h = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=1)).one() c.plays1h, c.ips1h = Session.query(func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(hours=1)).one() statsEver = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).all() stats7d = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=7)).all() stats24h = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(days=1)).all() stats1h = Session.query(User.user_name, func.count(TrackPlay.id), func.count(distinct(TrackPlay.ip))).outerjoin(TrackPlay).group_by(User.user_name).filter(TrackPlay.timestamp > datetime.utcnow() - timedelta(hours=1)).all() stats = {} for uname, count, ipcount in statsEver: stats[uname] = {'user':uname, 'countEver':count, 'ipEver':ipcount, 'count7d':0, 'ip7d':0, 'count24h':0, 'ip24h':0, 'count1h':0, 'ip1h':0} for uname, count, ipcount in stats7d: stats[uname].update({'count7d':count, 'ip7d':ipcount}) for uname, count, ipcount in stats24h: stats[uname].update({'count24h':count, 'ip24h':ipcount}) for uname, count, ipcount in stats1h: stats[uname].update({'count1h':count, 'ip1h':ipcount}) statlist = stats.values() statlist.sort(key=itemgetter('countEver'), reverse=True) c.stats = statlist return render('/stats.html')
def register(self, code): invite = Session.query(Invite).filter_by(code=code).first() if invite is None: return 'Your registration code appears to be invalid.' c.code = code return render('/register.html')
def login(self): return render('login.html')
def index(self): c.username = request.environ['repoze.what.credentials']['repoze.what.userid'] c.admin = 'admins' in request.environ['repoze.what.credentials']['groups'] return render('/hello.html')
def i2g(self): return render('/h2grav.html')
def i2(self): return render('/h2player.html')
def index(self): return render('/hello2.html')
def index(self): c.all_controllers=['/music', '/friends', '/init'] return render('main_index.mako')
def index(self): return render('/rosa_template.html')
def all(self): c.urls=['/music/addtracks', '/music/addmeta', '/friends/addknown', '/friends/friendallknown'] return render('init_all.mako')
def serveMako(self, name): c.username = sh.unameFromCookie(request.cookies["authkit"]) return render(name + ".mako")
def demo(self): return render('/isdemo.html')