sehmaschine/django-filebrowser — Issue #83: Caught UnboundLocalError while rendering: local variable 'f' referenced before assignment
Author: douglasmiranda
Created: 2012-03-06 04:42:08+00:00
State: open

TemplateSyntaxError at /
Caught UnboundLocalError while rendering: local variable 'f' referenced before assignment

This happen when, for example, I delete an image from the directory when I still using it to show in a template. So when visit the URL the exception appear.

I don't know, but i think that this error should to return an Exception like ImageNotFoundException or something like this.

All I know is that happen in the file (filebrowser/functions.py in version_generator, line 315) :

```python
def version_generator(value, version_prefix, force=None, site=None):
# another lines of code
try:
f = site.storage.open(value)
# another lines of code
except:
return None
finally:
tmpfile.close()
f.close()
```

If the code does not pass from here ``` f = site.storage.open(value)``` there's no way that this ``` f.close()``` works on "finally"
I meant, for me it's not working.