I have a problem once again :).

I have a code:
        for entry_class_attribute in entry_class_attributes:
            if entry_class_attribute.entry_label:
                entry_label = entry_class_attribute.entry_attribute_id.name
            fields.append(EntryValue.get_field(entry_class_attribute))

        form = SQLFORM.factory(*fields, table_name='entry_value')

This attributes are my form fields, fields are dynamically generated from 
the database trough get_field function. 

In my view i have:

            {{for entry_class_attribute in entry_class_attributes:}}
                <div>
                    {{entry_attribute_id = entry_class_attribute.
entry_attribute_id}}
                    {{field_name = entry_class_attribute.entry_attribute_id.
name}}
                    {{field_label = entry_class_attribute.entry_attribute_id
.description}}
                    {{field_type = entry_class_attribute.entry_attribute_id.
field_type}}
                    {{if field_type != "UPLOAD":}}
                        {{=form.custom.label[field_name]}}
                        <div>{{=form.custom.widget[field_name]}}</div>
                    {{elif field_type == "UPLOAD":}}
                        <label for="{{=field_name}}">{{=field_label}}</label
>
                        <div>
                            <input type="file" name="{{=field_name}}" id=
"{{=field_name}}" multiple />
                            {{if uploads.has_key(entry_attribute_id) and len
(uploads[entry_attribute_id]) > 0:}}
                                <ul class="files edit">
                                    {{for upload in uploads[
entry_attribute_id]:}}
                                        {{=LI(upload.upload_filename,
                                            " ",
                                            A(T("Preuzmi"), _href=URL(
"default", "download", args=upload.upload_value), _target="blank", _class=
"download"),
                                            " ",
                                            A(T("Obriši"), _href=URL(
"entry_value", "delete_value", args=upload.id), _class="delete"),
                                        )}}
                                    {{pass}}
                                </ul>
                            {{pass}}
                        </div>
                    {{pass}}
                </div>
            {{pass}}

But i am still getting the error:

127.0.0.1.2013-06-13.10-21-44.b2fb8130-4fad-444b-9246-f481539fa1ec
<type 'exceptions.UnboundLocalError'> local variable 'source_file' 
referenced before assignmentVersionweb2py™Version 
2.4.5-stable+timestamp.2013.04.01.19.18.09PythonPython 2.7.3: 
C:\Anaconda\Python.exe (prefix: C:\Anaconda)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File "C:\development\web2py\gluon\restricted.py", line 212, in restricted
    exec ccode in environment
  File "C:/development/web2py/applications/init/controllers/entry_value.py" 
<http://127.0.0.1:8000/admin/default/edit/init/controllers/entry_value.py>, 
line 453, in <module>
  File "C:\development\web2py\gluon\globals.py", line 194, in <lambda>
    self._caller = lambda f: f()
  File "C:\development\web2py\gluon\tools.py", line 2976, in f
    return action(*a, **b)
  File "C:/development/web2py/applications/init/controllers/entry_value.py" 
<http://127.0.0.1:8000/admin/default/edit/init/controllers/entry_value.py>, 
line 96, in form
    if form.validate():
  File "C:\development\web2py\gluon\html.py", line 2123, in validate
    if self.accepts(**kwargs):
  File "C:\development\web2py\gluon\sqlhtml.py", line 1468, in accepts
    newfilename = field.store(source_file, original_filename,
UnboundLocalError: local variable 'source_file' referenced before assignment

This looks like web2py is still trying to handle the file on its own. Am I 
right?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to