Commit graph

32 commits

Author SHA1 Message Date
Andrew Ekstedt e1bbe78b72 fix test suite under SQLAlchemy 1.2.x
* SQLAlchemy 1.0 introduced "baked queries" - a way to construct Query
 objects so that they can be cached and reused.

 * SQLAlchemy 1.2 changed lazyloaded columns to use baked queries under the
 hood.

 * Our MultilangQuery class attempts to set _default_language_id right
 before the query is executed by overriding the __iter__ method.

 * Baked queries bypass the __iter__ method and call a lower-level
 method, _execute_and_instances, directly.

 * This caused problems where _default_language_id wouldn't get set
 correctly on lazyloaded columns.

 * To fix, make MultilangQuery override the _execute_and_instances
 method instead of __iter__.

 * This is really just a stopgap: the root cause is that query params
 are not preserved across lazyloads.

Tested with SQLAlchemy 0.9.7, 1.1.18, and 1.2.5.

Updates #236.
2018-03-30 12:01:21 -07:00
John T. Wodder II c3f566b2c9 Addressed all of pyflakes3's complaints 2016-11-24 21:29:58 +00:00
Eevee (Alex Munroe) b76b74e7a6 Compat with Python 3.3+ 2015-10-05 08:12:23 -07:00
Andrew Ekstedt 02b1968bc5 "Fix" MultilangQuery.
SQLAlchemy 1.0 sets bindpararms to their default values when loading
lazy-loaded columns. This is in contrast to the 0.9 behaviour of
ignoring our incongruous bindparam alltogether.

So MultilangQuery is still broken, but now it breaks in the same way as before.

While we're here, set the correct param in one of the multilang tests. Not that
it matters.
2015-05-23 18:26:09 -07:00
Andrew Ekstedt 6f5abb9540 Put column descriptions where they belong
The Column class accepts a 'doc' argument. Use it.

And while we're at it, make them all unicode strings.

Performed by the following sed script:

   s/info=dict(description=u\?\("[^"]*"\))/doc=u\1/
   s/info=dict(description=u\?\('[^']*'\))/doc=u\1/
   s/\(\s*\)info=dict(description=u\?\("[^"]*"\), /\1doc=u\2,\n\1info=dict(/
   s/\(\s*\)info=dict(description=u\?\('[^']*'\), /\1doc=u\2,\n\1info=dict(/

   /info=dict(description=u\?\('[^']*'\),$/ {
       s//doc=u\1,/
       n
       s/^\s*/&info=dict(/
   }
2014-07-05 16:46:37 -07:00
Lynn "Zhorken" Vaughan 7286ba0254 Delete all the blank rows in pokemon_form_names.
All the tests still pass and everything.  We literally did not need them
after that innerjoin=True got commented out.
2014-06-11 22:22:32 -04:00
Petr Viktorin bbb3ab09e3 Add __tablename__ to translation tables
This makes it easier to write introspection scripts.
2013-08-07 14:13:04 +02:00
Petr Viktorin 0cb1f8a1b8 Make the table schema a bit more introspectable
This solves two problems: first, the relationships are now defined in
the class they apply to, rather than in a separate section of the module,
and second, their metadata -- both creation arguments and extra info such
as `description` (or, later, possibly, info for API properties) -- is
stored.
2012-02-12 16:19:09 +01:00
Petr Viktorin 96499fae30 Allow ordering and filtering on translated texts, e.g. Move.name 2012-02-12 09:50:04 +01:00
Petr Viktorin 719c32de0b Make MarkdownString.as_html() accept an extension object, not class
No reason to instantiate every time as_html's called, is there?

Also, sessions use a markdown_extension attribute instead of
markdown_extension_class. The latter is only used to set the former when
the session is created (unless another markdown_extension_class is given,
of course).
2011-09-22 00:51:59 +03:00
Eevee a11261e529 Fix a stupid closure-in-loop problem. #654 #655 2011-09-11 17:27:58 -07:00
Eevee 25ab674c7c Fix this markdown extension nonsense.
Previously, every single spline-pokedex request tacked another markdown
extension onto a global list in spline, making markdown processing just
a little bit slower over time.  This is terrible.

Now we do something a little less crazy and a little more global.  Wait,
is that less crazy or more?
2011-09-06 21:52:27 -07:00
Eevee 3a59ef1fe0 Update us to SQLAlchemy 0.7. #582 2011-09-04 23:19:56 -07:00
Petr Viktorin 3034c04d59 Allow missing Markdown translation rows (for species' form descriptions) 2011-05-06 12:26:16 +03:00
Petr Viktorin b711edd511 Port the Markdown value tests from spline-pokedex. Fix remaining strings. 2011-04-28 23:43:54 +03:00
Petr Viktorin 85d779ba83 Move Markdown handling to the translation classes
- the Session has a `pokedex_link_maker` property, whose `object_url`
  method is used to make URLs in Markdown
- pokemon.names_table.name is now an ordinary Unicode column
- pokemon.name is a MarkdownString that is aware of the session and the
  language the string is in
- pokemon.name_map is a dict-like association_proxy of the above
- move.effect works similarly, with transparent $effect_chance substitution
  as before
2011-04-28 23:42:56 +03:00
Petr Viktorin 4cd68fb5e3 Typo: multilang docstring was wrong 2011-04-17 22:34:02 -07:00
Petr Viktorin 27d33556d4 Load local_language lazily 2011-04-17 17:45:10 -07:00
Eevee 08bfd753e0 Fix default language assignment once and for all.
Stop trying to be clever and magical and just make the caller pass in a
damn primary key.
2011-04-10 00:54:14 -07:00
Eevee 8e2ad429d9 hurp durp default language 2011-04-05 23:34:28 -07:00
Eevee acf44c63a0 Merge branch 'encukou' 2011-04-05 21:04:32 -07:00
Eevee 9441ffb165 Remove the responsibility of setting a default language from multilang.
Caller now has to do it.  No need to avoid circular deps, no need to do
much of anything at all.
2011-04-05 21:03:41 -07:00
Eevee ef29dd667c Always joinedload the local_language for a full language map. 2011-04-05 20:48:10 -07:00
Petr Viktorin 4291c33c00 Make MultilangSession's language class configurable 2011-04-04 21:51:35 +03:00
Petr Viktorin 9fdb8e1bd0 Make session.default_language set/get work 2011-04-04 04:18:37 +03:00
Petr Viktorin 97bf4cfe45 Update test_schema to the new API. Add some missing column metadata. 2011-04-01 15:59:53 -07:00
Petr Viktorin d961cfe1c7 Add a mapped_classes list, and a translation_classes list to each mapped class 2011-04-01 15:59:52 -07:00
Eevee 825d40c51e Match default language by id, not identifier. 2011-03-29 20:15:41 -07:00
Eevee 1268a76832 Joinedload current-language names. 2011-03-29 18:39:37 -07:00
Eevee f24702b7a9 language_id -> local_language_id 2011-03-28 19:12:30 -07:00
Eevee 8ad84e4032 Removed ProseColumn and TextColumn. Huzzah. 2011-03-23 22:17:02 -07:00
Eevee 68e14e663e Started switching to create_translation_table.
- Moved the function to its own file.
- Implemented the session-based default language switching.
- Migrated a couple tables.
2011-03-21 22:32:52 -07:00