Open bskinn opened 1 year ago
A simple descriptor might be enough. Inside Inventory
:
class Inventory(...):
...
_sslcontext_obj = None
@property
def _sslcontext(self):
# This is clunky and not best practice. Could also work with top-level import
# and and just defer the exception to this use of ssl....have to decide.
import ssl
if not self._sslcontext_obj:
self._sslcontext_obj = ssl. ...
return self._sslcontext_obj
Note to self: There is request capability in Pyodide and PyScript, it just is accessed differently. So, we would want to to some import-time testing to see what's available, and then use the first option that works out of a priority-sequenced cascade of options.
This will be necessary in order for https://github.com/bskinn/soi-app/issues/10 to work, at all. PyScript doesn't ship with a working
ssl
package, andsphobjinv
importsssl
at import time.sphobjinv
doesn't use SSL except forInventory(url=...)
instantiation. AnyImportError
that occurs during an attempt toimport ssl
will need to be deferred until such time thatInventory(url=...)
is attempted.This means that the creation of
Inventory._sslcontext
will also have to be deferred, sincessl
is used to create that context. Thus, #113 will be needed for functional reasons.