-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Active collection and active record patterns. #36
Comments
I've had an idea. My concerns over implementing the active record pattern primarily revolved around the widespread impact such an implementation would have, nearly everywhere. Custom However, for a "phase 1" implementation of basic operations such effort is not necessarily required. No modification tracking of the individual complex internal structures (still largely using basic types or explicitly compatible Document for PyMongo compatibility) but only tracking assignment and deletion operations. This should be an accomplishable first milestone. To that end, The document-level mix-in would need to implement a This
Only the most recent "major" operation will apply, as only one can be performed within a given update. |
Additional points from discussion today:
|
Factory tested in small-scale, it works: [edit to compactify and handle the edge case of one already mixed-in] class CachedMixinFactory(dict):
def __missing__(self, cls):
if issubclass(cls, _ActiveField): return cls
new_class = cls.__class__('Active' + cls.__name__, (cls, _ActiveField), {})
self[cls] = new_class
return new_class |
Now to test the example implementation… 👹 class _Active(Document):
__field_cache = CachedMixinFactory()
def __attributed__(self):
"""Automatically mix active behaviours into field instances used during declarative construction."""
for name, field in self.__attributes__:
field.__class__ = self.__field_cache[field] |
Active Record and Active Field mix-in behaviors, mostly a proof of concept.
Traits:
Collection — "Active Collection" features for management, such as collection and index creation; minimal, encouraging use of
get_collection()
and PyMongo methods where possible.Queryable — "Active Collection" bridging to "Active Record" where such proxying serves the purpose of translation from simplified Marrow Mongo concepts (such as parametric interpretation) and is demonstrably useful. Less minimal.
Discuss.
The text was updated successfully, but these errors were encountered: