Reputation: 69
Is there any technique for partitioning data other than namespaces? I need to split data for every group of user, but some admin users should see all data and namespaces blocks for everyone.
Upvotes: 0
Views: 138
Reputation: 126
I have a multitenant app where each namespace has it's own admin. But, like you, I would like to have a super admin that could acces any namespace and execute all procedures that the namespace admin can.
So I have createded one admin Entity for each namespace, but i have created an Super Admin Entity on the empty namespace. So I use the default (empty) namespace to store global entities. By doing this you just have to set the namespace to empty before looking for Super Admins an must to be careful to set the original namesmpace.
YourHandler(RequestHandler):
original_ns=namespace_manager.get_namespace()
namespace_manager.set_namespace("")
#Look for Super Admin Here
...
# Return to original ns
namespace_manager.set_namespace(original_ns)
Of course I put this kind of security code in decorators to reuse it through all aplication, but thing the above code is easier to understand.
Upvotes: 1
Reputation: 1149
Did you try ancestor paths? This is what we use instead of namespaces for the exact same reason. We also add entities that serve as folders for whatever data you need to group. So for example: We have an Subscriber entity and we have added a label called Users which is a child of Subscriber. All User entities that belong to a specific instance of the subscriber, we add to that Users label. An ancestor query on the Subscriber can be used to return all entities, including the Subscriber, Label and User entities.
https://developers.google.com/appengine/docs/python/datastore/entities#Ancestor_Paths
Upvotes: 1