Google app engine - Python: How to use Namespaces and Ancestors? -


I am trying to understand how namespace and ancestors work in GAE. That's why I have made a simple multitainant "Todo List" application where every tenant is a user. That's why I've set names in appengine_config.py like this:

  dig namespace_merger_default_namespace_moder (): name = users Gate currentUser () The user_id () return name  

and then in my main.py , I manage such ideas:

  # Work with strong stability by giving them a parent DEFAULT_TASKS_ANCESTOR = ndb.Key ('agenda', 'default_agenda') class agenda (webpage 2. request): get def (self): name space = namespace_memiar.gate_name (location) = Task.kudi (Ancestors = DEFAULT_TASKS_ANCESTOR) Task = Tasks_how fetch (10, use_cache = False) Reference = { 'Work': Work, 'Name Location': Namespace,} Template = JINJA_ENVIRONMENT.get_template ('Templates / Work_Lic_HTML' ') self.response.write (template.render (context)) Def Post (self): name = cgi .escape (self.request.get ('name')) task = task (parent = DEFAULT_TASKS_ANCESTOR) task.name = name task.put () s Elf.redirect ('/ tasks_list')  

... and he gave a leak data:

  1. I logged in as a userA, then logged out as a separate user (userB) and Logged in again, and I could see that work from userA. I have confirmed from the admin panel that the work organizations are from different names and different from the ancestors because "there is a namespace in it?".

  2. I also stopped caching .fetch (10, use_cache = False) using . But the problem was still there, so it was not a caching problem.

  3. So finally I used to call .query () and .put () to parents and it worked! Such as: DEFAULT_TASKS_ANCESTOR = ndb.Key ('agenda', 'default_agenda') work_coreia = task.kudi (ancestors = DEFAULT_TASKS_ANCESTOR)

but now I have questions ...

  1. Why did this work? Since those working organizations do not share the same namespace, how can I ask data from any other namespace? Even if I accidentally ask for an ancestor from any other name, should I get the data? As DEFAULT_TASKS_ANCESTOR

  2. from DEFAULT_TASKS_ANCESTOR to namespace one namespace The same ancestor, or are they two completely different ancestors?

  3. Is the name space really pressing the data in the datastore or is it not?

  4. If the ancestors have played a big role in names places, do I still use the namespace or ancestors multitinant application?

Thank you in advance!


Comments