[Cubicweb] docutils broken with CubicWeb
Dimitri Papadopoulos Orfanos
dimitri.papadopoulos at cea.fr
Thu Apr 7 10:56:08 CEST 2016
I cannot find a way to retrieve the initial current directory in my
application code, since all application code seems to be called after
os.chdir('/') in daemonize().
The only solution I see so far would be to reload docutils before using
it in application code:
I don't have much experience with reload() though. Class variables in
the module do not seem to be reset. Do you have any clue what should be
done to reset docutils internal variables from our application?
Le 07/04/2016 03:20, Dimitri Papadopoulos Orfanos a écrit :
> Dear all,
> This is rather a docutils bug than a CubicWeb issue, but I thought you
> might have suggestions how to best handle it.
> There's a bug in docutils: the module defines and uses a
> docutils.utils.relative_path() function to initialize (and later use)
> paths as relative paths (relative to current dir). Of course
> initializing and later using relative paths in a library is nonsensical
> as a mere os.chdir() will break everything.
> Example from docutils/writers/html4css1/__init__.py:
> class Writer(writers.Writer):
> default_stylesheet_path = utils.relative_path(
> os.path.join(os.getcwd(), 'dummy'),
> os.path.join(os.path.dirname(__file__), default_stylesheet))
> This ugly code (what's "dummy" for?) initializes the class variable
> "default_stylesheet_path" as soon as the module is imported.
> The problem is that:
> * CubicWeb itself imports docutils early on through a chain of imports,
> * CubicWeb then calls daemonize(), except in debug mode, which in turn runs:
> Whatever code uses docutils after that breaks the application silently,
> without a single error message, except in debug mode!
> This bug has been recently fixed in docutils:
> Unfortunately it's not part of any formal release yet, so we're stuck
> with it in the short term. Any clue how to best work around this issue
> with minimal code modification? I would like to avoid modifying CubicWeb
> (deferring imports maybe) or docutils (killing the ugly relative_path()
> function wherever it's used with os.getcwd()).
> => How would you work around this from within a CubicWeb application?
DRF, I2BM, NeuroSpin
F-91191 Gif-sur-Yvette cedex, France
More information about the Cubicweb