autonomous-app 0.3.3__py3-none-any.whl → 0.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
autonomous/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.3"
1
+ __version__ = "0.3.4"
2
2
 
3
3
  from dotenv import load_dotenv
4
4
 
@@ -338,12 +338,15 @@ class ComplexBaseField(BaseField):
338
338
  @staticmethod
339
339
  def _lazy_load_refs(instance, name, ref_values, *, max_depth):
340
340
  _dereference = _import_class("DeReference")()
341
+ # log("_lazy_load_refs", _dereference)
342
+ # MARK: PROBLEM
341
343
  documents = _dereference(
342
344
  ref_values,
343
345
  max_depth=max_depth,
344
346
  instance=instance,
345
347
  name=name,
346
348
  )
349
+
347
350
  return documents
348
351
 
349
352
  def __set__(self, instance, value):
@@ -365,14 +368,14 @@ class ComplexBaseField(BaseField):
365
368
  # Document class being used rather than a document object
366
369
  return self
367
370
 
368
- ReferenceField = _import_class("ReferenceField")
371
+ # ReferenceField = _import_class("ReferenceField")
369
372
  GenericReferenceField = _import_class("GenericReferenceField")
370
373
  # EmbeddedDocumentListField = _import_class("EmbeddedDocumentListField")
371
374
 
372
375
  auto_dereference = instance._fields[self.name]._auto_dereference
373
376
  dereference = auto_dereference and (
374
- self.field is None
375
- or isinstance(self.field, (GenericReferenceField, ReferenceField))
377
+ self.field is None or isinstance(self.field, GenericReferenceField)
378
+ # or isinstance(self.field, (GenericReferenceField, ReferenceField))
376
379
  )
377
380
 
378
381
  if (
@@ -382,11 +385,9 @@ class ComplexBaseField(BaseField):
382
385
  and not getattr(instance._data[self.name], "_dereferenced", False)
383
386
  ):
384
387
  ref_values = instance._data.get(self.name)
385
- # log(f"Lazy loading refs for {self.name}: {ref_values}")
386
388
  instance._data[self.name] = self._lazy_load_refs(
387
389
  ref_values=ref_values, instance=instance, name=self.name, max_depth=1
388
390
  )
389
- # log(f"Lazy loading results: {instance._data[self.name]}")
390
391
  if hasattr(instance._data[self.name], "_dereferenced"):
391
392
  instance._data[self.name]._dereferenced = True
392
393
  value = super().__get__(instance, owner)
@@ -416,7 +417,6 @@ class ComplexBaseField(BaseField):
416
417
  )
417
418
  value._dereferenced = True
418
419
  instance._data[self.name] = value
419
- # log(f"Value: {value}")
420
420
  return value
421
421
 
422
422
  def to_python(self, value):
@@ -13,7 +13,7 @@ from autonomous.db.connection import get_db
13
13
  from autonomous.db.document import Document, EmbeddedDocument
14
14
  from autonomous.db.fields import (
15
15
  DictField,
16
- GenericReferenceField,
16
+ # GenericReferenceField,
17
17
  ListField,
18
18
  MapField,
19
19
  ReferenceField,
@@ -180,7 +180,6 @@ class DeReference:
180
180
  refs = [
181
181
  dbref for dbref in dbrefs if (collection, dbref) not in object_map
182
182
  ]
183
- # log(doc_type)
184
183
  if isinstance(doc_type, Document):
185
184
  references = doc_type._get_db()[collection].find(
186
185
  {"_id": {"$in": refs}}
@@ -225,9 +224,14 @@ class DeReference:
225
224
 
226
225
  if isinstance(items, (dict, SON)):
227
226
  if "_ref" in items:
228
- return self.object_map.get(
229
- (items["_ref"].collection, items["_ref"].id), items
227
+ # MARK: Changed this to remove deleted references
228
+ # result = self.object_map.get(
229
+ # (items["_ref"].collection, items["_ref"].id), items
230
+ # )
231
+ result = self.object_map.get(
232
+ (items["_ref"].collection, items["_ref"].id)
230
233
  )
234
+ return result
231
235
  elif "_cls" in items:
232
236
  doc = get_document(items["_cls"])._from_son(items)
233
237
  _cls = doc._data.pop("_cls", None)
autonomous/db/fields.py CHANGED
@@ -36,7 +36,8 @@ from autonomous.db.base import (
36
36
  get_document,
37
37
  )
38
38
  from autonomous.db.base.utils import LazyRegexCompiler
39
- from autonomous.db.common import _import_class
39
+
40
+ # from autonomous.db.common import _import_class
40
41
  from autonomous.db.connection import DEFAULT_CONNECTION_NAME, get_db
41
42
  from autonomous.db.document import Document, EmbeddedDocument
42
43
  from autonomous.db.errors import (
@@ -927,15 +928,14 @@ class ListField(ComplexBaseField):
927
928
  if instance is None:
928
929
  # Document class being used rather than a document object
929
930
  return self
930
- value = instance._data.get(self.name)
931
- LazyReferenceField = _import_class("LazyReferenceField")
932
- GenericLazyReferenceField = _import_class("GenericLazyReferenceField")
933
- if (
934
- isinstance(self.field, (LazyReferenceField, GenericLazyReferenceField))
935
- and value
936
- ):
937
- instance._data[self.name] = [self.field.build_lazyref(x) for x in value]
938
-
931
+ # value = instance._data.get(self.name)
932
+ # LazyReferenceField = _import_class("LazyReferenceField")
933
+ # GenericLazyReferenceField = _import_class("GenericLazyReferenceField")
934
+ # if (
935
+ # isinstance(self.field, (LazyReferenceField, GenericLazyReferenceField))
936
+ # and value
937
+ # ):
938
+ # instance._data[self.name] = [self.field.build_lazyref(x) for x in value]
939
939
  return super().__get__(instance, owner)
940
940
 
941
941
  def validate(self, value):
@@ -12,6 +12,7 @@ from pymongo.collection import ReturnDocument
12
12
  from pymongo.common import validate_read_preference
13
13
  from pymongo.read_concern import ReadConcern
14
14
 
15
+ from autonomous import log
15
16
  from autonomous.db import signals
16
17
  from autonomous.db.base import get_document
17
18
  from autonomous.db.common import _import_class
@@ -785,7 +786,6 @@ class BaseQuerySet:
785
786
  doc,
786
787
  _auto_dereference=self._auto_dereference,
787
788
  )
788
-
789
789
  return doc_map
790
790
 
791
791
  def none(self):
@@ -8,7 +8,6 @@ from autonomous.db.fields import (
8
8
  EnumField,
9
9
  FileField,
10
10
  FloatField,
11
- GenericLazyReferenceField,
12
11
  GenericReferenceField,
13
12
  ImageField,
14
13
  IntField,
@@ -59,51 +58,27 @@ class ReferenceAttr(GenericReferenceField):
59
58
  return result
60
59
 
61
60
 
62
- # class ReferenceAttr(GenericLazyReferenceField):
63
- # def __get__(self, instance, owner):
64
- # try:
65
- # result = super().__get__(instance, owner)
66
- # except DoesNotExist as e:
67
- # log(f"ReferenceAttr Error: {e}")
68
- # return None
69
- # return result.fetch() if result and result.pk else result
70
-
71
- # except DoesNotExist:
72
- # If the document doesn't exist, return None
73
- # return None
74
-
75
- # def validate(self, value):
76
- # if value is not None and not self.required:
77
- # super().validate(value)
78
-
79
-
80
61
  class ListAttr(ListField):
81
- # pass
82
62
  def __get__(self, instance, owner):
83
- # log(instance, owner)
84
63
  results = super().__get__(instance, owner) or []
85
- # print(self.name, self.field, owner, results)
86
64
  if isinstance(self.field, ReferenceAttr):
87
65
  i = 0
88
66
  while i < len(results):
89
67
  try:
90
68
  if not results[i]:
91
- log(f"Removing Object: {results[i]}")
69
+ # log(f"Removing Object: {results[i]}")
92
70
  results.pop(i)
93
71
  else:
94
72
  i += 1
95
73
  except DoesNotExist:
96
74
  results.pop(i)
97
- log(f"Object Not Found: {results[i]}")
98
- # log(results)
75
+ # log(f"Object Not Found: {results[i]}")
99
76
  return results
100
77
 
101
78
 
102
79
  class DictAttr(DictField):
103
80
  def __get__(self, instance, owner):
104
- # log(instance, owner)
105
81
  results = super().__get__(instance, owner) or {}
106
- # log(self.name, self.field, owner, results)
107
82
  for key, lazy_obj in results.items():
108
83
  try:
109
84
  if hasattr(lazy_obj, "fetch"):
@@ -54,15 +54,16 @@ class AutoModel(Document):
54
54
  def _auto_post_init(cls, sender, document, **kwargs):
55
55
  sender.auto_post_init(sender, document, **kwargs)
56
56
 
57
- @classmethod
58
- def model_name(cls, qualified=False):
57
+ def model_name(self, qualified=False):
59
58
  """
60
59
  Get the fully qualified name of this model.
61
60
 
62
61
  Returns:
63
62
  str: The fully qualified name of this model.
64
63
  """
65
- return f"{cls.__module__}.{cls.__name__}" if qualified else cls.__name__
64
+ return (
65
+ f"{self.__module__}.{self._class_name}" if qualified else self._class_name
66
+ )
66
67
 
67
68
  @classmethod
68
69
  def load_model(cls, model):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autonomous-app
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Containerized application framework built on Flask with additional libraries and tools for rapid development of web applications.
5
5
  Author-email: Steven A Moore <samoore@binghamton.edu>
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- autonomous/__init__.py,sha256=wCfQNGBJhN4rEvMfAPaMaJATBVzi6ntQbyINkZejQmA,94
1
+ autonomous/__init__.py,sha256=PXtARBHI2SI4uEosl5txLwFG6uKDSvdFvTt3Hp13pd4,94
2
2
  autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
3
3
  autonomous/logger.py,sha256=NQtgEaTWNAWfLSgqSP7ksXj1GpOuCgoUV711kSMm-WA,2022
4
4
  autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -23,10 +23,10 @@ autonomous/db/__init__.py,sha256=9frkXJrl_OUemUQteXCTPqC8ECyxjE91Gi2mgTq26Fw,115
23
23
  autonomous/db/common.py,sha256=BUN2x_XuQBRFcq54TGPx4yLMLJdgytdbIt07QWr4CSM,2551
24
24
  autonomous/db/connection.py,sha256=IhfJ8H5SZ44z7ptEez3T8QUPk88en9s3y9eKIpnIfg4,17747
25
25
  autonomous/db/context_managers.py,sha256=_nH2ajCL8Xy90AuB2rKaryR4iF8Q8ksU3Nei_mZj-DE,9918
26
- autonomous/db/dereference.py,sha256=Q_LkFwG5Be8XFKuwgvOIMb87R1DpavFbCOV2HdJV56Q,12573
26
+ autonomous/db/dereference.py,sha256=EgbpPCXtDZqD_ZuY1Wd4o3ltRy8qEo3C5yRh5_c9fLE,12776
27
27
  autonomous/db/document.py,sha256=PGbCbkx3Los4zOj0Da6YcLCv_rR-xXp_7X6qivjAsL4,44429
28
28
  autonomous/db/errors.py,sha256=_QeCotid1kmr7_W0QyH6NUrwwYN9eced_yyyiop0Xlw,4108
29
- autonomous/db/fields.py,sha256=kK1uGXyjjQwEDf1YFIfebCpA7wFnl-epudfXHI57lKo,93747
29
+ autonomous/db/fields.py,sha256=bAF2LSJ4Ys-eY89rKp1C9jIJjqtQnuDHNyig1tidSrc,93765
30
30
  autonomous/db/mongodb_support.py,sha256=u0X-zpqTIZZP8o2-IDyKRKHL8ALLhvW1VSGtK3fLyos,626
31
31
  autonomous/db/pymongo_support.py,sha256=UEZ4RHAGb_t1nuMUAJXMNs0vdH3dutxAH5mwFCmG6jI,2951
32
32
  autonomous/db/signals.py,sha256=BM-M4hh4SrTbV9bZVIEWTG8mxgKn9Lo2rC7owLJz4yQ,1791
@@ -34,27 +34,27 @@ autonomous/db/base/__init__.py,sha256=qbVw-SlbJxlWu8UoPLQcwyRQ7Oso0r3aUit6Jqpoz4
34
34
  autonomous/db/base/common.py,sha256=YjvDGwmn-QoRplL9Xx2q3eUXEetgo3YureIGxbR36Y8,1540
35
35
  autonomous/db/base/datastructures.py,sha256=fcgWe2JsfzTK3jbku3Teh0Iwvn5U5EhCpyeh9xr8bZ0,15850
36
36
  autonomous/db/base/document.py,sha256=OM7CeJFZbxha6yKMiMCrHOlTELfOXusqJ8i6FjdFd0c,46652
37
- autonomous/db/base/fields.py,sha256=c_FO9mryhdqzv4NdM1TnEl4WDoopy46I9UF1L8MVFFw,29146
37
+ autonomous/db/base/fields.py,sha256=o5XSMYm3NnpU5uw1hvqFFAZHcmJJwWxgwB_hq4sHkPI,29096
38
38
  autonomous/db/base/metaclasses.py,sha256=GVvJYcCxaW1ltEqyH4oNvT_srckEXDSHOtHVU_TAN70,18138
39
39
  autonomous/db/base/utils.py,sha256=MH4FuEwh-5IcIinwNTkyTs-PqQLyyiMctcYMsNP85qk,617
40
40
  autonomous/db/queryset/__init__.py,sha256=XT3__0BJCvQIQj3S_Mp7mPxNBkfdvXkdw56cg2gc86o,756
41
- autonomous/db/queryset/base.py,sha256=aTq4C3K_YP8H6eE_HHn82C8I81l8uw1w0EPmCzcS7HM,76077
41
+ autonomous/db/queryset/base.py,sha256=RjxzR55i7pfj9yntMZ_dSTbXp0Ik6HA57tdQFCWXXk8,76103
42
42
  autonomous/db/queryset/field_list.py,sha256=qY50kgMYzloZXrOXnWT0PS_fBJCoThSioRvW9-HmhYA,2964
43
43
  autonomous/db/queryset/manager.py,sha256=fXu95TlGChdJWTRA4OnY_Ik25JzezJ2_qPqmH78xJsY,2238
44
44
  autonomous/db/queryset/queryset.py,sha256=Xvt1q7Olij9STbJkHm6dKrUIrgyJeY_uwJOYE9WUZvk,5942
45
45
  autonomous/db/queryset/transform.py,sha256=UhBdDxYR_bWH0ECnaSw9g9YMwgWRZtsRl_q6PkqO9eY,19615
46
46
  autonomous/db/queryset/visitor.py,sha256=AN09lR6hWYUlKJC7G1sktvnWy5hrFnpoQhi58bOXbA4,5470
47
47
  autonomous/model/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
48
- autonomous/model/autoattr.py,sha256=7yLhkohTxGseOYhOJ_oDT1QD56UWhHEVdXP5yEsBJZE,2822
49
- autonomous/model/automodel.py,sha256=cEII68skKHSCbxx9-BTY9wLBkqvJeMceXku5F9bxhwc,6792
48
+ autonomous/model/autoattr.py,sha256=ouNOrVLLgt8AS955ly4XO1mBat99mznNCd9_AEzFse0,2049
49
+ autonomous/model/automodel.py,sha256=Q5S84TsIXZT4r0AFQS6OQm4oRIMPWWfuUhD0i5gsm7s,6809
50
50
  autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  autonomous/storage/imagestorage.py,sha256=SmBjBNBlP1ZEjxdOnGVzCHZhbEhMKTUQC2TbpWbejDE,6168
52
52
  autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
53
53
  autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
54
54
  autonomous/tasks/autotask.py,sha256=aK5iapDhgcAic3F5ZYMAhNKJkOepj8yWwbMizKDzUwQ,4153
55
55
  autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
56
- autonomous_app-0.3.3.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
57
- autonomous_app-0.3.3.dist-info/METADATA,sha256=IX1zBDszQLS3hAHqZVyZaX7Y1MShWWL786_3JGBv8Zw,4188
58
- autonomous_app-0.3.3.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
59
- autonomous_app-0.3.3.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
60
- autonomous_app-0.3.3.dist-info/RECORD,,
56
+ autonomous_app-0.3.4.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
57
+ autonomous_app-0.3.4.dist-info/METADATA,sha256=PnZvIHS6gyyxRBHJ7hvet23VdAp7gxkfP7sCd4EqD6Q,4188
58
+ autonomous_app-0.3.4.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
59
+ autonomous_app-0.3.4.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
60
+ autonomous_app-0.3.4.dist-info/RECORD,,