inveniosoftware/invenio — pull request #2154 by pedrogaudencio (2014-08-26 14:32:24+00:00)
Title: records: lazy type introduction in MarcXML export

**Idea:**
Check if the string is a lazy string and convert it into a list in order not to be split in letters while exporting to MarcXML.

**Problem:**
As an example, this is the languages list we have in a form to generate a select field:

```
languages = [("en", _("English")),
("fre", _("French")),
("ger", _("German")),
("dut", _("Dutch")),
("ita", _("Italian")),
("spa", _("Spanish")),
("por", _("Portuguese")),
("gre", _("Greek")),
("slo", _("Slovak")),
("cze", _("Czech")),
("hun", _("Hungarian")),
("pol", _("Polish")),
("nor", _("Norwegian")),
("swe", _("Swedish")),
("fin", _("Finnish")),
("rus", _("Russian")),
("oth", _("Other"))]
```

It uses `_` from `invenio.base.i18n`. What happens when we generate MarcXML from it is:

```
> from invenio.modules.deposit.models import Deposition
> d = Deposition.get(20)
> s = d.get_latest_sip(sealed=True)
> s.metadata['language']

lu'English'

> print s.package

340

E
n
g
l
i
s
h

title

HEP

```

This would be the correct MarcXML:

```
> print s.package

340

English

title

HEP

```

To contextualize, `s.package` is the MarcXML generated by [`legacy_export_as_marc()`](https://github.com/inveniosoftware/invenio/blob/pu/invenio/modules/records/api.py#L165) prior to the record upload. In this case, it breaks specifically the language field as if it had several languages, when in fact only has "English". This happens because the string isn't `six.string_types` nor an `Iterable`, it's a lazy string type and that case is not covered by the conditions.

**Proposal:**
Since we're working with translated strings in the forms, the proposal is to include that check in the conditions to make the `value` in the current `marc_dict` a list (`[value]`).