Invenio: print records in marcxml format using invenio API

Sometimes it is useful to get the marcxml output of some records.

This is an example showing how to print recid’s from 18007 to 18200 in marcxml format using Invenio API:

from invenio.search_engine import print_record
salida = ''
for recid in range(18007,18200):
    #print "Registro %s" %recid
    salida += print_record(recid,format='xm')
print salida

Drupal7: list allowed values from a field type list [SOLVED]

In Drupal 7, how do you list all the allowed values in a certain field of some content type?

You can use the list_allowed_values function.

Lets see it with an example.

I will define a new Content Type called “Actividad” (machine name=’actividad‘), which will have a title, a body and a List(text) field type called ‘tipo_actividad‘ (machine name=’field_tipo_actividad‘):
list_allowed_values drupal 7

And then I will define the allowed values for this field_tipo_actividad field:
drupal 7 list_allowed_values for field

Now, how do I programmatically list the allowed values for that field? Using list_allowed_values function:

$field = field_info_field('field_tipo_actividad'); /* field_tipo_actividad=machine name of the field */
$allowed_values = list_allowed_values($field);     /* what are the values allowed for that field? */
return var_dump($allowed_values);

drupal7 list allowed values

If you want a prettier output, you can change the code to:

$field = field_info_field('field_tipo_actividad');
$allowed_values = list_allowed_values($field);
$salida = "";
foreach ($allowed_values as $key=>$value){
    $salida = $salida."Key: ".$key." Value: ".$value."<br />";
return $salida;

And you’ll get something like:
drupal list_allowed_values tutorial example