appier 1.34.6__py2.py3-none-any.whl → 1.34.8__py2.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.
appier/model.py CHANGED
@@ -354,6 +354,7 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
354
354
  safe=True,
355
355
  build=False,
356
356
  fill=True,
357
+ fill_safe=False,
357
358
  new=True,
358
359
  **kwargs
359
360
  ):
@@ -395,7 +396,11 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
395
396
  injected into the resulting instance.
396
397
  :type fill: bool
397
398
  :param fill: If the various attributes of the model should be "filled"
398
- with default values (avoiding empty values).
399
+ with default values (avoiding empty values), not going to be applied to
400
+ safe attributes.
401
+ :type fill_safe: bool
402
+ :param fill_safe: If the safe values should also be "filled" meaning that
403
+ they are initialized in a forced "way".
399
404
  :type new: bool
400
405
  :param new: In case this value is valid the resulting instance is expected
401
406
  to be considered as new meaning that no identifier attributes are set.
@@ -408,7 +413,7 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
408
413
  model = util.get_object() if form else dict(kwargs)
409
414
  if fill:
410
415
  model = cls.fill(model, safe=not new)
411
- instance = cls(fill=False)
416
+ instance = cls(fill=fill_safe)
412
417
  instance.apply(model, form=form, safe_a=safe)
413
418
  if build:
414
419
  cls.build(instance.model, map=False)
appier/mongo.py CHANGED
@@ -29,6 +29,7 @@ __license__ = "Apache License, Version 2.0"
29
29
  """ The license for the module """
30
30
 
31
31
  import json
32
+ import logging
32
33
 
33
34
  from . import util
34
35
  from . import legacy
@@ -385,3 +386,26 @@ def _motor(verify=True):
385
386
  exception=exceptions.OperationalError,
386
387
  )
387
388
  return motor.motor_asyncio
389
+
390
+
391
+ def _patch_logging():
392
+ """
393
+ Patch the logging settings for the pymongo library, so
394
+ that it does not interfere with the application's logging.
395
+ """
396
+
397
+ pymongo_logger = logging.getLogger("pymongo")
398
+ pymongo_logger.propagate = False
399
+ pymongo_logger.setLevel(logging.INFO)
400
+
401
+ handler = logging.StreamHandler()
402
+ formatter = logging.Formatter("%(asctime)s [%(levelname)s] [%(name)s] %(message)s")
403
+ handler.setFormatter(formatter)
404
+
405
+ for handler in pymongo_logger.handlers:
406
+ pymongo_logger.removeHandler(handler)
407
+
408
+ pymongo_logger.addHandler(handler)
409
+
410
+
411
+ _patch_logging()