~valhalla/lesana-devel

Exception searching with template

Details
Message ID
<651K5R.GUAN7A9PBP0M@kirgroup.net>
DKIM signature
pass
Download raw message
running

	lesana search -e <query>


(with `query` having or not any template var in it) results in:

Traceback (most recent call last):
  File "scripts/lesana", line 39, in <module>
    Lesana().main()
  File "lesana/command.py", line 55, in main
    self.args.func(self.args)
  File "/lesana/command.py", line 65, in _main
    self.main()
  File "lesana/command.py", line 329, in main
    query = collection.render_query_template(query)
  File "lesana/collection.py", line 358, in render_query_template
    t = jinja2.Template(query)
  File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 
1195, in __new__
    return env.from_string(source, template_class=cls)
  File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 
1092, in from_string
    return cls.from_code(self, self.compile(source), gs, None)
  File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 
750, in compile
    source = self._generate(source, name, filename, 
defer_init=defer_init)
  File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 
678, in _generate
    return generate( # type: ignore
  File "/usr/lib/python3.10/site-packages/jinja2/compiler.py", line 
112, in generate
    raise TypeError("Can't compile non template nodes")
TypeError: Can't compile non template nodes


The problem seems to be in File "lesana/command.py", line 329

	query = collection.render_query_template(query)

here `query` should be a string, but from command line is a list of 
strings.

moreover, later in same function `query` is handled as a list:

	if query == ['*'] and not (

	[...]

            collection.start_search(
                ' '.join(query),


changing the line in

	query = collection.render_query_template(' '.join(query))

works from command line, but test fail

======================================================================
FAIL: test_search_template (tests.test_commands.testCommandsComplex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File 
"/home/fabio/progetti/lesana_project/lesana/tests/test_commands.py", 
line 245, in test_search_template
    self.assertIn('8e9fa1ed', streams['stdout'].getvalue())
AssertionError: '8e9fa1ed' not found in ''
Reply to thread Export thread (mbox)