Exemple #1
0
	def get(self):
		user = users.get_current_user()
		if user:
			nickname = user.nickname()
		else:
			nickname = None

		workspaces = Workspace.gql("WHERE user = :1", user)
		params = {
			"sign_in_url": users.create_login_url("/"),
		    "sign_out_url": users.create_logout_url("/"),
		    "nickname": nickname,
		    "workspaces": workspaces,
		    "add_workspace_url": "/"
		}
		self.response.out.write(template.render("templates/main.html", params))
 def get(self, *args):
     if not len(args):
         user = users.get_current_user()
         workspaceList = Workspace.gql("WHERE user = :1", user)
         data = {}
         for w in workspaceList:
             data[w.id] = w.json
         res = json.dumps(data, indent=4)
         self.error(200)
         self.response.out.write(res)
     elif len(args) == 1:
         ws = Workspace.get("WHERE name = :1", args[0])
         if not ws:
             self.response.out.write("{}")
             return
         data = {ws.id: ws.json}
         res = json.dumps(data, indent=4)
         self.error(200)
         self.response.out.write(res)
         return
     else:
         raise NotImplemented("WorkspaceQuery does not expect more than one parameter")