The response object *should* be a requests.Response object, which *should*
have a .text property. However, there are situations where this is not the
case, and in those cases we now won't produce an AttributeError.
This makes it easier to see what the Celery worker is actually working on
when refreshing a large number of links.
It'll report on every N refreshed links, where N = link_count/25 but
clamped to N ∈ [5, 100]
I hope this fixes this error; I no longer see it locally:
Traceback (most recent call last):
File "/data/git/blender-cloud/runserver.wsgi", line 16, in <module>
application = PillarServer(my_path)
File "/data/git/pillar/pillar/__init__.py", line 96, in __init__
self._config_bugsnag()
File "/data/git/pillar/pillar/__init__.py", line 191, in _config_bugsnag
handle_exceptions(self)
File "/opt/python/lib/python3.6/site-packages/bugsnag/flask/__init__.py", line 27, in handle_exceptions
got_request_exception.connect(__log_exception, app)
File "/opt/python/lib/python3.6/site-packages/blinker/base.py", line 130, in connect
sender_ref = reference(sender, self._cleanup_sender)
File "/opt/python/lib/python3.6/site-packages/blinker/_utilities.py", line 134, in reference
weak = callable_reference(object, callback)
File "/opt/python/lib/python3.6/site-packages/blinker/_utilities.py", line 145, in callable_reference
return BoundMethodWeakref(target=object, on_delete=callback)
File "/opt/python/lib/python3.6/site-packages/blinker/_saferef.py", line 135, in __new__
key = cls.calculate_key(target)
File "/opt/python/lib/python3.6/site-packages/blinker/_saferef.py", line 196, in calculate_key
return (id(get_self(target)), id(get_func(target)))
File "/opt/python/lib/python3.6/site-packages/events/events.py", line 41, in __getattr__
(self.__class__.__name__, name))
AttributeError: type object 'PillarServer' has no attribute '__self__'
Before this, the user's authentication token would still be stored in
the session even when it's found to be invalid. This caused a login
action to fail, but not in such a way that we would redirect to the login
page of Blender ID. Rather, it would keep you not logged in. By clearing
the session we're sure that the invalid token is forgotten, and the next
request will handle the login properly.
This uses the orphan-files.txt file output by find_orphan_files() to
mark those files as deleted. This allows for a two-stage approach, where
file IDs are found on one machine (against a read-only MongoDB slave, for
example) and soft-deleted on another machine (against a writable master).
This is quite a heavy thing to run, since it goes over all files of a
project, and then goes over every document in (almost) every collection
which has a property 'project' that's set to the project ID. It then goes
over every document to find all ObjectIDs and removes those from the set
of file ObjectIDs for that project. The remaining ObjectIDs are considered
orphans.
This is a very thorough search, but it doesn't require any knowledge of
the document and collection structure, so it should be future-proof.
User experience
===============
For users it means we can provide localized web-sites to enrich their
overall experiences.
Although for the Blender Cloud this doesn't make much sense (since the
content is in English), Flamenco and Attract can really benefit from
this.
New configuration settings
==========================
There are two new parameters in config.py:
* DEFAULT_LOCALE='en_US'
* SUPPORT_ENGLISH=True
They are both properly documented in the `config.py` file.
Technicall details
==================
We are using the 'Accept-Languages' header to match the
available translations with the user supported languages.
If an extension has a `translations` folder, it's used for translations.
However the main application (e.g., Blender Cloud) is the one that
determines the supported languages based on its `languages` folder.
How to mark strings for translation
===================================
See the documentation in README.md.
But as an example, 404.pug and pillar/__init__.py::handle_sdk_resource_invalid
have marked up strings that will be extracted once you install pillar,
or run any of the translations commangs.
Remember to **gulp** after you update the template files.
How to setup translations
=========================
You will need to create translation for the main project, and for each
extension that you want to see translated. I added a new entry-point to
the installation of Pillar.
So all you need is to use the `translations`
script to initialize, update and compile your translations.
Pending tasks
=============
Aside from marking more strings for extraction and start the translation
effort it would be interesting to replace the pretty_date routine with
momentjs.
Acknowledgement
===============
Many thanks for Sybren Stüvel for the suggestions and throughout code
review. Thanks also to Francesco Siddi for the original documentation
and suggesting me to tackle this. And Kudos for Pablo Vazquez for the
motivational support and for the upcoming "strings mark up" task force!
The core of the implementation is based on Miguel Grinberg i18n chapter
of his great 'The Mega Flask Tutorial'.
Reviewers: sybren
Differential Revision: https://developer.blender.org/D2826
Eve expects 'flask>=0.10.1,<=0.12' so we can't use flask==0.12.2 in
pillar for now.
This needs to be fixed upstream (eve), but for now `python setup.py
install`.
This should be hidden in the UI as well, but the backend should support this too.
We also want to set initial rating of 1 for contents that need it.
This commit includes a new unittest for this case.
Reviewers: sybren
Differential Revision: https://developer.blender.org/D2825
This mimicks the behaviour of flask_login. In our case, it only redirects
when redirect_to_login=True and the user is anonymous. Otheriwse it still
results in a 403 Forbidden response.