First thank you for the help, its really appreciated.

Well, I create setup's for deployments of systems. :)

My goal is:
1) To have a view that does not show the id's but the names of the joins
2) To be able to add a new record preferable with as defaults the same 
lvsize_id, and storagemap_id and the last lun_id +1 

This is the first time I use the SQLFORM.grid and/or smartgrid. This form 
creates a view that shows the harddisk/logical volume sizes that have to be 
created on the storage.


First I select the setup 
----------------------------------------------------------
@auth.requires_login()
def modify_lvstorage_select():
    
    form = SQLFORM.factory(
    Field('setup', requires=IS_IN_DB(db(), db.setup.id, '%(setupname)s', 
zero=None))
    )

    if form.accepts(request.vars, session, keepvalues=True):
        session.modify_lvstorage_select = form.vars.setup
        redirect(URL(r=request, f='modify_lvstorage'))

    return dict(form=form)
-----------------------------------------------------------------
Then with this information I create a grid view. Here you should be able to 
add records or modify records.

------------------------------------------------------------------------
@auth.requires_login()
def modify_lvstorage():
    
    usedsetupid = session.modify_lvstorage_select
    
  
 
    left = 
(db.lvsize.on(db.lvstorage.lvsize_id==db.lvsize.id),db.storagemap.on(db.lvstorage.storagemap_id==db.storagemap.id),db.setup.on(db.lvstorage.setup_id==db.setup.id))
    
 
    columns = 
['lvstorage.setup_id','lvstorage.storagemap_id','lvstorage.lvsize_id','lvstorage.lunid']
    
    query = db.lvstorage.setup_id==usedsetupid
    grid = SQLFORM.grid(query,
                        left = left,
                        columns = columns,
                        orderby = ['lvstorage.lunid'], 
                        csv = False
                        )
 
    return dict(usedsetupid=usedsetupid, grid=grid)
-------------------------------------------------------------------------------
The DB setting
-------------------------------------------------------------------------------
# Logical volume on storage
db.define_table('lvstorage',

    Field('setup_id', db.setup,
          default=1,
          label=T('Setup ID')),
    Field('lvsize_id', db.lvsize,
          default=2,
          label=T('Size ID')),
    Field('lunid', type='integer',
          default=2,
          label=T('Lun ID')),
    Field('storagemap_id', db.storagemap,
          default=1,
          label=T('Host Group')),
    Field('created_on','datetime',default=request.now,
          label=T('Created On'),writable=False,readable=False),
    Field('modified_on','datetime',default=request.now,
          label=T('Modified On'),writable=False,readable=False,
          update=request.now),
    migrate=settings.migrate)

# Table rules
db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname')
db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename')
db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 
'storagemap.mapping')
------------------------------------------------------------------------------------------------

> Mike
> 
> If you post some of the details of your app I'm happy to look at it.
> I'm using SQLFORM.smartgrid extensively and it is working really well
> for me.
> 
>      -Jim
> 
> On 11/2/2011 10:47 PM, Mike Veltman wrote:
> > Now I am even more confused :)
> > 
> > 
> > Sorry for being a nagging person.
> > 
> > 
> > Why does SQLFORM.grid display the name (as I want) in the setupid
> > column, but not display the name on Size ID or hostgroup. ?
> > 
> > 
> > 
> > Id
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=&order=lv
> > storage.id&_signature=8dbb920c257181ac6fc35485619f4345c246c296>
> > 
> > 
> > 
> > Setup ID
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=&order=lv
> > storage.setup_id&_signature=a0a4d78cba448c29fc27a1706b56da0f45ccfba2>
> > 
> > 
> > 
> > Size ID
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=&order=lv
> > storage.lvsize_id&_signature=95b25e5d3ea2df3c36319851611869e9185708aa>
> > 
> > 
> > 
> > Lun ID
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=&order=lv
> > storage.lunid&_signature=7153b8a143e74e602bda43f31123a9606e21e24f>
> > 
> > 
> > 
> > Host Group
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage?keywords=&order=lv
> > storage.storagemap_id&_signature=eeb802acefa7a18bbd87fbda8f3d690578769d7e
> > >
> > 
> > 1
> > 
> > 
> > 
> > AN10 on frame 520-1
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 7
> > 
> > 
> > 
> > View
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/view/lvstorage/1?_
> > signature=145034e485ba2811bdd12f874e26cfe9144ce779>Edit
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/edit/lvstorage/1?
> > _signature=8de6c80354940b970b0af5f4c88e7a2f3e8f838c>Delete
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage#null>
> > 
> > 2
> > 
> > 
> > 
> > AN10 on frame 520-1
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 3
> > 
> > 
> > 
> > 7
> > 
> > 
> > 
> > View
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/view/lvstorage/2?_
> > signature=21b8a4286ba02217a3a4685bab985290e5eb0ec1>Edit
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/edit/lvstorage/2?
> > _signature=557572282c31c0a17c8a03e3c896198365771626>Delete
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage#null>
> > 
> > 3
> > 
> > 
> > 
> > AN10 on frame 520-1
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 4
> > 
> > 
> > 
> > 7
> > 
> > 
> > 
> > View
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/view/lvstorage/3?_
> > signature=17f856570c5acbb1b3513479589e6c64215e38fc>Edit
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage/edit/lvstorage/3?
> > _signature=d9871efc593f5ad4525ed3f290e92a7a7d150dc4>Delete
> > <http://127.0.0.1:8000/adeploy/formdb/modify_lvstorage#null>
> > 
> > The database table
> > 
> > db.define_table('lvstorage',
> > 
> > Field('setup_id', db.setup,
> > 
> > default=1,
> > 
> > label=T('Setup ID')),
> > 
> > Field('lvsize_id', db.lvsize,
> > 
> > default=2,
> > 
> > label=T('Size ID')),
> > 
> > Field('lunid', type='integer',
> > 
> > default=2,
> > 
> > label=T('Lun ID')),
> > 
> > Field('storagemap_id', db.storagemap,
> > 
> > default=1,
> > 
> > label=T('Host Group')),
> > 
> > Field('created_on','datetime',default=request.now,
> > 
> > label=T('Created On'),writable=False,readable=False),
> > 
> > Field('modified_on','datetime',default=request.now,
> > 
> > label=T('Modified On'),writable=False,readable=False,
> > 
> > update=request.now),
> > 
> > migrate=settings.migrate)
> > 
> > # Table rules
> > 
> > db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id',
> > 'setup.setupname')
> > 
> > db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id',
> > 'lvsize.sizename')
> > 
> > db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id',
> > 'storagemap.mapping')
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Controller
> > 
> > 
> > left =
> > (db.lvsize.on(db.lvstorage.lvsize_id==db.lvsize.id),db.storagemap.on(db.l
> > vstorage.storagemap_id==db.storagemap.id),db.setup.on(db.lvstorage.setup_
> > id==db.setup.id))
> > 
> > query = db.lvstorage.setup_id==usedsetupid
> > 
> > grid = SQLFORM.grid(query,
> > 
> > left = left,
> > 
> > csv = False
> > 
> > )
> > 
> > return dict(usedsetupid=usedsetupid, grid=grid)
> > 
> > > Now I think of it, you do not need to do a redirect because it
> > 
> > creates its
> > 
> > > own page based on the called page.
> > > 
> > > 
> > > 
> > > Its just that the submit does not do anything.
> > > 
> > > > SQLFORM.grid does not actually add the records automatically. It just
> > > > 
> > > > calls the grid controller with args action/table.
> > > > 
> > > > 
> > > > 
> > > > You have to do something like:
> > > > 
> > > > if request.args(0) in ("edit", "new"):
> > > > 
> > > > redirect(URL("edit.html", args=[request.args(1),
> > > > 
> > > > 
> > > > 
> > > > request.args(2)])
> > > > 
> > > > On Nov 2, 9:15 am, Mike Veltman <[email protected]> wrote:
> > > > > > are you able to see the form? or are you getting the "not
> > 
> > authorized
> > 
> > > > > > message?"
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > you can set user_signature=False or ensure that user is logged
> > > > > > in.
> > > > > 
> > > > > Thanks for the reaction. But no the form is generated perfectly.
> > > > > And
> > > > > 
> > > > > the user is logged in.
> > > > > 
> > > > > > On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman
> > 
> > <[email protected]>
> > 
> > > wrote:
> > > > > > > I have
> > > > > > > 
> > > > > > > grid =
> > 
> > SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,det
> > 
> > > > > > > ai ls=T rue,searchable=True)
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > That creates a form with the records with a add button. But
> > 
> > when I
> > 
> > > > > > > use add I
> > > > > > > 
> > > > > > > get the next screen but the record is not added. What do I
> > 
> > miss ?
> > 
> > > > > > > Btw is the same setup with a query possible with
> > 
> > SQLFORM.smartgrid
> > 
> > > > > > > ?
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > With regards,
> > > > > > > 
> > > > > > > Mike Veltman
> > > > > 
> > > > > With regards,
> > > > > 
> > > > > Mike Veltman
> > > 
> > > With regards,
> > > 
> > > Mike Veltman
> > 
> > With regards,
> > 
> > Mike Veltman

With regards,
Mike Veltman


Reply via email to