13 November 2019 by Peter
post main image
While writing an application on my Docker platform I hit an unexpected problem, yes, another one ... This was the first time that I had to show the time on a page of a website running on Docker and it appeared that the time was UTC instead of local time. In the code I was just using the normal Python calls to get the time: import datetime ... now = datetime.datetime.now() hour = now.hour ...
Read more
13 November 2019 Updated 13 November 2019 by Peter
post main image
How to implement Flask multilanguage is explained in the Flask docs, see links below. But this is just a starting point. You need deeper understanding of the process to handle special cases like falling back to a default language, language switching, and the 404 Page Not Found exception. Assumptions In the remainder of this post we are using a language code, 'lang_code', that is available in the ...
Read more
18 October 2019 Updated 18 October 2019 by Peter
post main image
I run a server with ISPConfig with some 50 sites. The sites are static or PHP. I am developing Python Flask applications now and also want to run them on the ISPConfig server. You can create virtual environments on the ISPConfig server and run your application from here. But some time ago I have chosen to use Docker for development, staging and production. It takes time to set this up ...
Read more
9 October 2019 Updated 16 October 2019 by Peter
post main image
The Flask application I am writing to run this website has all code in a single 'app'. I already did some reorganizing as I wanted full separation of frontend code and the administration code. Now it it is time for total separation, meaning making the frontend a Flask app and the admin another Flask app while both running in the same domain and both reside in the same project directory. Because we ...
Read more
28 September 2019 Updated 11 October 2019 by Peter
post main image
Update 11 October 2019: I changed the addon-tag from '{% addon: ... %}' to '[[ addon: ... ]]'. The reason is that I wanted to be able to render the page text coming from the database, using render_template_string, and '{% ... %}' conflicts with Jinja2 tags. And yes, I do not want to implement a Jinja2 custom tag.  What is difficult about implementing a contact page with a contact form with Flask ...
Read more
15 September 2019 Updated 15 September 2019 by Peter
post main image
Before you read on, you may want to read my previous posts about multilanguage and language fallback, see links below. When I gave myself the assignment to develop and implement a multilanguage Flask website with SQLAlchemy I knew things could get difficult. I did not really took the time to design everything beforehand, I just read a lot about multilanguage on the internet and trusted my experience ...
Read more
14 September 2019 Updated 14 September 2019 by Peter
post main image
Before you read on, you may want to read my previous post about language fallback, see link below. Here you have an example of the complexity of multilanguage. The link should be shown in the language you are using at the moment ... another time.   Life is one long big sequence of problems we are solving all the time. It starts with getting enough oxygen, solved by breathing, maybe second ...
Read more
11 September 2019 Updated 12 September 2019 by Peter
post main image
In a previous post I described the first version of the multilanguage database used on this website. For every table that has fields that must translated, we add a 'translation' table with these fields. I also implemented language fallback: if an item, like a blog post, does not exist in the selected language then the item of the (system-wide) default language is shown. This works fine but now I want ...
Read more
31 August 2019 Updated 7 September 2019 by Peter
post main image
Update: Using reserved words is only working if you keep the words in place. I first substituted them for non-translatable tags but then DeepL does not know what it is doing anymore.  Of course nothing compares to a translation by a professional translator. Machine translation is difficult. DeepL tries to improve translations by machine learning but they are still far away from using the proper ...
Read more
29 August 2019 Updated 30 August 2019 by Peter
post main image
Objects, it is nice to build an application with them but it has one very big disadvantage: it can be very slow because of the extra CPU-cycles and all the extra memory used. The slowdown of course is very much caused by the extra mapper layers and extra data.  Should you care about performance? Yes! The admin part of an application does not have to be very fast but the frontend pages, the pages ...
Read more