On 1/11/07, Sanjay <[EMAIL PROTECTED]> wrote:
>
> Hi All,
Hello Sanjay,
in the upload controller you could do something like this:
--------------------------------------------
from turbogears import expose, validate, identity, validators
[... snip ... some code here ...]
@expose()
@validate(validators={'up_file':validators.FieldStorageUploadConverter()})
@identity.require(identity.has_permission("admin"))
def save_file(self, up_file):
'''
exposed method for receiving POSTed files and storing them into
our DB
'''
file_data = up_file.file.read()
myfile = model.File()
myfile.lastuser = identity.current.user.user_id
myfile.size = len(file_data)
myfile.mime_type = up_file.type
myfile.orig_filename = up_file.disposition_options['filename']
myfile.data = file_data
etc ...
------------------------------------------------------------
note that the data column in the DB could be declared as deferred
loading in your model (if you are using SQLAlchemy I posted an exemple
some time ago for ActiveMapper but assignmapper is even easier to use)
Regards,
Florent Aide.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---