def show_photos(self, aid, page = 0):
		c.u = utils
		c.album = s.query(Album).filter(Album.id == aid).first()
		if not c.album:
			abort(404)

		c.photos = self._get_photos(aid, page, "show_photos", 10)[1]

		return render("/photo-all.mako")
	def album_edit(self, aid):
		c.u = utils
		c.aid = aid
		c.new_album = False

		c.album = s.query(Album).filter(Album.id == aid).first()
		if not c.album:
			abort(404)

		return render('album_edit.mako')
	def index(self, aid, pid):
		photo_q = s.query(Photo)
		c.photo = photo_q.filter_by(album_id=aid, id=pid).first()

		if c.photo is None:
			abort(404)

		(c.idx, c.all, c.first, c.prev, c.next, c.last) = self._find_adj_photos(s, aid, pid)

		return render('/photo.mako')
	def show_page(self, aid, page):
		c.u = utils
		c.album = s.query(Album).filter(Album.id == aid).first()
		if not c.album:
			abort(404)

		c.albums = self._get_albums(aid, page)
		c.photos = self._get_photos(aid, page, "show_page", 16)[1]

		c.counts = self._get_counts(c.album)

		return render("/album.mako")
	def photo_del_submit(self, aid, pid):
		photo_q = s.query(Photo)
		photo_obj = photo_q.filter_by(album_id=aid, id=pid).first()
		if photo_obj is None:
			c.name = pid
			return render('/photo_not_found.mako')

		s.delete(photo_obj)
		s.commit()

		redirect(url(controller = "album",
					action = "show_first_page", aid = aid))
	def submit(self):
		"""
		Verify username and password
		"""

		if request.params.get("cancel"):
			redirect(url(controller="album", action = "index"))

		# Both fields filled?
		form_username = str(request.params.get('username')).lower()
		form_password = str(request.params.get('password'))

		if form_username != "dimak":
			return render('/login.mako')

		if md5.md5(password).hexdigest() != md5.md5(form_password).hexdigest():
			return render('/login.mako')

		# Mark user as logged in
		session['user'] = form_username
		session.save()

		redirect(url(controller="album", action = "index"))
	def get_photo_ajax(self, aid, pid):
		pid = int(pid)
		c.u = utils

		c.album = s.query(Album).filter(Album.id == aid).first()
		if not c.album:
			abort(404)

		all_ph, c.photos = self._get_photos(aid, 1, "show_page", 16)

		try:
			c.pnav = PhotosNav(all_ph, pid)
		except PhotosNavError:
			abort(404)

		return render("/album-getphoto.mako")
	def show_photo(self, aid, page, pid):
		pid = int(pid)
		c.u = utils
		c.album = s.query(Album).filter(Album.id == aid).first()
		if not c.album:
			abort(404)

		c.albums = self._get_albums(aid, page)
		all_ph, c.photos = self._get_photos(aid, page, "show_page", 16)

		try:
			c.pnav = PhotosNav(all_ph, pid)
		except PhotosNavError:
			abort(404)

		c.photo = c.pnav.photo
		c.counts = self._get_counts(c.album)

		return render("/album.mako")
    def new(self, format='html'):
        """GET /articles/new: Form to create a new item"""
        # url('new_article')
	return render("/article-edit.mako")
	def index(self):
		# Return a rendered template
		#return render('/sandbox.mako')
		# or, return a string
		return render("/sandbox.mako")
	def photo_edit(self, aid, pid):
		c.photo = s.query(Photo).filter_by(album_id=aid, id=pid)[0]
		
		return render('/photo_edit.mako')
	def photo_add(self, aid):
			return render("/photo_add.mako")
	def index(self):
		# Return a rendered template
		#   return render('/some/template.mako')
		# or, Return a response
		return render("/admin.mako")
	def album_add(self, aid):
		c.u = utils
		c.new_album = True
		c.album = Album()
		return render('album_edit.mako')
	def index(self):
		"""
		Show login form. Submits to /login/submit
		"""
		return render('/login.mako')