Re: [web2py] Re: A SQLFORM.grid question

2011-11-08 Thread Mike Veltman


I am wondering about that. mmm

On 11/03/2011 10:53 PM, apple wrote:

My mistake. I tend to redirect because I need some extra processing
but grid does actually produce a basic edit form. If you do use the
grid generated form then the submit should work as normal though. You
should check where it is failing - e.g. when you press submit is it
actually calling the controller?

On Nov 3, 2:16 am, Mike Veltman  wrote:

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  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

wrote:

I have
grid =
SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai
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




Re: [web2py] Re: A SQLFORM.grid question

2011-11-03 Thread Mike Veltman

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
> >  > storage.id&_signature=8dbb920c257181ac6fc35485619f4345c246c296>
> > 
> > 
> > 
> > Setup ID
> >  > storage.setup_id&_signature=a0a4d78cba448c29fc27a1706b56da0f45ccfba2>
> > 
> > 
> > 
> > Size ID
> >  > storage.lvsize_id&_signature=95b25e5d3ea2df3c36319851611869e9185708aa>
> > 
> > 
> > 
> > Lun ID
> >  > storage.lunid&_signature=7153b8a143e74e602bda43f31123a9606e21e24f>
> > 
> > 
> > 
> > Host Group
> >  > storage.storagemap_id&_signature=eeb802acefa7a18bbd87fbda8f3d690578769d7e
> > >
> > 
> > 1
> > 
> > 
> > 
> > AN10 on frame 520-1
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 2
> > 
> > 
> > 
> > 7
> > 
> > 
> > 
> > View
> >  > signature=145034e485ba2811bdd12f874e26cfe9144ce779>Edit
> >  > _signature=8de6c80354940b970b0af5f4c88e7a2f3e8f838c>Delete
> > 

Re: [web2py] Re: A SQLFORM.grid question

2011-11-03 Thread Jim Steil

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 





Setup ID 





Size ID 





Lun ID 





Host Group 



1



AN10 on frame 520-1



2



2



7



View 
Edit 
Delete 



2



AN10 on frame 520-1



2



3



7



View 
Edit 
Delete 



3



AN10 on frame 520-1



2



4



7



View 
Edit 
Delete 



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.lvstorage.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  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 



>

> 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 se

Re: [web2py] Re: A SQLFORM.grid question

2011-11-02 Thread Mike Veltman

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
Setup ID
Size ID
Lun ID
Host Group

1
AN10 on frame 520-1
2
2
7
ViewEditDelete
2
AN10 on frame 520-1
2
3
7
ViewEditDelete
3
AN10 on frame 520-1
2
4
7
ViewEditDelete

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.lvstorage.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  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 
> 
> 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




Re: [web2py] Re: A SQLFORM.grid question

2011-11-02 Thread Mike Veltman
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  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  
wrote:
> > > > I have
> > > > grid =
> > > > 
> > > > SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai
> > > > 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




Re: [web2py] Re: A SQLFORM.grid question

2011-11-02 Thread Mike Veltman

Actually that makes a lot of sense. It got caught of guard because edit does 
do it.

But with this you also answered my other question, how to change the default 
values in edit. :-)

Thanks !

> 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  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  
wrote:
> > > > I have
> > > > grid =
> > > > 
> > > > SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai
> > > > 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