There IS NO SQLHTML :-)

I figure Massimo meant SQLFORM ... and the follow code works!

Thanks!  Thanks!  Thanks!

def editrec():
  #
  #  edit record 1
  #
  # form = SQLFORM( db.tbbooks, 1 )
  form = SQLFORM(db.tbbooks,1,
upload=URL(r=request,f='download') )
  return dict ( form = form )


On May 24, 3:53 pm, NetAdmin <[email protected]> wrote:
> Whoa!  SQLHTML? I didn't even know that existed!
>
> Thanks for the tip!
>
> On May 24, 3:37 pm, mdipierro <[email protected]> wrote:
>
> > If you are looking for a preview of the uploaded images when editing a
> > record you can to do
>
> > form = SQLHTML(....,upload=URL(r=request,f='download'))
>
> > On May 24, 10:52 am, NetAdmin <[email protected]> wrote:
>
> > > I'm a bit confused.
>
> > > During an edit or listing of all books,
> > > how can I display the .jpg file that is
> > > stored in the field named coverblob ?
>
> > > I can only see the blob field contents
> > > when using appadmin.
>
> > > Thanks!
>
> > > ==========   db.py  ==========================
>
> > > db.define_table( 'tbbooks' ,
> > >   SQLField('booktitle' , 'string', length=20),
> > >   SQLField('cover', 'upload', uploadfield='coverblob'),
> > >   SQLField('coverblob', 'blob')
> > > )
>
> > > ======== default.py  ==========================
>
> > > def index():
> > >   #
> > >   #   select all books
> > >   #
> > >   recs = db().select(db.tbbooks.ALL,orderby=db.tbbooks.booktitle)
> > >   return dict ( recs = recs )
>
> > > def editrec():
> > >   #
> > >   #  edit record 1
> > >   #
> > >   form = SQLFORM( db.tbbooks, 1 )
> > >   #
> > >   if form.accepts(request.vars, session):
> > >     response.flash = 'Done!'
> > >   #
> > >   return dict ( form = form )
>
> > > def insrec():
> > >   #
> > >   # insert a new record
> > >   #
> > >   form = SQLFORM( db.tbbooks )
> > >   #
> > >   if form.accepts(request.vars, session):
> > >     response.flash = 'Done!'
> > >   #
> > >   return dict ( form = form )
>
> > > ==================================

Reply via email to