Hi:

I follow the introduction to create a upload function. but the object
seems not content the 'file' attribute.
why? how can I solve it.

thank you in advance!!!

the error is following:
-------------------------------------------
buf = video.file.read(BUFFER_SIZE)
AttributeError: 'dict' object has no attribute 'file'

-----------------------------------------------------------
code is following
--------------------------------------------------------------
class EditProjectVideoFields(widgets.WidgetsList):
    video = FileField('video',label=_(u"Default video"),)
    id = widgets.HiddenField('id')

class EditProjectVideoSchema(validators.Schema):
    video = FileValidator(not_empty=True)
    id = validators.Number(not_empty=True)

edit_project_video_form = widgets.TableForm(
        fields=EditProjectVideoFields(),
        validator=EditProjectVideoSchema(),
        )

class Root(controllers.RootController):
    @expose(template="Wiki.templates.index")
    def index(self):
        return dict(form=edit_project_video_form)

    @expose(template="Wiki.templates.new")
    def save(self, video,id):
        fp = open('\\tmp\\uploaded_file.jpg', 'wb')
        buf = video.file.read(BUFFER_SIZE)
            while buf:
                     fp.write(buf)
                     buf = video.file.read(BUFFER_SIZE)
             fp.close()
        return dict()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to