horsemeat 2.22.12__tar.gz → 2.23.0__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.12 → horsemeat-2.23.0}/PKG-INFO +1 -1
  2. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/configwrapper.py +60 -3
  3. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/version.py +1 -1
  4. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat.egg-info/PKG-INFO +1 -1
  5. {horsemeat-2.22.12 → horsemeat-2.23.0}/requirements.txt +1 -0
  6. {horsemeat-2.22.12 → horsemeat-2.23.0}/MANIFEST.in +0 -0
  7. {horsemeat-2.22.12 → horsemeat-2.23.0}/README +0 -0
  8. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/__init__.py +0 -0
  9. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/model/__init__.py +0 -0
  10. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/model/newsmessage.py +0 -0
  11. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/model/session.py +0 -0
  12. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/model/user.py +0 -0
  13. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/pg.py +0 -0
  14. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/scripts/make-frippery-project +0 -0
  15. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/tests/__init__.py +0 -0
  16. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/tests/test_configwrapper.py +0 -0
  17. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/__init__.py +0 -0
  18. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/bogusrequest.py +0 -0
  19. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/dispatcher.py +0 -0
  20. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/framework_templates/__init__.py +0 -0
  21. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/frameworkhandlers.py +0 -0
  22. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/handler.py +0 -0
  23. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/request.py +0 -0
  24. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/response.py +0 -0
  25. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat/webapp/scrubber.py +0 -0
  26. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat.egg-info/SOURCES.txt +0 -0
  27. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat.egg-info/dependency_links.txt +0 -0
  28. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat.egg-info/requires.txt +0 -0
  29. {horsemeat-2.22.12 → horsemeat-2.23.0}/horsemeat.egg-info/top_level.txt +0 -0
  30. {horsemeat-2.22.12 → horsemeat-2.23.0}/setup.cfg +0 -0
  31. {horsemeat-2.22.12 → horsemeat-2.23.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: horsemeat
3
- Version: 2.22.12
3
+ Version: 2.23.0
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
@@ -19,6 +19,7 @@ import warnings
19
19
  import jinja2
20
20
  import pkg_resources
21
21
  import psycopg2, psycopg2.extras
22
+ import psycopg
22
23
  import yaml
23
24
 
24
25
  from horsemeat import fancyjsondumps
@@ -85,6 +86,8 @@ class ConfigWrapper(object):
85
86
  yaml.safe_load(stream),
86
87
  yaml_file_name=filename)
87
88
 
89
+ stream.close()
90
+
88
91
  return self
89
92
 
90
93
  @classmethod
@@ -183,7 +186,39 @@ class ConfigWrapper(object):
183
186
  def database_password(self):
184
187
  return self.config_dictionary['postgresql'].get('password')
185
188
 
186
- def make_database_connection(self, register_composite_types=True):
189
+ def make_psycopg_database_connection(self, register_composite_types=True):
190
+
191
+ """
192
+ This is NOT psycopg2, but psycopg3, which goes by psycopg.
193
+ """
194
+
195
+ if self.config_dictionary["postgresql"].get("psycopg_version") != "psycopg":
196
+
197
+ raise Exception("Add a 'psycopg_version' key under postgresql in your yaml file and set it to 'psycopg' to use this!")
198
+
199
+ else:
200
+
201
+ pgconn = psycopg.connect(
202
+ row_factory=psycopg.rows.namedtuple_row,
203
+ port=self.database_port,
204
+ dbname=self.database_name,
205
+ host=self.database_host,
206
+ user=self.database_user,
207
+ password=self.database_password)
208
+
209
+ log.info(f"Just made postgresql connection {pgconn} (composite types registered: {register_composite_types}.")
210
+
211
+ # psycopg2.extras.register_uuid()
212
+ # psycopg2.extras.register_hstore(pgconn, globally=True)
213
+ # psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
214
+ # psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
215
+
216
+ if register_composite_types:
217
+ self.register_psycopg_composite_types(pgconn)
218
+
219
+ return pgconn
220
+
221
+ def make_psycopg2_database_connection(self, register_composite_types=True):
187
222
 
188
223
  pgconn = psycopg2.connect(
189
224
  connection_factory=psycopg2.extras.NamedTupleConnection,
@@ -202,15 +237,37 @@ class ConfigWrapper(object):
202
237
  psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
203
238
 
204
239
  if register_composite_types:
205
- self.register_composite_types(pgconn)
240
+ self.register_psycopg2_composite_types(pgconn)
206
241
 
207
242
  return pgconn
208
243
 
244
+ def make_database_connection(self, register_composite_types=True):
245
+
246
+ """
247
+ Defaults to psycopg2, not the fancy newer psycopg, which is
248
+ really psycopg3.
249
+
250
+ Add a config entry to use the fancy one.
251
+ """
252
+
253
+ if self.config_dictionary["postgresql"].get("psycopg_version") != "psycopg":
254
+ return self.make_psycopg2_database_connection(register_composite_types=register_composite_types)
255
+
256
+ else:
257
+ return self.make_psycopg_database_connection(register_composite_types=register_composite_types)
258
+
209
259
  # Make aliases because Matt can't remember stuff well.
210
260
  create_postgresql_connection = make_database_connection
211
261
  make_postgresql_connection = make_database_connection
212
262
 
213
- def register_composite_types(self, pgconn):
263
+ def register_psycopg_composite_types(self, pgconn):
264
+
265
+ """
266
+ Subclasses can define this if they want to.
267
+ """
268
+ pass
269
+
270
+ def register_psycopg2_composite_types(self, pgconn):
214
271
 
215
272
  """
216
273
  Subclasses can define this if they want to.
@@ -22,4 +22,4 @@ hasn't been installed yet.
22
22
 
23
23
  """
24
24
 
25
- __version__ = '2.22.12'
25
+ __version__ = '2.23.0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: horsemeat
3
- Version: 2.22.12
3
+ Version: 2.23.0
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