horsemeat 2.22.13__tar.gz → 2.23.1__tar.gz

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.
Files changed (31) hide show
  1. {horsemeat-2.22.13 → horsemeat-2.23.1}/PKG-INFO +1 -1
  2. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/configwrapper.py +81 -14
  3. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/version.py +1 -1
  4. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/request.py +0 -22
  5. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat.egg-info/PKG-INFO +1 -1
  6. {horsemeat-2.22.13 → horsemeat-2.23.1}/requirements.txt +1 -0
  7. {horsemeat-2.22.13 → horsemeat-2.23.1}/MANIFEST.in +0 -0
  8. {horsemeat-2.22.13 → horsemeat-2.23.1}/README +0 -0
  9. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/__init__.py +0 -0
  10. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/model/__init__.py +0 -0
  11. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/model/newsmessage.py +0 -0
  12. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/model/session.py +0 -0
  13. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/model/user.py +0 -0
  14. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/pg.py +0 -0
  15. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/scripts/make-frippery-project +0 -0
  16. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/tests/__init__.py +0 -0
  17. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/tests/test_configwrapper.py +0 -0
  18. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/__init__.py +0 -0
  19. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/bogusrequest.py +0 -0
  20. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/dispatcher.py +0 -0
  21. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/framework_templates/__init__.py +0 -0
  22. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/frameworkhandlers.py +0 -0
  23. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/handler.py +0 -0
  24. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/response.py +0 -0
  25. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat/webapp/scrubber.py +0 -0
  26. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat.egg-info/SOURCES.txt +0 -0
  27. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat.egg-info/dependency_links.txt +0 -0
  28. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat.egg-info/requires.txt +0 -0
  29. {horsemeat-2.22.13 → horsemeat-2.23.1}/horsemeat.egg-info/top_level.txt +0 -0
  30. {horsemeat-2.22.13 → horsemeat-2.23.1}/setup.cfg +0 -0
  31. {horsemeat-2.22.13 → horsemeat-2.23.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: horsemeat
3
- Version: 2.22.13
3
+ Version: 2.23.1
4
4
  Summary: Web framework for the damned. The mad.
5
5
  Home-page: https://github.com/216software/horsemeat
6
6
  Author: 216 Software, LLC
@@ -3,6 +3,7 @@
3
3
  import abc
4
4
  import contextlib
5
5
  import datetime
6
+ import importlib
6
7
  import json
7
8
  import logging
8
9
  import logging.config
@@ -17,8 +18,9 @@ import warnings
17
18
 
18
19
  # import clepy
19
20
  import jinja2
20
- import pkg_resources
21
+ # import pkg_resources
21
22
  import psycopg2, psycopg2.extras
23
+ import psycopg
22
24
  import yaml
23
25
 
24
26
  from horsemeat import fancyjsondumps
@@ -77,9 +79,11 @@ class ConfigWrapper(object):
77
79
 
78
80
  else:
79
81
 
80
- stream = pkg_resources.resource_stream(
81
- cls.configmodule,
82
- filename)
82
+ stream = importlib.resources.files(cls.configmodule).joinpath(filename).open()
83
+
84
+ # stream = pkg_resources.resource_stream(
85
+ # cls.configmodule,
86
+ # filename)
83
87
 
84
88
  self = cls(
85
89
  yaml.safe_load(stream),
@@ -105,9 +109,11 @@ class ConfigWrapper(object):
105
109
 
106
110
  return self
107
111
 
108
- elif pkg_resources.resource_exists(
109
- cls.configmodule,
110
- path_to_file):
112
+ # elif pkg_resources.resource_exists(
113
+ # cls.configmodule,
114
+ # path_to_file):
115
+
116
+ elif importlib.resources.files(cls.configmodule).joinpath(path_to_file).exists():
111
117
 
112
118
  return cls.from_yaml_file_name(path_to_file)
113
119
 
@@ -185,7 +191,39 @@ class ConfigWrapper(object):
185
191
  def database_password(self):
186
192
  return self.config_dictionary['postgresql'].get('password')
187
193
 
188
- def make_database_connection(self, register_composite_types=True):
194
+ def make_psycopg_database_connection(self, register_composite_types=True):
195
+
196
+ """
197
+ This is NOT psycopg2, but psycopg3, which goes by psycopg.
198
+ """
199
+
200
+ if self.config_dictionary["postgresql"].get("psycopg_version") != "psycopg":
201
+
202
+ raise Exception("Add a 'psycopg_version' key under postgresql in your yaml file and set it to 'psycopg' to use this!")
203
+
204
+ else:
205
+
206
+ pgconn = psycopg.connect(
207
+ row_factory=psycopg.rows.namedtuple_row,
208
+ port=self.database_port,
209
+ dbname=self.database_name,
210
+ host=self.database_host,
211
+ user=self.database_user,
212
+ password=self.database_password)
213
+
214
+ log.info(f"Just made postgresql connection {pgconn} (composite types registered: {register_composite_types}.")
215
+
216
+ # psycopg2.extras.register_uuid()
217
+ # psycopg2.extras.register_hstore(pgconn, globally=True)
218
+ # psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
219
+ # psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
220
+
221
+ if register_composite_types:
222
+ self.register_psycopg_composite_types(pgconn)
223
+
224
+ return pgconn
225
+
226
+ def make_psycopg2_database_connection(self, register_composite_types=True):
189
227
 
190
228
  pgconn = psycopg2.connect(
191
229
  connection_factory=psycopg2.extras.NamedTupleConnection,
@@ -204,15 +242,40 @@ class ConfigWrapper(object):
204
242
  psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
205
243
 
206
244
  if register_composite_types:
207
- self.register_composite_types(pgconn)
245
+ self.register_psycopg2_composite_types(pgconn)
208
246
 
209
247
  return pgconn
210
248
 
249
+ def make_database_connection(self, register_composite_types=True):
250
+
251
+ """
252
+ Defaults to psycopg2, not the fancy newer psycopg, which is
253
+ really psycopg3.
254
+
255
+ Add a config entry to use the fancy one.
256
+ """
257
+
258
+ # Pretty quick, move to psycopg from psycopg2 but this is here
259
+ # until I get tests passing.
260
+ if self.config_dictionary["postgresql"].get("psycopg_version") != "psycopg":
261
+ 1/0
262
+ return self.make_psycopg2_database_connection(register_composite_types=register_composite_types)
263
+
264
+ else:
265
+ return self.make_psycopg_database_connection(register_composite_types=register_composite_types)
266
+
211
267
  # Make aliases because Matt can't remember stuff well.
212
268
  create_postgresql_connection = make_database_connection
213
269
  make_postgresql_connection = make_database_connection
214
270
 
215
- def register_composite_types(self, pgconn):
271
+ def register_psycopg_composite_types(self, pgconn):
272
+
273
+ """
274
+ Subclasses can define this if they want to.
275
+ """
276
+ pass
277
+
278
+ def register_psycopg2_composite_types(self, pgconn):
216
279
 
217
280
  """
218
281
  Subclasses can define this if they want to.
@@ -238,13 +301,17 @@ class ConfigWrapper(object):
238
301
 
239
302
  if isinstance(x, str):
240
303
 
241
- warnings.warn("Stop it! Define logging configuration "
304
+ warnings.warn("Stop it! Define logging configuration in"
242
305
  "the same YAML file!")
243
306
 
244
307
  logging.config.fileConfig(
245
- pkg_resources.resource_filename(
246
- 'horsemeat.configs.logging_configs',
247
- x))
308
+ importlib.resources.files('horsemeat').joinpath("configs").joinpath("logging_configs"),
309
+ x)
310
+
311
+ # logging.config.fileConfig(
312
+ # pkg_resources.resource_filename(
313
+ # 'horsemeat.configs.logging_configs',
314
+ # x))
248
315
 
249
316
  elif isinstance(x, dict):
250
317
  logging.config.dictConfig(x)
@@ -22,4 +22,4 @@ hasn't been installed yet.
22
22
 
23
23
  """
24
24
 
25
- __version__ = '2.22.13'
25
+ __version__ = '2.23.1'
@@ -537,28 +537,6 @@ class Request(collections.abc.MutableMapping):
537
537
  else:
538
538
  return 'UTF-8'
539
539
 
540
-
541
- def get_binder_id(self):
542
-
543
- if 'binder_id' in self:
544
- return self['binder_id']
545
-
546
- if 'binder_id' in self.wz_req.args:
547
- self['binder_id'] = int(self.wz_req.args['binder_id'])
548
- return self['binder_id']
549
-
550
- elif 'binder_id' in self.wz_req.form:
551
- self['binder_id'] = int(self.wz_req.form['binder_id'])
552
- return self['binder_id']
553
-
554
- elif self.global_session_data \
555
- and 'binder_id' in self.global_session_data:
556
- self['binder_id'] = self.global_session_data['binder_id']
557
- return self['binder_id']
558
-
559
- else:
560
- raise ValueError('Sorry, could not figure out binder ID')
561
-
562
540
  @property
563
541
  def json(self):
564
542
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: horsemeat
3
- Version: 2.22.13
3
+ Version: 2.23.1
4
4
  Summary: Web framework for the damned. The mad.
5
5
  Home-page: https://github.com/216software/horsemeat
6
6
  Author: 216 Software, LLC
@@ -6,3 +6,4 @@ psycopg2>=2.7
6
6
  # clepy>=0.3.23
7
7
  nose>=1.3.3
8
8
  gunicorn
9
+ psycopg
File without changes
File without changes
File without changes
File without changes
File without changes