I made a new attempt at installing and running Booktype 2.4, using the manual installation procedure (on a DigitalOcean droplet). Seems to work fine, but it will not run properly over HTTPS.
I can get the Letsencrypt certificate up and running no problem, but get mixed content warnings in both Firefox and Chrome, and many interface menu-icons will not show up when using HTTPS, thus it's almost impossible for ordinary users to figure out how to use Booktype. (They have to guess the functionality of a menu item button, and hope it does not destroy something)
When viewing the website in https, and then hitting F12 in the browser to view the console, it is full of references to http:// urls collected from "CACHE", "static" and "data" directories.
It seems like the installation process has created some static url references to http://, that ofcourse will not work when site is viewed in https://
Do I have to rebuild the app after configuring the Letsencrypt certificate, or are there some settings I can change in base.py or prod.py to get this to work properly?
What to do?
Attached is the log from the browser console. This is what shows when visiting the site as guest, when logged in these results increase by a great number.
Then restarted server, cleared browser cache. Now mixed content errors are gone and it seems to work.
However, now - after installing SSL certificate - exporting books don't work any longer, it just hangs there with a message saying "Exporting, please wait". It did work as expected before I installed SSL.
Here is what I found in booktype-celery.error.log, the only thing I found related to any export/publishing error
[2019-03-18 23:35:23,818: ERROR/ForkPoolWorker-12] Task booktype.apps.edit.tasks.publish_book[b534fb3a-f862-4282-939f-da2fa6084414] raised unexpected: UnboundLocalError("local variable 'req' referen$ Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 375, in trace_task R = retval = fun(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 632, in __protected_call__ return self.run(*args, **kwargs) File "/usr/local/src/booktype/lib/booktype/apps/edit/tasks.py", line 116, in publish_book result = download.fetch_url(convert_url, data, method='POST') File "/usr/local/src/booktype/lib/booktype/utils/download.py", line 36, in fetch_url if req.status_code != 200: UnboundLocalError: local variable 'req' referenced before assignment
UnboundLocalError: local variable 'req' referenced before assignment
Python has lexical scoping by default, which means that although an enclosed scope can access values in its enclosing scope, it cannot modify them (unless they're declared global with the global keyword). A closure binds values in the enclosing environment to names in the local environment. The local environment can then use the bound value, and even reassign that name to something else, but it can't modify the binding in the enclosing environment. UnboundLocalError happend because when python sees an assignment inside a function then it considers that variable as local variable and will not fetch its value from enclosing or global scope when we execute the function. To modify a global variable inside a function, you must use the global keyword.