GENI-NSF / geni-ch

GENI clearinghouse services
Other
3 stars 6 forks source link

Too many directories in sys.path #488

Closed tcmitchell closed 8 years ago

tcmitchell commented 8 years ago

Imports are happening via different paths in sys.path (set in ch_server.wsgi). For example, Exceptions.py is imported as either plugins.chapiv1rpc.chapi.Exceptions or as chapi.Exceptions. This causes isinstance to fail unexpectedly in some (but not all) cases. This is because both /usr/share/geni-ch/chapi/chapi and /usr/share/geni-ch/chapi/chapi/plugins/chapiv1rpc are on the path and Exceptions is sometimes imported as chapi.Exceptions (e.g. SAv1PersistentImplementation.py).

Straighten out the directories in sys.path, then make the import statements match. I recommend including only the top level directory (/usr/share/geni-ch/chapi/chapi, but use automake replacement) in the sys.path, and then importing as either plugins.foo.bar or tools.foo.bar.

A meta question: should sys.path be set by ch_server.wsgi at all? Or should the path be set in WSGI config instead?

tcmitchell commented 8 years ago

The WSGI config in apache needs to be updated. We cannot use WSGIPythonPath in daemon mode, so instead use the python-path argument to WSGIDaemonProcess:

WSGIDaemonProcess ch_server display-name=%{GROUP} python-path=/usr/share/geni-ch/chapi/chapi:/usr/share/geni-ch/chapi/chapi/tools:/usr/share/geni-ch/gcf/src

With that in place we no longer need to set the basic paths via sys.path in ch_server.wsgi.