Closed adrienverge closed 4 years ago
My aim is that everything that "feels" like a document, should eventually have at least a similar interface like the Document class. Thus, 18ba9a10c27c97ff418d49000e290ad999526076 adds a new SecurityDocument, which is available as data.security()
.
Again, your solution is pretty neat, I like it!
However, I'm not a fan of these 2 lines inside SecurityDocument.fetch()
:
self.setdefault("members", {"names": [], "roles": []})
self.setdefault("admins", {"names": [], "roles": []})
because the user can choose to have just {members: {names: ["a", "b"]}}
or even {}
. It's supported by CouchDB, it's the default (a fresh database comes with nothing), and we use this to have lightweight shards (again, performance -- we operate 100k+ databases).
Do you think we could remove these lines, and adapt the helpers you write, e.g.
@property
def members(self):
- return self["members"]["names"]
+ return self.get("members", {}).get("names", [])
?
I see the idea, but the problem with that specific code is that its behavior is inconsistent and users can easily run into issues.
I think 4e3f045f3796aad7f9e10ee6534761dfd3024d6a is a good comprimise.
I think 4e3f045 is a good comprimise.
:+1:
Currently, trying to read or write
_security
document usingdb["_security"]
fails, because aiocouch tries to access it as a regular document. But_security
is special: it doesn't have_id
not_rev
(it's one of the only documents without revisions).I propose to implement wrappers to get and set this document:
PS: About the wording
get_security()
/set_security()
, your feedback is welcome!