form = SQLFORM.factory(db.club, db.cities, _class='well',
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=request.folder+'uploads/pictures',
uploadseparate=True, autodelete=True, table_name='club' )Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback (most recent call last):
File "/home/paolo/Dropbox/git/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py", line 123, in <module>
File "/home/paolo/Dropbox/git/web2py/gluon/globals.py", line 193, in <lambda>
self._caller = lambda f: f()
File "/home/paolo/Dropbox/git/web2py/gluon/tools.py", line 2935, in f
return action(*a, **b)
File "/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py", line 35, in modal
d = {'form':club_form(c_id=club_id)}
File "/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py", line 103, in club_form
if form.process(dbio=False).accepted:
File "/home/paolo/Dropbox/git/web2py/gluon/html.py", line 2179, in process
self.validate(**kwargs)
File "/home/paolo/Dropbox/git/web2py/gluon/html.py", line 2118, in validate
if self.accepts(**kwargs):
File "/home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py", line 1408, in accepts
source_file = open(f, 'rb')
IOError: [Errno 2] No such file or directory: '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'/home/paolo/Dropbox/git/web2py/applications/bikend/uploads/pictures/club.picture/a4Field("picture", "upload", uploadfolder=request.folder+'uploads/pictures', uploadseparate=True, autodelete=True, requires=[IS_NOT_EMPTY(), IS_IMAGE(), IS_UPLOAD_FILENAME(extension='jpg|jpeg|png'),IS_IMAGE(extensions=('jpeg', 'png'))]),
for field in ['title','description', 'user_contact','picture' ]:
db.club[field].default = club[field]
for field in ['name']:
db.cities[field].default = city[field]
form = SQLFORM.factory(db.club, db.cities, _class='well',
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=request.folder+'uploads/pictures',
uploadseparate=True, autodelete=True, table_name='club')requires=[IS_IMAGE(), IS_UPLOAD_FILENAME(extension='jpg|jpeg|png'), IS_IMAGE(extensions=('jpeg', 'png'))requires=Nonerequires=[]<cod...
Show original
<cod...
Show original
db.define_table('test_img',
Field("picture", "upload",
uploadfolder=os.path.join(request.folder,'uploads','pictures'),
uploadseparate=True),
Field('created_on', 'datetime', default=request.now, writable=False)
)
def sqlform_add():
form = SQLFORM.factory(db.test_img, _class='well',
upload=URL('default', 'download'),
uploadfolder=os.path.join(request.folder,'uploads','pictures'),
uploadseparate=True, table_name='test')
if form.process(dbio=False).accepted:
id = db.test_img.insert(**dict(form.vars))
return response.render('generic.html', dict(form=form))
def sqlform_edit():
img = db(db.test_img.id>0).select().first()
db.test_img['picture'].default = img['picture']
form = SQLFORM.factory(db.test_img, _class='well',
upload=URL('default', 'download'),
uploadfolder=os.path.join(request.folder,'uploads','pictures'),
uploadseparate=True, table_name='test')
if form.process(dbio=False).accepted:
print 'form accepted'
return response.render('generic.html', dict(form=form))
sqlform_add and then removing it with appadmin --> workedh sqlform_edit --> failed
- using both sqlform_add and sqlform_edit --> failed db.test_img['picture'].default
equal to real path of the file. This worked well but than, if I
understood correctly how web2py works, it tried to store again the
default value as the new value, starting a kind of loop! That was wrong,
and actually this has never worked, it stopped due to the 'error
filename' to long.f = self.table[fieldname].default or ''
fields[fieldname] = f
fields[fieldname] = self.table[fieldname].default
--