navigator-session 0.6.0__py3-none-any.whl → 0.6.3__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.
navigator_session/data.py CHANGED
@@ -1,9 +1,8 @@
1
1
  import uuid
2
2
  import time
3
3
  from typing import Union, Optional, Any
4
- from datetime import datetime
4
+ from datetime import datetime, timezone
5
5
  from collections.abc import Iterator, Mapping, MutableMapping
6
- import pendulum
7
6
  import jsonpickle
8
7
  from jsonpickle.unpickler import loadclass
9
8
  from aiohttp import web
@@ -25,11 +24,7 @@ class ModelHandler(jsonpickle.handlers.BaseHandler):
25
24
  def restore(self, obj):
26
25
  module_and_type = obj['py/object']
27
26
  mdl = loadclass(module_and_type)
28
- if hasattr(mdl, '__new__'):
29
- cls = mdl.__new__(mdl)
30
- else:
31
- cls = object.__new__(mdl)
32
-
27
+ cls = mdl.__new__(mdl) if hasattr(mdl, '__new__') else object.__new__(mdl)
33
28
  cls.__dict__ = self.context.restore(obj['__dict__'], reset=False)
34
29
  return cls
35
30
 
@@ -53,33 +48,29 @@ class SessionData(MutableMapping[str, Any]):
53
48
  self._changed = False
54
49
  self._data = {}
55
50
  # Unique ID:
56
- self._id_ = data.get(SESSION_ID, None) if data else id
57
- if not self._id_:
58
- self._id_ = uuid.uuid4().hex
51
+ self._id_ = (data.get(SESSION_ID, None) if data else id) or uuid.uuid4().hex
59
52
  # Session Identity
60
- self._identity = data.get(SESSION_KEY, None) if data else identity
61
- if not self._identity:
62
- self._identity = self._id_
53
+ self._identity = (
54
+ data.get(SESSION_KEY, None) if data else identity
55
+ ) or self._id_
63
56
  self._new = new if data != {} else True
64
- self._max_age = max_age if max_age else None
57
+ self._max_age = max_age or None
65
58
  created = data.get('created', None) if data else None
66
- self._now = pendulum.now('UTC') # time for this instance creation
59
+ self._now = datetime.now(timezone.utc)
67
60
  self.__created__ = self._now
68
61
  now = int(self._now.int_timestamp)
69
62
  self._now = now # time for this instance creation
70
63
  age = now - created if created else now
71
64
  if max_age is not None and age > max_age:
72
65
  data = None
73
- if self._new or created is None:
74
- self._created = now
75
- else:
76
- self._created = created
66
+ self._created = now if self._new or created is None else created
77
67
  ## Data updating.
78
68
  if data is not None:
79
69
  self._data.update(data)
80
70
  # Other mark timestamp for this session:
81
- dt = pendulum.now('UTC')
82
- self._dow = dt.day_of_week
71
+ dt = datetime.now(timezone.utc)
72
+ self._dow = dt.weekday()
73
+ self._doy = dt.timetuple().tm_yday
83
74
  self._time = dt.time()
84
75
  self.args = args
85
76
 
@@ -1,11 +1,13 @@
1
1
  """Navigator Session Meta information.
2
2
  Navigator Session allows us to store user-specific data into session object.
3
3
  """
4
-
5
4
  __title__ = 'navigator_session'
6
- __description__ = ('Navigator Session allows us to store user-specific data '
7
- 'into session object.')
8
- __version__ = '0.6.0'
5
+ __description__ = (
6
+ 'Navigator Session allows us to store user-specific data '
7
+ 'into session object.'
8
+ )
9
+ __version__ = '0.6.3'
10
+ __copyright__ = 'Copyright (c) 2023 Jesus Lara'
9
11
  __author__ = 'Jesus Lara'
10
12
  __author_email__ = 'jesuslarag@gmail.com'
11
13
  __license__ = 'Apache-2.0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: navigator-session
3
- Version: 0.6.0
3
+ Version: 0.6.3
4
4
  Summary: Navigator Session allows us to store user-specific data into session object.
5
5
  Home-page: https://github.com/phenobarbital/navigator-session
6
6
  Author: Jesus Lara
@@ -24,16 +24,15 @@ Classifier: Programming Language :: Python :: 3.11
24
24
  Classifier: Programming Language :: Python :: 3.12
25
25
  Classifier: Framework :: AsyncIO
26
26
  Classifier: Framework :: aiohttp
27
- Requires-Python: >=3.9.16
27
+ Requires-Python: >=3.9.13
28
28
  Description-Content-Type: text/markdown
29
29
  License-File: LICENSE
30
- Requires-Dist: aiohttp >=3.9.5
31
- Requires-Dist: uvloop ==0.19.0
32
- Requires-Dist: asyncio ==3.4.3
33
- Requires-Dist: jsonpickle >=3.0.2
34
- Requires-Dist: redis >=5.0.4
35
- Requires-Dist: python-datamodel >=0.2.1
36
- Requires-Dist: navconfig[default] >=1.6.3
30
+ Requires-Dist: aiohttp>=3.9.5
31
+ Requires-Dist: asyncio==3.4.3
32
+ Requires-Dist: jsonpickle>=3.0.2
33
+ Requires-Dist: redis>=5.0.4
34
+ Requires-Dist: python-datamodel>=0.7.0
35
+ Requires-Dist: navconfig[default]>=1.7.0
37
36
 
38
37
  # Navigator_Session #
39
38
 
@@ -1,15 +1,15 @@
1
1
  navigator_session/__init__.py,sha256=U1MtM30ccs5N6c_lzUYFRS5NURz6kheDC8jZmRL_2yc,3056
2
2
  navigator_session/conf.py,sha256=Pe8qsukmt5cXXPc3hwFphSWF5xCIpZfeFQ8JhICEnow,1695
3
- navigator_session/data.py,sha256=9bNj_tBGvyqOpcYP8MSKt--5DG5TlTIrYwbQYK7cfAM,6037
3
+ navigator_session/data.py,sha256=eokimbzdbAczhJuykNsVwa9KIcSoQYKcdKrtnSaHO_Y,5869
4
4
  navigator_session/middleware.py,sha256=_bQKfD81BxNZTGuyGTc4yh7y1Rb95I-y2hM1ihE4wCk,1944
5
5
  navigator_session/session.py,sha256=CG-TjsmQqjuk6N7GCYNgQTCkrXptgq-swHDiemgHmKI,2398
6
- navigator_session/version.py,sha256=N6sPpSUtraKYGwgN10X5nuZUoj-0nIuKu8709Z7EquQ,394
6
+ navigator_session/version.py,sha256=RJA3PjPrkm7lW5U1k0tsXio0eTMYhnFCuarQ8cgU8Jg,430
7
7
  navigator_session/storages/__init__.py,sha256=kTcHfqps5LmnDpFAktxevPuSIwRbnrcMmB7Uygq4axQ,34
8
8
  navigator_session/storages/abstract.py,sha256=wTv0yWMVXTwrzA_bjexcwI7c6_W3tzosXlMOIZIQrBM,6503
9
9
  navigator_session/storages/cookie.py,sha256=VILzVCatKlDhMoQDoE2y0u6s7lp4wbdep5Oc0NfIJcg,2474
10
10
  navigator_session/storages/redis.py,sha256=W-3I_hpabDToLOl7nVrIupV3Taf_IQUO_t8BP6EscYk,11506
11
- navigator_session-0.6.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- navigator_session-0.6.0.dist-info/METADATA,sha256=j2GJylJ5csGzsI__0pmCqh0xmQh8223niPIx7Ee_2dE,2339
13
- navigator_session-0.6.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
14
- navigator_session-0.6.0.dist-info/top_level.txt,sha256=ZpOEy3wLKGsxG2rc0nHqcqJCV3HIOG_XCfE6mtsYYYY,18
15
- navigator_session-0.6.0.dist-info/RECORD,,
11
+ navigator_session-0.6.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ navigator_session-0.6.3.dist-info/METADATA,sha256=m7y9yE9J0M72Kts678fvdnpl3LiuzbRatdZYQuAPtAc,2302
13
+ navigator_session-0.6.3.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
14
+ navigator_session-0.6.3.dist-info/top_level.txt,sha256=ZpOEy3wLKGsxG2rc0nHqcqJCV3HIOG_XCfE6mtsYYYY,18
15
+ navigator_session-0.6.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5