How to get the URL of a NamedBlobFile which is a field in a DataGridField?


To get the URL of a "standard" NamedBlobFile, I can find many docs on (thanks for the docs !).

A DataGridField field is a list of dictionaries, so if I want to download a file which is an attribute of a DataGridField, how can I get the right URL? Using the index of the list ? but how ?

For example, my use case is :

class IFunding(Interface):
certificate = NamedBlobFile(
title=(u"funding certificate"),
(u'certificate help'),

class IThesis(model.Schema):
    fundings = schema.List(
        title=_(u"list of fundings"),
        description=_(u"description of fundings selection"),
        value_type=DictRow(title=_(u"Funding"), schema=IFunding),

The fundings field value is as follow:

[{'body': 'universite-de-bretagne-occidentale', 'acquired': u'Demande en cours', 'purcentage': '50 %', 'certificate': <plone.namedfile.file.NamedBlobFile object at 0x10d4d5aa0>},...

Thanks !

I am not sure you can store blobs in a dict, which is not a first-class persistent object. You may need to avoid DictRow value_type and use value_type=schema.Object() instead.

Now, using an object requires you write a custom conversion class, per the readme. If you look at this demo, you likely have a starting point:

Anyway, I suspect you have some work ahead of you to store BLOB in a data grid, but I would think this doable as long as you ensure your object storing each row subclasses persistent.Persistent.


I have tried this without too muck luck.
when you edit the content, the images disappear on save.

That said, it is possible to construct a download url with the content url + field + /@@download , but I have not found a way to find the blobs url.
I might be able to find the code I used for it.

PS: This has been discussed here a lot on another 'question'