I'm not sure of the best way to approach this, any suggestions? I am inserting records into a table that contains an upload field for an image (which is stored in the table as a blob). The user will be able to later change this image via a form, and I wish to expose the field for download, thus the use of the upload field. However, when I first insert a new record, I want to store a default image in the upload field as the initial insert is not done via a form.
Currently I am opening a default image stored in an application directory containing a set of default images and storing that file's contents in the blob used for the upload field. I am not sure, however what to do about the filename string that is stored in the upload field itself (usually generated on form.accepts). Is the function that generates this value from the filename exposed in a manner that I can use it to manually generate a value outside of a form.accepts? Or does it matter what I store in the upload field as a value (eg. Could I use tablename.fieldname.<record id>.filename as a unique value (although this would be not optimal for the DB as I have to do an insert to get the ID and then an update for the generated filename)? This code represents what I want to do: # get the default image filename = os.path.join(request.folder,'templates','default.png') file = open(filename) imageBlob = file.read() file.close() # generate a unique value for the upload field uploadName = generateUploadName('profile','file','default.png') db.profile.insert(file=uploadName,file_data=imageBlob) Not sure if generateUploadName() is a call to an already existing web2py method or one that I need to create myself, and if I create myself, if it needs to be consistent with with what is normally generated when using form.accepts. Suggestions? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---