I'm fetching a dataset from my database with sqlalchemy in Python :

```
links = session.query(Link).order_by(Link.id.desc()).limit(20)

```

I'm then iterating over the `links` result in my view :

```
%for link in links:
    <div class="link">
        {{link.url}}
        %if link.pdf: 
            <a href="{{link.pdf}}">[pdf]</a>
        %end
    </div>
%end

```

I want to read the external attribute in `link`, `pdf` if a pdf file exists for the result.

I've tried :

```
for index, link in enumerate(links):
    if os.path.isfile('/pdf/'+str(link.id)+'.pdf'):
        links[index].pdf = '/pdf/'+str(link.id)+'.pdf'
    else:
        links[index].pdf = None

```

but the `pdf` attribute is apparently not set.

What am I doing wrong ?