Hi mjbruder,
The easiest way to do this would be to define the conversion function for
exporting 'stores' as follows:

lambda x: ":".join(str(y) for y in x)

And the conversion function for imports as follows:

lambda x: [db.Key(y) for y in x.split(":")]

-Nick Johnson

On Thu, Sep 10, 2009 at 3:43 PM, mjbruder <mjbru...@gmail.com> wrote:

>
> I'm attempting to use the bulkloader to load data into my app. I have
> my loader/exporter set up with the following classes:
>
> class FoodItemLoader(bulkloader.Loader):
>  def __init__(self):
>
>    bulkloader.Loader.__init__(self, 'FoodItem',
>                               [('author', str),
>                                ('name', str),
>                                ('brand', str),
>                                ('price', str),
>                                ('category', str),
>                                ('stores', list)
>                               ])
>
> class FoodItemExporter(bulkloader.Exporter):
>  def __init__(self):
>    bulkloader.Exporter.__init__(self, 'FoodItem',
>                                 [('author', str, None),
>                                  ('name', str, None),
>                                  ('brand', str, None),
>                                  ('price', str, None),
>                                  ('category', str, None),
>                                  ('stores', list, None),
>                                 ])
>
> exporters = [FoodItemExporter]
> loaders = [FoodItemLoader]
>
> ---
>
> The exporter seems to work fine, and it exports a column with the
> following type of data in it for the stores list property
> "[datastore_types.Key.from_path(u'Store', 3002L,
> _app_id_namespace=u'grocerygeek')]"
>
> Unfortunately, I cannot use this same format to load data into my
> datastore because it gives me the following error "BadValueError:
> Items in the stores list must all be Key instances"
>
> Is there a way I can format my CSV file or my code to accept this type
> of data?
>
> >
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to