Example #1
0
class ProfileUpdate(View):
    """ After login target.  Refreshes the player profile of the
        current user, creating it first if necessary.  Redirects the
        user to either their profile page or to the page from which
        they came.
    """
    def get(self):
	user = users.get_current_user()
	try:
	    profile = PlayerProfile.build(user)
	    profile.refresh()
	except (Exception, ), exc:
    	    error('player profile refresh: %s', exc)
	    self.error(500)
	else:
	    paths = self.request.environ['PATH_INFO'].split('/')
	    redirect_url = '/profile/%s' % (user.nickname(), )
	    if len(paths) == 3:
		try:
		    redirect_url = paths[-1].decode('base64')
		except (Exception, ), exc:
		    error('player profile redirect decoding exception: %s', exc)
	    self.redirect(redirect_url)


main = View.make_main(ProfileUpdate)


if __name__ == '__main__':
    main()
Example #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tf2auctions.lib import View


class NotFound(View):
    """ Final catchall handler configured in app.yaml.  Sends 404 and
        a nice error page.
    """
    template_name = '404.pt'

    def get(self):
	self.error(404)
	self.render()


main = View.make_main(NotFound)


if __name__ == '__main__':
    main()
Example #3
0
from tf2auctions.models import Listing


class ListingDetailView(View):
    """ Returns a page for showing the details of a listing.

    """
    template_name = 'listing_detail.pt'
    related_css = (View.jq_ui_css, 'listing_detail.css', )
    related_js = (View.jq_ui, 'listing_detail.js', )

    def get(self):
	try:
	    key = db.Key.from_path('Listing', int(self.path_tail()))
	    exists = Listing.all(keys_only=True).filter('__key__', key).get()
	except (Exception, ), exc:
	    self.error(500)
	else:
	    if exists:
		self.render()
	    else:
		self.error(404)
		self.render(self.template('404.pt'))


main = View.make_main(ListingDetailView)


if __name__ == '__main__':
    main()