[web2py] Re: Linking GRID records with other records in same GRID

2019-08-09 Thread Sarbjit
Any suggestions ? How can I get to the details page for any grid record 
without clicking on Details button (knowing the grid-id is not sufficient 
as the signature value is unique for every record)

On Wednesday, March 13, 2019 at 10:02:06 AM UTC-4, Sarbjit wrote:
>
> I am using SQLFORM.GRID to display the database records. In my 
> application, certain records may contain the reference to id of other 
> records. Currently, I have to use "search" option to find the record 
> matching reference id.
>
> What I want to do is :- Have a hyperlink in the reference field and then 
> open the details (View button equivalent) for the other record.Problem is 
> View button for each row in GRID has a unique _signature . In the absence 
> of this value, I can't form the hyperlink (view option) for other record. 
>
> How can I get the _signature value associated with GRID records? or is 
> there any way, I can access the Edit Page for a record from the GRID given 
> its ID.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/5ac45233-0edc-4d16-9c88-85cf9b3e9632%40googlegroups.com.


[web2py] Linking GRID records with other records in same GRID

2019-03-13 Thread Sarbjit
I am using SQLFORM.GRID to display the database records. In my application, 
certain records may contain the reference to id of other records. 
Currently, I have to use "search" option to find the record matching 
reference id.

What I want to do is :- Have a hyperlink in the reference field and then 
open the details (View button equivalent) for the other record.Problem is 
View button for each row in GRID has a unique _signature . In the absence 
of this value, I can't form the hyperlink (view option) for other record. 

How can I get the _signature value associated with GRID records?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Update text for GRID buttons - View/Edit etc

2019-03-12 Thread Sarbjit
Hello,

I want to change the default text of the buttons visible in SQLFORM.GRID. I 
am using the following code, but it is not updating the text

grid.element(_title='View')['innerHTML']='Details'

Any idea on how this can be done?

Thanks !

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Using REST API for uploading file

2019-03-04 Thread Sarbjit
In my actual app, I have multiple fields which needs to be populated along 
with file upload. I have never used CURL before, so I don't know how to 
handle this case. I can try with --data-binary but I am not sure if other 
fields will work.

On Monday, March 4, 2019 at 5:01:07 PM UTC-5, Dave S wrote:
>
>
>
> On Monday, March 4, 2019 at 11:22:19 AM UTC-8, Sarbjit wrote:
>>
>> Hello, 
>>
>> I am trying to use CURL to upload a file in the 'upload' field using REST 
>> services. But on using the command, some garbage is getting uploaded, even 
>> though it shows as type "file" but I could not download the file  (invalid 
>> request) and the URL becomes too lengthy (looks like the file contents are 
>> uploaded)
>>
>> Models
>>
>> db.define_table('test',  Field('date', 'datetime'),
>> Field('user'),
>> Field('upload_data','upload'))
>>
>> Controllers
>> 
>> @request.restful()
>> def api():
>> response.view = 'generic.json'
>>
>>
>> def GET(tablename, id):
>> if not tablename == 'test':
>> raise HTTP(400)
>> return dict(record = db.test(id))
>>
>>
>> def POST(tablename, **fields):
>> if not tablename == 'test':
>> raise HTTP(400)
>> return db.test.validate_and_insert(**fields)
>>
>>
>> return locals()
>>
>> CURL syntax
>>
>> curl POST -i -F upload_data=@somefile.zip http:
>> //:8000/testapp/default/api/test.json
>>
>>
>> Has anyone used the CURL to upload a file (zip file) with web2py?
>>
>  
>  You're using -F which is for Form data ... is that what you want?
>
> I use --data-binary for a zip file, to an NginX front end, and that works 
> just fine.  (-d does not work; my zip file gets truncated at the first 0, 
> and I think there's URL_ENCODING applied before that ).  Curl isn't the 
> usual client for my app -- instead, I use libcurl inside my app, which 
> doesn't seem to mind binary.  I do set the content-type header, and I 
> provide the size via CURLOPT_POSTFIELDSIZE_LARGE.
>
> /dps
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using REST API for uploading file

2019-03-04 Thread Sarbjit
Hello, 

I am trying to use CURL to upload a file in the 'upload' field using REST 
services. But on using the command, some garbage is getting uploaded, even 
though it shows as type "file" but I could not download the file  (invalid 
request) and the URL becomes too lengthy (looks like the file contents are 
uploaded)

Models

db.define_table('test',  Field('date', 'datetime'),
Field('user'),
Field('upload_data','upload'))

Controllers

@request.restful()
def api():
response.view = 'generic.json'


def GET(tablename, id):
if not tablename == 'test':
raise HTTP(400)
return dict(record = db.test(id))


def POST(tablename, **fields):
if not tablename == 'test':
raise HTTP(400)
return db.test.validate_and_insert(**fields)


return locals()

CURL syntax

curl POST -i -F upload_data=@somefile.zip http:
//:8000/testapp/default/api/test.json


Has anyone used the CURL to upload a file (zip file) with web2py?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to reuse the IS_IN_SET validator list in views and controllers?

2017-11-26 Thread Sarbjit
Thanks

On Sunday, November 26, 2017 at 10:59:11 AM UTC-5, Anthony wrote:
>
> In a model file:
>
> my_products = ['Type1', 'Type2', 'Type3']
>
> Because (non-conditional) models are executed on every request before any 
> controller or view, any objects defined in a model are available in any 
> controller or view -- so in a controller or view, just refer to the 
> my_products variable.
>
> You could of course also define the list in a module and import it 
> wherever needed.
>
> Anthony
>
> On Sunday, November 26, 2017 at 10:05:21 AM UTC-5, Sarbjit wrote:
>>
>> Hello,
>>
>> I have defined a IS_IN_SET validator inside my models. Now, I want to use 
>> the same list inside controllers and views. What is the best way to re-use 
>> the same list inside controllers and views without having to duplicate the 
>> code. Right now, I just copied the entire list inside my controller. So, if 
>> I have to change anything, I have to change it at two places.
>>
>> db.define_table('products',
>> Field('type'),
>> auth.signature)
>>
>> db.products.type.requires = IS_IN_SET(['Type1', 'Type2', 'Type3'])
>>
>> An example snippet  would be highly appreciated.
>>
>> Thanks !
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to reuse the IS_IN_SET validator list in views and controllers?

2017-11-26 Thread Sarbjit
Hello,

I have defined a IS_IN_SET validator inside my models. Now, I want to use 
the same list inside controllers and views. What is the best way to re-use 
the same list inside controllers and views without having to duplicate the 
code. Right now, I just copied the entire list inside my controller. So, if 
I have to change anything, I have to change it at two places.

db.define_table('products',
Field('type'),
auth.signature)

db.products.type.requires = IS_IN_SET(['Type1', 'Type2', 'Type3'])

An example snippet  would be highly appreciated.

Thanks !

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Question regarding building dynamic queries

2017-10-05 Thread Sarbjit


On Wednesday, October 4, 2017 at 9:02:07 PM UTC-4, Leonel Câmara wrote:
>
> This is sort of a python question.
>
> Lets see exactly what this means
>
> query &= db.orders.status == status.
>
> This syntax is a python (not web2py or the DAL) shorthand for:
>
> query = query & (db.orders.status == status)
>
>
> So really what you want is:
>
> query = db.orders.id_buyer == auth.user_id
> query1 = query & (db.orders.status == status)
> query2 = query & (db.orders.order_date <= initial_date)
>
>
Thanks for reply, I did try that before but it was not giving the correct 
results

I tried the following 

query = db.orders.id_buyer == auth.user_id
query1 = query & (db.orders.status == status)

On printing query1, it will print "False", while I want something like

print db(query1).count()

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Question regarding building dynamic queries

2017-10-04 Thread Sarbjit
I have some basic question regarding forming dynamic queries

As an example, lets say my base query is

query = db.orders.id_buyer == auth.user_id

Now I want to form two different queries like

query &= db.orders.status == status.  ===> Should form query1 and want to 
store it for later use

AND

query &= db.orders.order_date <= initial_date. ===> Should form query2 and 
want to store it for later use

I am not able to figure out how to store it in query1 and query2 without 
having to write the base query again intially. Right now, I am solving it 
like below :-

query1 = db.orders.id_buyer == auth.user_id
query1 &= db.orders.status == status

query2 = db.orders.id_buyer == auth.user_id
query2 &= db.orders.order_date <= initial_date

What I want to do ?

query = db.orders.id_buyer == auth.user_id

query1 &= db.orders.status == status AND USE query data, but how?
query2 &= db.orders.order_date <= initial_date AND USE query data, but how?

I hope the problem statement is clear.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: AttributeError: 'SQLite' object has no attribute 'file_open'

2017-08-04 Thread Sarbjit
Any workaround? I am kind of stuck in populating the test database

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] AttributeError: 'SQLite' object has no attribute 'file_open'

2017-08-02 Thread Sarbjit
Hello All,

I am trying to update the database for my web2py app using the command line 
script :-

Sample Code :-

# Assumption : script is placed inside scripts folder in application
scriptPath = os.path.dirname(os.path.realpath(__file__))
dbPath = os.path.abspath(os.path.join(scriptPath,"../databases"))
libraryPath = os.path.abspath(os.path.join(scriptPath,"../../.."))
sys.path.append(libraryPath)
from gluon import DAL
print dbPath, libraryPath
db = DAL('sqlite://storage.sqlite',folder=dbPath,auto_import=True)

I get the following error :-

Traceback (most recent call last):

  File "populate_database.py", line 19, in 

db = DAL('sqlite://storage.sqlite',folder=dbPath,auto_import=True)

  File 
"/Users/sarbjit/Data/development/python/web2py/gluon/packages/dal/pydal/base.py",
 
line 170, in __call__

obj = super(MetaDAL, cls).__call__(*args, **kwargs)

  File 
"/Users/sarbjit/Data/development/python/web2py/gluon/packages/dal/pydal/base.py",
 
line 500, in __init__

tables=tables)

  File 
"/Users/sarbjit/Data/development/python/web2py/gluon/packages/dal/pydal/base.py",
 
line 522, in import_table_definitions

tfile = self._adapter.file_open(filename, 'r')

AttributeError: 'SQLite' object has no attribute 'file_open'



If I remove the "auto_import" statement, then the connection works fine but 
the following statement fails


db.products.insert(**record)


AttributeError: 'DAL' object has no attribute 'products'


I am using latest web2py version on MAC.


Thanks in advance 

Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to rename the Edit and View button of SQLFORM.GRID

2015-05-04 Thread Sarbjit
I am able to do it using the below code :

grid = SQLFORM.GRID(...)
try:
for x in grid.elements('span.buttontext'):
if x.components[0] == "Edit":
x.components[0] = "New Edit"
if x.components[0] == "View":
x.components[0] = "New View"
except Exception : pass

Is there any better way to do it?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to rename the Edit and View button of SQLFORM.GRID

2015-05-03 Thread Sarbjit
Hi All,

I am looking for a way to rename the buttons - EDIT/VIEW from SQLFORM.GRID. 
Can someone please help me on this.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Updating multiple targets using AJAX callback

2015-04-27 Thread Sarbjit
Thanks Anthony !!

It worked.

On Sunday, April 26, 2015 at 8:33:55 PM UTC+5:30, Anthony wrote:
>
> Maybe try triggering the onchange event when dropdown2_a is changed. You 
> could do that by changing the dropdown1 Ajax call from:
>
> ajax('{{=URL('default', 'getoptionsfordropdown2'})}}', [''], 'dropdown2')
>
> to:
>
> ajax('{{=URL('default', 'getoptionsfordropdown2'})}}', [''], ':eval')
>
> Then in the getoptionsfordropdown2 function, instead of just returning the 
> select HTML, you can return Javascript code that changes the select HTML 
> and then triggers the onchange event. This is not tested, by something 
> along these lines:
>
> def getoptionsfordropdown2():
> html = [code to generate the select]
> return 'jQuery("#dropdown2").html("%s"); 
> jQuery("#dropdown2_a").change();' % html
>
> Anthony
>
> On Sunday, April 26, 2015 at 9:24:13 AM UTC-4, Sarbjit wrote:
>>
>> Hi,
>>
>> I have used AJAX based cascading drop down menu based on slice "
>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2
>> "
>>
>> I have introduced a third drop down whose value is populated based on the 
>> selection of second drop down.
>>
>> I am using the following code : (Not the exact code, but it'll be enough 
>> to explain the flow)
>>
>> *VIEWS:*
>>
>>   
>> onchange="jQuery('#dropdown2_a').empty();  
>> ajax('{{=URL('default','getoptionsfordropdown2'})}}', [''], 
>> 'dropdown2');">
>> ..
>> 
>> 
>>   
>> onchange="jQuery('#dropdown3_a').empty();  
>> ajax('{{=URL('default','getoptionsfordropdown3'})}}', [''], 
>> 'dropdown3');">
>> 
>> 
>> 
>>
>> 
>> 
>>
>> *CONTROLLER:*
>>
>> getoptionsfordropdown2/getoptionsfordropdown3:
>>
>> def ...
>>  query the db and build SELECT 
>> return SELECT(...)
>>
>>
>> *Problem:*
>>
>> So, at any point of time, if the option in the drop down1 is not changed, 
>> then everything works fine i.e. changes in dropdown2 updates the options in 
>> dropdown3.
>>
>> However, once the dropdown1 option is changed, dropdown3 contents are not 
>> RESET (No code for it, and I need some guidance for it). So, I have to 
>> change the option in dropdown2 and come-back in order to change the options 
>> in dropdown3. Basically, once an option is changed in drop down1, user has 
>> to change the option in dropdown2 once in order to update the dropdown3.
>>
>> Can someone please suggest me on how to handle this situation such that 
>> changing the dropdown1 should update dropdown3 as well (based on the value 
>> of dropdown2).
>>
>> Is it possible to call multiple forcefully trigger the onchange event for 
>> dropdown2 once it is re-populated based on the changes in dropdown1.
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Updating multiple targets using AJAX callback

2015-04-26 Thread Sarbjit
Hi,

I have used AJAX based cascading drop down menu based on slice 
"http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2";

I have introduced a third drop down whose value is populated based on the 
selection of second drop down.

I am using the following code : (Not the exact code, but it'll be enough to 
explain the flow)

*VIEWS:*

  
onchange="jQuery('#dropdown2_a').empty();  
ajax('{{=URL('default','getoptionsfordropdown2'})}}', [''], 'dropdown2');">
..


  
onchange="jQuery('#dropdown3_a').empty();  
ajax('{{=URL('default','getoptionsfordropdown3'})}}', [''], 'dropdown3');">



   



*CONTROLLER:*

getoptionsfordropdown2/getoptionsfordropdown3:

def ...
 query the db and build SELECT 
return SELECT(...)


*Problem:*

So, at any point of time, if the option in the drop down1 is not changed, 
then everything works fine i.e. changes in dropdown2 updates the options in 
dropdown3.

However, once the dropdown1 option is changed, dropdown3 contents are not 
RESET (No code for it, and I need some guidance for it). So, I have to 
change the option in dropdown2 and come-back in order to change the options 
in dropdown3. Basically, once an option is changed in drop down1, user has 
to change the option in dropdown2 once in order to update the dropdown3.

Can someone please suggest me on how to handle this situation such that 
changing the dropdown1 should update dropdown3 as well (based on the value 
of dropdown2).

Is it possible to call multiple forcefully trigger the onchange event for 
dropdown2 once it is re-populated based on the changes in dropdown1.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How can I modify the login form with Bootstrap

2015-02-24 Thread Sarbjit
Hi,

First of all, I am very sorry for asking this stupid question, but I have 
been learning Bootstrap and I just wanted to try it with the default 
scaffolding appliance.

I want to modify the default login form as per bootstrap style, so I used 
the following in my models :-

auth.settings.formstyle = 'bootstrap' 

Now, the login form in the web2py has different appearance compared with 
default theme. However, I have noticed that the button color is still grey, 
while it should be blue.

What I want is that my login form should be identical to :-

http://getbootstrap.com/2.3.2/examples/signin.html

Can someone please guide me on how to achieve this?

Any example would be appreciated. 
  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Launching modal form from onupdate callback (Grid)

2014-09-10 Thread Sarbjit
I tried the following such that when the user clicks on Submit button from 
the Grid edit form, it would open the dialog. -> But it just opens the 
dialog and in actual doesn't updates the db or performs the other checks.

grid.element(_type='submit')['_onclick']='%s;return false' %dialog1.show()

Derek, for the javascript , could you please provide some pointers, I don't 
have much experience in js.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Launching modal form from onupdate callback (Grid)

2014-09-09 Thread Sarbjit
I tried using the "dialog" element in the view, but this is also not 
working. Idea is that when the user submits the gird changes, the dialog 
will show (modal dialog). But the below code is not working, can some one 
please point out the problem.

{{if grid.update_form:}}
{{=grid.update_form.custom.begin}}
{{grid.element(_type='submit')['_onclick']='%s;return false' % 
dialog.show()}}
{{=grid}}
{{=grid.update_form.custom.end}}

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to add a check-box element in grid (update mode only) using view?

2014-09-09 Thread Sarbjit
I am looking for a example on adding a checkbox field for a grid in update 
mode only. This checkbox will be used for some decision at the time of form 
submission and hence I don't want to create a new field in database (since 
this field is useless there).

Is there any way, I can add a checkbox element using views?

{{if grid.update_form:}}
{{=grid.update_form.custom.begin}}
{{=grid}}

{{=grid.update_form.custom.end}}

Thanks
Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Launching modal form from onupdate callback (Grid)

2014-09-09 Thread Sarbjit
I am using the Dialog plugin from http://dev.s-cubism.com/plugin_dialog to 
display modal dialog form.

My requirement is that whenever the user edits the Grid record, then I 
should do some validation on the form contents (I'll be using onvalidate 
callback for my custom form validation).

Once the validation is complete, I want to display the form with some 
pre-populated fields, if the user accepts this modal form, then I'll run 
one external script in addition to updation of the grid data. If the user 
donot submit the form, it should just update the grid record.

*Example*

This is the example usage shown in the plugin doc.

def index():
dialog = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
close_button='close', renderstyle=True)
return dict(dialog=A('show dialog', _href='#',
 _onclick='%s;return false;' %dialog.show()))
 
def inner():
return DIV('OK!')

What I'm trying is :- (In onupdate callback) 

def myonupdate(form):
print 'update!'
dialog1 = DIALOG(LOAD(f='inner', ajax=True), title='Test', 
close_button='close', renderstyle=True)
dialog1.show()

*Problem :-*

It doesn't opens the modal form, while in the example on clicking button, a 
modal form does appears.

Is there any way, I can make this modal form to appear on editing the grid 
record or I can open a conformer dialog when the user is updating the grid 
such that I can run the additional external process if the answer is yes.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Document Expired/ Need to reload page on using browser back button

2014-08-31 Thread Sarbjit
Thanks a lot Anthony for the solution.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Document Expired/ Need to reload page on using browser back button

2014-08-29 Thread Sarbjit
Hi Anthony,

I am able to reproduce this problem in a small app (tested on windows - 
2.9.5).

*MODEL:*

db.define_table('Category',
Field('Name'),
Field('SubCategoryName'))
 
# Insert test data 
 
if db(db.Category.id>0).count() == 0:
db.Category.insert(Name='PC',SubCategoryName='Intel')
db.Category.insert(Name='PC',SubCategoryName='AMD')
db.Category.insert(Name='SmartPhone',SubCategoryName='Apple')
db.Category.insert(Name='SmartPhone',SubCategoryName='HTC')
db.Category.insert(Name='SmartPhone',SubCategoryName='Google')

*CONTROLLER:*

def index():
response.flash = T("Welcome to web2py!")
return dict(message=T('Hello World'))

def results():
if (request.vars.testval and session.var1):
try:
del session.var1
except Exception : pass
if (request.vars.var1) and (not session.var1):
   session.var1 = request.vars.var1
grid = {}
if session.var1:
query = (db.Category.Name==session.var1)
grid = SQLFORM.grid(query=query)
return dict(grid=grid)

*VIEWS:*

*results.html*

{{extend 'layout.html'}}
{{=grid}}

*index.html*

{{extend 'layout.html'}}


PC
Smart Phone





*Steps to reproduce the problem :-*

1. Select any value from the drop down and hit submit button.
2. Select any GRID row and click on View
3. Use Browser Back button -> Document will expire, you have to refresh to 
get the results back (Tried on Chrome/Firefox)
4. Repeat Step2
5. Now instead of using Browser back button, use GRID embedded back button.
6. Now repeating step 2-3 won't cause any problem (document won't expire) 
until the new selection is made from the selection drop down.

Please suggest something to resolve this problem. 

Thanks
Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Document Expired/ Need to reload page on using browser back button

2014-08-29 Thread Sarbjit
More Updates :

I tried debugging it using Eclipse and I observed that whenever the 
document expires, breakpoint is not hit. (results function).

Also I observed that once I use the Back button from within the grid field, 
it starts working from the browser also but only for current selection 
(from index controller).

If I change the selection from index and comes back to results - Then i 
face the same problem again - have to use back button from grid once, then 
browser button works fine for other grid entries.

Now any pointers on where to proceed?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Document Expired/ Need to reload page on using browser back button

2014-08-29 Thread Sarbjit
Hi Anthony,

Thanks for response.

It would be difficult for me to share the exact code (my company specific 
data and lot of extra code etc)

However, I am providing code snippets of the main portions that I feel are 
causing this problem  and work flow (i have changed the variable names):-

Please let me know, if you still require the exact code, then I'll try to 
reproduce it in a small app that can be shared as such.

*INDEX :*

index function from controllers returns options to be populated in select 
html column. It uses ajax callbacks to dynamically populate the select 
field.

{{extend 'layout.html'}}


...

...




Once the options are selected the results function is called :-

def results(): 
if (request.vars.testval and session.var1 and session.var2) or 
(len(request.vars) == 0):
try:
del session.var1
del session.var2
except Exception : pass
if (request.vars.var1) and (not session.var1):
   session.var1 = request.vars.var1
if request.vars.var2 and not session.var2:
   session.var2 = request.vars.var2

Then the session data is checked and a grid is created. Results view just 
displays the grid data.

Now from the grid data, when I select any row and uses browser back button, 
I get this problem.

Thanks
Sarbjit


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Document Expired/ Need to reload page on using browser back button

2014-08-28 Thread Sarbjit
I have an application having the layout as :-

INDEX controller generates a view which have some drop-down and calls 
another controller RESULTS :

Snippet :


Now the RESULTS controller creates a grid and populates the view 
corresponding to RESULT controller.

PROBLEM :-

When I view/edit any entry of GRID, then on using the browser back button, 
I get the following message :-

Document Expired (Firefox)
Need to conform form resubmissions (ERR_CACHE_MISS) -- Chrome

In the RESULTS controller, I just query request.vars for variables and 
store them in session and later on clear the session once the GRID is 
populated.

I don't see this problem if I use the BACK button provided by the GRID 
itself (URL contained a signature - Is it causing it to work?)

Can any one please suggest on how to address this problem. This is very 
annoying problem.

Thanks in advance
Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How do I serve static files with caching

2014-07-18 Thread Sarbjit
Thanks Anthony for quick response.

Are you saying if I use the URL with the mentioned syntax, then browser 
will cache static files automatically?

Because the fast_download technique that I used (picked from web2py 
application development cookbook) enables browser cache for database 
uploaded images.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How do I serve static files with caching

2014-07-18 Thread Sarbjit
Hi,

In my application, there are few static images which needs to be visible 
for all pages.

Currently, I am serving these files using the below code



Q1 :- Is it the right way to serve the image file?

Q2 :- How could I enable caching for these static files? Please note, I am 
using fast_download technique for database uploaded images, but I am not 
sure on if this can be used and how can be used?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Before update and After update callbacks are giving the same results on updating table

2014-07-09 Thread Sarbjit
Thanks Anthony :)

>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Before update and After update callbacks are giving the same results on updating table

2014-07-08 Thread Sarbjit
Hi All,

I want to detect if there is a change in auth_user table for 
registeration_key field. I have implemented the following code :-

Models :

db.auth_user._before_update.append(lambda s,f: before_trigger_auth(s,f))
db.auth_user._after_update.append(lambda s,f: after_trigger_auth(s,f))

Modules :

def before_trigger_auth(*args):
print args
print "before"
f = args[1]
rkey = f['registration_key']
current.session.before_rkey = rkey

def after_trigger_auth(*args):
print args
print "after"
f = args[1]
rkey = f['registration_key']
if current.session.before_rkey:
if current.session.before_rkey == "pending" and rkey == "":
del current.session.before_rkey
ruseremail = f['email']
print "Trigger an email update"


Now when I am editing the db.auth_user table record (using appadmin) to 
delete the pending word from registeration_key, I have noticed that the 
results from both and after callbacks were same i.e. registeration_key was 
empty. 

If I add the "pending" word in registration_key, then also I get the same 
results from both the after and before callbacks.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Any one intergrated Indian Payment Systems with web2py app?

2014-07-01 Thread Sarbjit
Thanks Kiran for the reply and sharing the knowledgeable link.

I found zaapakpay.com and payu.in to be promising. zaapakpay has their 
legal terms to accept an application which includes the application to be 
submitted on behalf of company and it is a must that the website should be 
an ecommerce store. 

I am building my application on own and is not affiliated with any company 
as such, I need the payment setup just for receiving the registration fees.

I do not have any experience with integration of payment gateway with 
website, Will it be possible for you to share an example code of payu 
integration, that might be useful for others as well.

Thanks in advance,
Sarbjit

On Tuesday, July 1, 2014 9:41:59 PM UTC+5:30, Kiran Subbaraman wrote:
>
>  I integrated a web2py app with payu (payu.com). Each of these payment 
> gateways have their own integration API. 
> This blog is a useful read: 
> http://gaganpreet.in/blog/2013/09/18/how-secure-are-indian-payment-gateways/
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Tue, 01-07-2014 8:24 PM, Sarbjit wrote:
>  
> Hi All,
>
> Has any one integrated Indian Payment System with web2py app. In India, 
> ccavenue seems to be more popular (http://www.ccavenue.com/quick.jsp) but 
> they doesn't appears to provide python support. 
>
> But apparently, I found few Django app's integarted with ccavenue on 
> google, has any one implemented any Indian Payment System with web2py.
>
> I am no-voice to Payment Integration.
>
> -Sarbjit
>  -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to web2py+un...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Any one intergrated Indian Payment Systems with web2py app?

2014-07-01 Thread Sarbjit
Hi All,

Has any one integrated Indian Payment System with web2py app. In India, 
ccavenue seems to be more popular (http://www.ccavenue.com/quick.jsp) but 
they doesn't appears to provide python support. 

But apparently, I found few Django app's integarted with ccavenue on 
google, has any one implemented any Indian Payment System with web2py.

I am no-voice to Payment Integration.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: auth.settings.register_next doesn't works with registration_requires_approval

2014-06-29 Thread Sarbjit

Thanks Massimo Di Pierro.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: auth.registrationkey, auth.password etc not visible in grid created from db.auth_user

2014-06-29 Thread Sarbjit
Thanks Anthony  and Massimo,

When I set the ignore_rw field, I could see these additional fields in the 
grid, however I am not able to set these fields to be visible in the header.

@auth.requires_login()  
def manageusers():
grid = 
SQLFORM.grid(db.auth_user,ignore_rw=True,fields=(db.auth_user.first_name,db.auth_user.last_name,db.auth_user.email,db.auth_user.registration_key,))
return dict(grid=grid)  


Is there anything else that I need to set. 

@Massimo,

Actually, I want that the admin of the site should be able to manage users 
without using the appadmin (admin panel is disabled in production).

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] auth.registrationkey, auth.password etc not visible in grid created from db.auth_user

2014-06-28 Thread Sarbjit
Hi,

I want to create a grid for db.auth_user (just like appadmin) where the 
admin would be able to approve the user accounts.

@auth.requires_login()  
def manageusers():
grid = SQLFORM.grid(db.auth_user)
return dict(grid=grid)  

In the grid generated by the above code, there are no registration key, 
passwords field etc which are visible in appadmin db.auth_user table.

How can I make this available here in grid especially registerationkey.

Thanks
Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] auth.settings.register_next doesn't works with registration_requires_approval

2014-06-28 Thread Sarbjit
Hi,

I want to send an email to the user stating that there account approval is 
in process. So, I set the following in db.py :-

auth.settings.register_next = URL('Welcome')
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.settings.reset_password_requires_verification = True

But, after registration only flash message appears and "welcome" function 
is not called in controller.

Can anyone please suggest on how this can be achieved?

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Customizing auth.navbar function

2014-06-24 Thread Sarbjit
Hi All,

I want to customize the auth.navbar function (basically I want to add new 
option when the user is logged-in and also want to modify the text 
"Register"). So, I followed the following approach :-

- Created a new function (by using the source code from tools.py) in a 
separate file in modules.
- Imported the new function and replaced auth.navbar

CODE :- (There is no modification as of now in customnavbar)
#
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from apputils import customnavbar
auth = Auth(db)
auth.navbar = customnavbar 


When I load the application, I get the following error :- (In layout, I 
have used auth.navbar())

 customnavbar() takes at least 1 argument (0 
given)
Can some one please help.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: ajax based cascading drop down menus not working in internet explorer

2014-06-18 Thread Sarbjit
Solved !!

I have used second select inside  and assigned id to it, it seems 
ajax callback was not able to replace  in IE.
OLD :-


{{for maker in makers:}}

{{=maker.Name}}
{{pass}}


NEW CODE :-


{{for maker in makers:}}

{{=maker.Name}}
{{pass}}



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py slices: cascading drop down lists with ajax 2

2014-06-18 Thread Sarbjit
Hi Omi,

I do not see this recipe working on IE-9. I have used this code in a newly 
created app and I observed that the second drop down is not populated on 
changing value in first drop down. It appears that the data is returned by 
ajax callback but is not getting replaced somehow.

-Sarbjit
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: ajax based cascading drop down menus not working in internet explorer

2014-06-18 Thread Sarbjit
This problem can be reproduced by using this code in a new app created 
using web2py.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] ajax based cascading drop down menus not working in internet explorer

2014-06-18 Thread Sarbjit
I am using the web2py slice from 
http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2.

I noticed that the second drop down is getting populated correctly on 
firefox but on internet explorer, it is not working (Tested on IE9).

I verified that on IE, on changing the value, an additional select 
statement is seen which seems to be causing the issue :-

IE Debug Snapshot (Before any change in selection)



IE Debug Snapshot (After change in first drop down)



Can anyone please help to resolve this on IE

*Views*

{{extend 'layout.html'}}



{{for category in categories:}}

{{=category.Name}}

{{pass}}


{{for maker in makers:}}

{{=maker.Name}}
{{pass}}




*Controller :*

def index():
print request.vars
grid = {}
if request.vars.maker_name:
query = (db.Product.Maker_ID==request.vars.maker_name)
grid = 
SQLFORM.grid(query=query,csv=False,create=False,deletable=False,)
lists = 
db(db.Product.Maker_ID==request.vars.maker_name).select(db.Product.ALL)
themakers = 
db(db.Maker.id==request.vars.maker_name).select(db.Maker.ALL)  
else:
lists = db(db.Product.Maker_ID==1).select(db.Product.ALL)
themakers = db(db.Maker.id==1).select(db.Maker.ALL)
categories = db().select(db.Category.ALL)
if request.vars.category_name:
makers = 
db(db.Maker.Category_ID==request.vars.category_name).select(db.Maker.ALL)
else:
makers = db(db.Maker.Category_ID==1).select(db.Maker.ALL)
return dict(lists=lists, categories=categories, makers=makers, 
themakers=themakers, grid=grid)

def maker():
makers = 
db(db.Maker.Category_ID==request.vars.category_name).select(db.Maker.ALL)
result = ""
for maker in makers:
result += "" + maker.Name + 
""  
result += ""
return XML(result)

*Models :*

db.define_table('Category',
Field('Name'))

db.define_table('Maker',
Field('Name'),
Field('Category_ID', db.Category),
Field('Note', 'text'))

db.define_table('Product',
Field('Part_Number'),
Field('Maker_ID', db.Maker),
Field('List_Price', 'decimal(13,2)'),
Field('Special_Price', 'decimal(13,2)'))

db.Category.Name.requires = IS_NOT_EMPTY()
db.Maker.Name.requires = IS_NOT_EMPTY()
db.Maker.Category_ID.requires = IS_IN_DB(db, db.Category.id, '%(Name)s')
db.Product.Part_Number.requires = IS_NOT_EMPTY()
db.Product.Maker_ID.requires = IS_IN_DB(db, db.Maker.id, '%(Name)s')

if db(db.Category.id>0).count() == 0:
db.Category.insert(Name='PC')
db.Category.insert(Name='Smart Phone')

db.Maker.insert(Name='Toshiba', Category_ID=1, Note='Good Maker')
db.Maker.insert(Name='HP', Category_ID=1, Note='Good Maker')
db.Maker.insert(Name='Dell', Category_ID=1, Note='Good Maker')
db.Maker.insert(Name='Apple', Category_ID=2, Note='Good Maker')
db.Maker.insert(Name='Samsung', Category_ID=2, Note='Good Maker')

db.Product.insert(Part_Number='Toshiba Product A', Maker_ID=1, 
List_Price=1000, Special_Price=500)
db.Product.insert(Part_Number='Toshiba Product B', Maker_ID=1, 
List_Price=1500, Special_Price=1000)
db.Product.insert(Part_Number='Toshiba Product C', Maker_ID=1, 
List_Price=2000, Special_Price=1500)
db.Product.insert(Part_Number='Toshiba Product D', Maker_ID=1, 
List_Price=2500, Special_Price=2000)
db.Product.insert(Part_Number='Toshiba Product E', Maker_ID=1, 
List_Price=3000, Special_Price=2500)
db.Product.insert(Part_Number='Toshiba Product F', Maker_ID=1, 
List_Price=3500, Special_Price=3500)

db.Product.insert(Part_Number='HP Product A', Maker_ID=2, 
List_Price=1000, Special_Price=500)
db.Product.insert(Part_Number='HP Product B', Maker_ID=2, 
List_Price=1500, Special_Price=1000)
db.Product.insert(Part_Number='HP Product C', Maker_ID=2, 
List_Price=2000, Special_Price=1500)
db.Product.insert(Part_Number='HP Product D', Maker_ID=2, 
List_Price=2500, Special_Price=2000)
db.Product.insert(Part_Number='HP Product E', Maker_ID=2, 
List_Price=3000, Special_Price=2500)
db.Product.insert(Part_Number='HP Product F', Maker_ID=2, 
List_Price=3500, Special_Price=3500)

db.Product.insert(Part_Number='Dell Product A', Maker_ID=3, 
List_Price=1000, Special_Price=500)
db.Product.insert(Part_Number='Dell Product B', Maker_ID=3, 
List_Price=1500, Special_Price=1000)
db.Product.insert(Part_Number='Dell Product C', Maker_ID=3, 
List_Price=2000, Special_Price=1500)
db.Product.insert(Part_Number='Dell Product D', Maker_ID=3, 
List_Price=2500, Special_Price=2000)
db.Product.insert(Part_Number='Dell Product E', Maker_ID=3, 
List_Price=3000, Special_Price=2500)
db.Product.insert(Part_Number='Dell Product F', Maker_ID=3, 
List_Price=3500, Special_Price=3500)

db.Product.insert(Part_Number='Apple Product A', Maker_ID=4, 
List_Price=1000, Special_Price=500)
db.Product.insert(Part_Number='Apple Product B', Maker_ID=4, 
List_Price=1500, Spe

[web2py] Re: How to control style formatting in views

2014-06-17 Thread Sarbjit
Solved it using :

form.element(_type='submit')['_class']='btn'

On Tuesday, June 17, 2014 4:06:24 PM UTC+5:30, Sarbjit wrote:
>
> I am trying to adapt a custom css/js template to web2py plugin. I see that 
> in the user login form, submit button is not having class : btn,
>
>
> <https://lh6.googleusercontent.com/-lr0dTa-A5UM/U6AZIPTRWfI/AJM/b-x-QYcESmQ/s1600/Capture.PNG>
>
>
> So, in user login page, I see Login button in very small format while 
> 'register' and 'Lost Password' are seen in proper format. I checked with 
> firebug that the later two buttons are having class='btn', while Login 
> button is missing it.
>
> Is there a way that I could add the class attribute for this button.
>
> I tried the following in views : (user.html)
>
> =form.element('select[value=Login]')['_style']='class:"btn"'
> =form
>
> But it gives an error, can some one please help me to add the class 
> attribute on the form submit button
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to control style formatting in views

2014-06-17 Thread Sarbjit
I am trying to adapt a custom css/js template to web2py plugin. I see that 
in the user login form, submit button is not having class : btn,




So, in user login page, I see Login button in very small format while 
'register' and 'Lost Password' are seen in proper format. I checked with 
firebug that the later two buttons are having class='btn', while Login 
button is missing it.

Is there a way that I could add the class attribute for this button.

I tried the following in views : (user.html)

=form.element('select[value=Login]')['_style']='class:"btn"'
=form

But it gives an error, can some one please help me to add the class 
attribute on the form submit button

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: one more web2py e-commerce app :)

2014-06-15 Thread Sarbjit
Hi Adi,

I visited the nammuhats.com, its a fantastic site. I just want to know 
whether you are using woocommerce plugin (wordpress plugin) in this site or 
using woocommerce template in it?

Can you give some pointers on how to adapt woocommerce plugin to web2py app.

Thanks
Sarbjit

On Thursday, October 10, 2013 4:40:32 AM UTC+5:30, Adi wrote:
>
>
> :) 
>
> There are only few hats left in this color, so they are just on small 
> special now, but we also send absolutely free hat to anyone who's going 
> through chemotherapy <http://nammuhats.com/page_view/6/Chemotherapy-Hats> 
> treatment. 
>
>
> On Wed, Oct 9, 2013 at 6:26 PM, Derek > 
> wrote:
>
>> Why is a light purple hat $2 less than a white one?
>>
>>   

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Can I include wordpress plugin in web2py (e.g. woocommerce) ?

2014-06-14 Thread Sarbjit
Is it possible to include wordpress plugins in web2py? I want to use 
"woocommerce" (link ) theme 
(look and feel for web2py app).

I saw that http://www.nammuhats.com/ is listed as being developed using 
web2py but this site seems to be using woocommerce themes etc.

Is it possible to integrate the front end side of woocommerce theme in 
web2py?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Problem using multiple grids in single view

2014-06-11 Thread Sarbjit
*Thanks Stifan and *














*LaDarrius Stewart !!By using the formnames, I don't see the issues of both 
the grids displaying the same data. However, I am still not able to use 
custom grid (grid1) i.e. I want to use custom grid in view_form mode.Code 
(test1.load){{if grid1.view_form:}}test{{else:}}{{=grid1}}{{pass}}Rest code 
is same as mentioned in my second approach with a difference that each grid 
is having formname.*
Can you please check if my test1.load code is correct?

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Problem using multiple grids in single view

2014-06-10 Thread Sarbjit
Can some one please conform if it would be possible to use multiple grids 
in single view using web2py as LOAD doesn't seems to give the expected 
results.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Grid data is not displayed on using Edit/View in case there are two grids in one view

2014-06-09 Thread Sarbjit
I am using two grids in my application but I have observed that when I use 
Edit/View button for GRID1, then the layout of the grid is not proper (Data 
from Grid1 is not seen) and default layout doesn't seems to be loaded.

NOTE :-

Since web2py doesn't supports two grids in one view, I am using LOAD for 
one gird and second grid is loaded directly. 

Reason, I want to display second grid directly is that I want to customize 
the edit function for the grid.

Below is the sample Code 

*Views :*

{{extend 'layout.html'}}
{{if grid.view_form:}}
{{=grid}}
{{elif grid.update_form:}}
{{=grid}}
{{else:}}
{{=grid}}
{{=LOAD('default','loadGrid1',ajax=True)}}
{{pass}}

*Controller :*

@auth.requires_login()  
def index():
grid = 
SQLFORM.grid(query=db.person,csv=False,create=False,deletable=False,paginate=20,sortable=True)
return dict(grid=grid)

def loadGrid1():
grid1 = 
SQLFORM.grid(query=db.dog,csv=False,create=False,deletable=False,paginate=20,sortable=True)


return grid1

*Model :*

db.define_table('person', 
Field('name'), 
Field('countyry'))

db.define_table('dog',
Field('name'),
    Field('ownername'))Models :

Can someone please help me to resolve this issue.

Thanks
Sarbjit


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Formatting GRID rows data based on the field value in database

2014-06-08 Thread Sarbjit
Thanks Anthony,

I have used the Images in the represent field for my application.

On Sunday, June 8, 2014 7:59:52 AM UTC+5:30, Anthony wrote:
>
> Note, it would be more appropriate to use "lambda status, row:", as the 
> second value passed to the represent function is the Row object (not the 
> Field object). You might be thinking of custom validators, which are passed 
> the value being validated and the Field object.
>
> Anthony
>
> On Saturday, June 7, 2014 8:52:22 PM UTC-4, 黄祥 wrote:
>>
>> yes, you are right, my fault, my code only produce one color, thank you 
>> so much for your detail explaination, anthony.
>> e.g.
>> if 'product' in request.function :
>> table.status.represent = lambda status, field: SPAN(status, 
>> _class = 'text-success' if status == 'Sold' else 'text-warning' if status 
>> == 'Hold' else 'text-error')
>>
>> best regards,
>> stifan
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Formatting GRID rows data based on the field value in database

2014-06-06 Thread Sarbjit
Thanks Anthony, 

Can you please provide a small example.

On Friday, June 6, 2014 6:03:29 PM UTC+5:30, Anthony wrote:
>
> You can set the "represent" attribute for the fields you would like to 
> format.
>
> Anthony
>
> On Friday, June 6, 2014 1:31:06 AM UTC-4, Sarbjit wrote:
>>
>> Hi,
>>
>> I am using GRID in my application, my requirement is that I want to 
>> display the field value in different color (RED/GREEN) OR I want to display 
>> the images (Tick Mark Image/Cross Mark Image) based upon the data in the 
>> field.
>>
>> e.g. (Sample example)
>>
>> Product_ID  Product_TitleProduct_SignOff
>> 1   XZ   Yes
>> 2   AV   Yes
>> 3   AD   NO
>>
>> I want it to be viewed in gird as :
>>
>> Product_ID  Product_TitleProduct_SignOff
>> 1   XZ   Yes
>> 2   AV   Yes
>> 3   AD   NO
>>
>> OR
>>  any other additional indicator could be added such that the rows with 
>> Signoff value as NO could be easily identified (or highlighted). I was 
>> wondering, if I could use some images there (Green color Tick mark or Red 
>> color Cross mark) in the grid.
>>
>> Since, I am not having much experience using web2py, can someone please 
>> help me to achieve this.
>>
>> Thanks
>> Sarbjit
>>
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Formatting GRID rows data based on the field value in database

2014-06-05 Thread Sarbjit
Hi,

I am using GRID in my application, my requirement is that I want to display 
the field value in different color (RED/GREEN) OR I want to display the 
images (Tick Mark Image/Cross Mark Image) based upon the data in the field.

e.g. (Sample example)

Product_ID  Product_TitleProduct_SignOff
1   XZ   Yes
2   AV   Yes
3   AD   NO

I want it to be viewed in gird as :

Product_ID  Product_TitleProduct_SignOff
1   XZ   Yes
2   AV   Yes
3   AD   NO

OR
 any other additional indicator could be added such that the rows with 
Signoff value as NO could be easily identified (or highlighted). I was 
wondering, if I could use some images there (Green color Tick mark or Red 
color Cross mark) in the grid.

Since, I am not having much experience using web2py, can someone please 
help me to achieve this.

Thanks
Sarbjit




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to improve performance for db queries

2014-05-26 Thread Sarbjit
Hi Anthony,

Problem of drop down's not working can be seen with the code/data posted in 
the original slice can be seen with the following changes.

*Controller :*

def index():
grid = {}
if request.vars.maker_name:
query = (db.Product.Maker_ID==request.vars.maker_name)
grid = 
SQLFORM.grid(query=query,csv=False,create=False,deletable=False,)
lists = 
db(db.Product.Maker_ID==request.vars.maker_name).select(db.Product.ALL)
themakers = 
db(db.Maker.id==request.vars.maker_name).select(db.Maker.ALL)  
else:
lists = db(db.Product.Maker_ID==1).select(db.Product.ALL)
themakers = db(db.Maker.id==1).select(db.Maker.ALL)
categories = db().select(db.Category.ALL)
if request.vars.category_name:
makers = 
db(db.Maker.Category_ID==request.vars.category_name).select(db.Maker.ALL)
else:
makers = db(db.Maker.Category_ID==1).select(db.Maker.ALL)
return dict(lists=lists, categories=categories, makers=makers, 
themakers=themakers, grid=grid)


*Views:*

{{extend 'layout.html'}}
 


{{for category in categories:}}

{{=category.Name}}

{{pass}}

 

{{for maker in makers:}}

{{=maker.Name}}
{{pass}}



 
{{=grid}}


Now when the results are displayed in the grid, on selecting the view 
option (you may have to click on submit again to view the results). After 
view grid record option is used, changes made in drop down's are not 
reflected upon submit i.e if the product name is changed from the drop 
down, new grid results are not seen.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to improve performance for db queries

2014-05-23 Thread Sarbjit
HI Anthony,

Changes suggested by you in the controller to reduce the complexity of the 
function actually worked, now the drop down options are changed instantly.

However, I am observing one strange problem now. Somehow the "getResults()" 
function is not called when the drop down options are changed from within 
the GRID view/edit pages.

So, basically in my form, I am displaying the results as GRID. Once, I get 
the results from grid based on the options selected in drop-downs, If I 
open any record from grid using VIEW/EDIT option from GRID, second drop 
down is never populated. Infact I noticed that this function is not called 
if I am inside the view/edit option. 

Do you have any idea on what could be the problem.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to improve performance for db queries

2014-05-22 Thread Sarbjit
Yes, In-fact the data is expected to change once in week. 


Regarding Index on table, I know DAL doesn't provides a direct way of doing 
it, my question is once i have created an index on my table, do i need to 
modify anything in my controller?

-Sarbjit

On Thursday, May 22, 2014 7:54:54 PM UTC+5:30, Kiran Subbaraman wrote:
>
>  In addition to this, and assuming that the data doesn't change 
> frequently (days vs minutes), maybe a select-cache, with TTL of 24 hours 
> would help?
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Caching-selects
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Thu, 22-05-2014 7:39 PM, Anthony wrote:
>  
> First, you can simplify your function as follows:
>
>  def getResults():
> tab2results = db(db.Table2.Release == request.vars.release_name).
> select(
>  db.Table2.id, db.Table2.Year, orderby=~db.Table2.id)
> return SELECT([OPTION(r.Year, _value=r.id) for r in tab2results],
>   _name='table2_name')
>  
> I assume request.vars.release_name is actually the db.Table1 id field 
> value, not a string name, correct (otherwise, the query won't work)?
>
> In the above, insert "return BEAUTIFY(db._timings)" before the final 
> return, and call the function directly in a browser tab, with 
> release_name=[some id] in the query string. See how long the above query is 
> taking in that case. If the query itself is taking several seconds, try 
> creating an index on the "Release" field.
>
> Anthony
>
> On Thursday, May 22, 2014 9:38:56 AM UTC-4, Sarbjit wrote: 
>>
>>  Below is the snippets from code (I have changed few field names as I 
>> can't share the exact field names)
>>
>> --> Data base
>>
>> db.define_table('Table1',
>> Field('Release'),
>> format='%(Release)s')
>> 
>> db.define_table('Table2',
>> Field('Release',db.Table1),
>> Field('Year'),
>> format='%(Year)s')
>> 
>> db.define_table('Table3',
>> Field('Manfucturer',writable=False),
>> Field('MID'),
>> Field('Year',db.Table2,writable=False),
>> Field('Engineer'),
>> Field('Location',writable=False),
>> Field('Title',writable=False),
>> Field('Description','text'),
>> Field('City',writable=False))
>> 
>> 
>> db.Table2.Release.requires = IS_IN_DB(db,db.Table1.id,'%(Release)s')
>> db.Table3.Year.requires = IS_IN_DB(db,db.Table2.id,'%(Year)s')
>>
>> --> This function is called by AJAX on change of first option in drop down
>>
>> def getResults():
>> tab2results = 
>> db(db.Table2.Release==request.vars.release_name).select(orderby=~
>> db.Table2.id)
>> result = ""
>> for tab2 in tab2results:
>> print tab2
>> result += "" + tab2.Year + 
>> ""  
>> result += ""
>> return XML(result)
>>
>> No, I don't have an index for the table.
>>
>>
>> On Thursday, May 22, 2014 6:50:02 PM UTC+5:30, Anthony wrote: 
>>>
>>> Would still help to see your specific model code. Is the field in 
>>> question a reference field with a "represent" attribute? If so, you'll get 
>>> separate queries for each item in order to lookup the represent value. How 
>>> many records in the table? Do you have an index on the field being 
>>> searched? If you execute the same query in a separate DB client, how long 
>>> does it take?
>>>
>>> Anthony
>>>
>>> On Thursday, May 22, 2014 8:37:55 AM UTC-4, Sarbjit wrote: 
>>>>
>>>> Hi Anthony, 
>>>>
>>>> Code is almost identical to the code posted in slice with change in 
>>>> field names and number of records. Only additonal difference is that I am 
>>>> using "orderby" in the query before returing the results.
>>>>
>>>> Surprisingly, sometime the result appears fast (within 2-3 seconds) but 
>>>> some time it takes long time to populate it.
>>>>
>>>> -Sarbj

[web2py] Re: How to improve performance for db queries

2014-05-22 Thread Sarbjit
Thanks Anthony, 

I will try and will update.

I am new to web2py (web apps in general). Could you please provide me an 
example on how to create index on table and once created, what changes i 
have to do in controller, do i need to change the getResults function?

-Sarbjit

On Thursday, May 22, 2014 7:39:48 PM UTC+5:30, Anthony wrote:
>
> First, you can simplify your function as follows:
>
> def getResults():
> tab2results = db(db.Table2.Release == request.vars.release_name).
> select(
>  db.Table2.id, db.Table2.Year, orderby=~db.Table2.id)
> return SELECT([OPTION(r.Year, _value=r.id) for r in tab2results],
>   _name='table2_name')
>
> I assume request.vars.release_name is actually the db.Table1 id field 
> value, not a string name, correct (otherwise, the query won't work)?
>
> In the above, insert "return BEAUTIFY(db._timings)" before the final 
> return, and call the function directly in a browser tab, with 
> release_name=[some id] in the query string. See how long the above query is 
> taking in that case. If the query itself is taking several seconds, try 
> creating an index on the "Release" field.
>
> Anthony
>
> On Thursday, May 22, 2014 9:38:56 AM UTC-4, Sarbjit wrote:
>>
>> Below is the snippets from code (I have changed few field names as I 
>> can't share the exact field names)
>>
>> --> Data base
>>
>> db.define_table('Table1',
>> Field('Release'),
>> format='%(Release)s')
>> 
>> db.define_table('Table2',
>> Field('Release',db.Table1),
>> Field('Year'),
>> format='%(Year)s')
>> 
>> db.define_table('Table3',
>> Field('Manfucturer',writable=False),
>> Field('MID'),
>> Field('Year',db.Table2,writable=False),
>> Field('Engineer'),
>> Field('Location',writable=False),
>> Field('Title',writable=False),
>> Field('Description','text'),
>> Field('City',writable=False))
>> 
>> 
>> db.Table2.Release.requires = IS_IN_DB(db,db.Table1.id,'%(Release)s')
>> db.Table3.Year.requires = IS_IN_DB(db,db.Table2.id,'%(Year)s')
>>
>> --> This function is called by AJAX on change of first option in drop down
>>
>> def getResults():
>> tab2results = 
>> db(db.Table2.Release==request.vars.release_name).select(orderby=~
>> db.Table2.id)
>> result = ""
>> for tab2 in tab2results:
>> print tab2
>> result += "" + tab2.Year + 
>> ""  
>> result += ""
>> return XML(result)    
>>
>> No, I don't have an index for the table.
>>
>>
>> On Thursday, May 22, 2014 6:50:02 PM UTC+5:30, Anthony wrote:
>>>
>>> Would still help to see your specific model code. Is the field in 
>>> question a reference field with a "represent" attribute? If so, you'll get 
>>> separate queries for each item in order to lookup the represent value. How 
>>> many records in the table? Do you have an index on the field being 
>>> searched? If you execute the same query in a separate DB client, how long 
>>> does it take?
>>>
>>> Anthony
>>>
>>> On Thursday, May 22, 2014 8:37:55 AM UTC-4, Sarbjit wrote:
>>>>
>>>> Hi Anthony, 
>>>>
>>>> Code is almost identical to the code posted in slice with change in 
>>>> field names and number of records. Only additonal difference is that I am 
>>>> using "orderby" in the query before returing the results.
>>>>
>>>> Surprisingly, sometime the result appears fast (within 2-3 seconds) but 
>>>> some time it takes long time to populate it.
>>>>
>>>> -Sarbjit
>>>>
>>>> On Thursday, May 22, 2014 4:46:55 PM UTC+5:30, Anthony wrote:
>>>>>
>>>>> Would help to see some code. 4-5 seconds sounds much too long.
>>>>>
>>>>> You might also look into 
>>>>> http://dev.s-cubism.com/plugin_lazy_options_widget.
>>>>>
>>>>> Anthony
>>>>>
>>>>>

[web2py] Re: How to improve performance for db queries

2014-05-22 Thread Sarbjit
Below is the snippets from code (I have changed few field names as I can't 
share the exact field names)

--> Data base

db.define_table('Table1',
Field('Release'),
format='%(Release)s')

db.define_table('Table2',
Field('Release',db.Table1),
Field('Year'),
format='%(Year)s')

db.define_table('Table3',
Field('Manfucturer',writable=False),
Field('MID'),
Field('Year',db.Table2,writable=False),
Field('Engineer'),
Field('Location',writable=False),
Field('Title',writable=False),
Field('Description','text'),
Field('City',writable=False))


db.Table2.Release.requires = IS_IN_DB(db,db.Table1.id,'%(Release)s')
db.Table3.MID.requires = IS_IN_DB(db,db.Table2.id,'%(MID)s')

--> This function is called by AJAX on change of first option in drop down

def getResults():
tab2results = 
db(db.Table2.Release==request.vars.release_name).select(orderby=~db.Table2.id)
result = ""
for tab2 in tab2results:
print tab2
result += "" + tab2.Year + 
""  
result += ""
return XML(result)

No, I don't have an index for the table.


On Thursday, May 22, 2014 6:50:02 PM UTC+5:30, Anthony wrote:
>
> Would still help to see your specific model code. Is the field in question 
> a reference field with a "represent" attribute? If so, you'll get separate 
> queries for each item in order to lookup the represent value. How many 
> records in the table? Do you have an index on the field being searched? If 
> you execute the same query in a separate DB client, how long does it take?
>
> Anthony
>
> On Thursday, May 22, 2014 8:37:55 AM UTC-4, Sarbjit wrote:
>>
>> Hi Anthony, 
>>
>> Code is almost identical to the code posted in slice with change in field 
>> names and number of records. Only additonal difference is that I am using 
>> "orderby" in the query before returing the results.
>>
>> Surprisingly, sometime the result appears fast (within 2-3 seconds) but 
>> some time it takes long time to populate it.
>>
>> -Sarbjit
>>
>> On Thursday, May 22, 2014 4:46:55 PM UTC+5:30, Anthony wrote:
>>>
>>> Would help to see some code. 4-5 seconds sounds much too long.
>>>
>>> You might also look into 
>>> http://dev.s-cubism.com/plugin_lazy_options_widget.
>>>
>>> Anthony
>>>
>>> On Thursday, May 22, 2014 12:17:42 AM UTC-4, Sarbjit wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am using cascading drop-down based on the slice posted on "
>>>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2";.
>>>>  
>>>> In my application, the number of sub-records for drop-down are typically 
>>>> in 
>>>> range of 50-60, so every-time I change the first option in drop down, it 
>>>> takes significant time (around 4-5 seconds) to populate my second drop 
>>>> down.
>>>>
>>>> I was wondering if there is a way to make this fast by means of caching 
>>>> or by storing the data for all the records the first time when user logs 
>>>> into the system and then using that data. Can some one please comment on 
>>>> how to address this problem and if possible, an example would be helpful.
>>>>
>>>> -Sarbjit
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to improve performance for db queries

2014-05-22 Thread Sarbjit
Hi Anthony, 

Code is almost identical to the code posted in slice with change in field 
names and number of records. Only additonal difference is that I am using 
"orderby" in the query before returing the results.

Surprisingly, sometime the result appears fast (within 2-3 seconds) but 
some time it takes long time to populate it.

-Sarbjit

On Thursday, May 22, 2014 4:46:55 PM UTC+5:30, Anthony wrote:
>
> Would help to see some code. 4-5 seconds sounds much too long.
>
> You might also look into 
> http://dev.s-cubism.com/plugin_lazy_options_widget.
>
> Anthony
>
> On Thursday, May 22, 2014 12:17:42 AM UTC-4, Sarbjit wrote:
>>
>> Hi,
>>
>> I am using cascading drop-down based on the slice posted on "
>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2";.
>>  
>> In my application, the number of sub-records for drop-down are typically in 
>> range of 50-60, so every-time I change the first option in drop down, it 
>> takes significant time (around 4-5 seconds) to populate my second drop down.
>>
>> I was wondering if there is a way to make this fast by means of caching 
>> or by storing the data for all the records the first time when user logs 
>> into the system and then using that data. Can some one please comment on 
>> how to address this problem and if possible, an example would be helpful.
>>
>> -Sarbjit
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to improve performance for db queries

2014-05-22 Thread Sarbjit
Hi Anthony, 

Code is almost identical to the code posted in slice with change in field 
names and number of records. Only additonal difference is that I am using 
"orderby" in the query before returing the results.

Surprisingly, sometime the result appears fast (within 2-3 seconds) but 
some time it takes long time to populate it.

-Sarbjit

On Thursday, May 22, 2014 4:46:55 PM UTC+5:30, Anthony wrote:
>
> Would help to see some code. 4-5 seconds sounds much too long.
>
> You might also look into 
> http://dev.s-cubism.com/plugin_lazy_options_widget.
>
> Anthony
>
> On Thursday, May 22, 2014 12:17:42 AM UTC-4, Sarbjit wrote:
>>
>> Hi,
>>
>> I am using cascading drop-down based on the slice posted on "
>> http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2";.
>>  
>> In my application, the number of sub-records for drop-down are typically in 
>> range of 50-60, so every-time I change the first option in drop down, it 
>> takes significant time (around 4-5 seconds) to populate my second drop down.
>>
>> I was wondering if there is a way to make this fast by means of caching 
>> or by storing the data for all the records the first time when user logs 
>> into the system and then using that data. Can some one please comment on 
>> how to address this problem and if possible, an example would be helpful.
>>
>> -Sarbjit
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to improve performance for db queries

2014-05-21 Thread Sarbjit
Hi,

I am using cascading drop-down based on the slice posted on 
"http://www.web2pyslices.com/slice/show/1526/cascading-drop-down-lists-with-ajax-2";.
 
In my application, the number of sub-records for drop-down are typically in 
range of 50-60, so every-time I change the first option in drop down, it 
takes significant time (around 4-5 seconds) to populate my second drop down.

I was wondering if there is a way to make this fast by means of caching or 
by storing the data for all the records the first time when user logs into 
the system and then using that data. Can some one please comment on how to 
address this problem and if possible, an example would be helpful.

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Unable to pass arguments to a LOAD for a modal dialog

2014-05-19 Thread Sarbjit
Hi,

I am using the plugin for modal dialog from 
"http://dev.s-cubism.com/plugin_dialog";. I am somehow not able to pass 
arguments to modal dialog box.

*Controller :-*

def index():
dialog1 = DIALOG(LOAD(f='inner',ajax=True), 
title='Test',vars={'a':'testvar'},close_button='Close', renderstyle=True)
dialog =  A('Click me !!', _href='#', _onclick='%s;return false' % 
dialog1.show())
grid = {}
query = (db.Product.product_name==request.vars.product_id)
grid = SQLFORM.grid(query=query)
return dict(grid=grid,dialog=dialog)


def inner():
x = request.vars.a
return DIV(x)

*Views:*

{{if grid.view_form:}}
{{=grid.view_form.custom.begin}}
{{=grid}}
{{=dialog}}
{{=grid.view_form.custom.submit}}
{{=grid.view_form.custom.end}}
{{else:}}
{{=grid}}
{{pass}}

*Requirement :-*

I want to display specific data for particular row of grid (when opened in 
view mode) in the modal form. I found the plugin to show the modal dialog 
box. It works for static data but I am not able to pass any variable to the 
inner function (tried passing dummy variable). My end goal is to pass the 
"db.Product.Product_type" for that particular row to the modal dialog. 

Can someone please help me on how to achieve this.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Error on moving to next page using grid

2014-05-18 Thread Sarbjit
I am facing problem using GRID, the results which are displayed in the gird 
are correct as per query but if the number of records are more, then 
results are displayed across multiple pages in the grid. Problem is that 
when, I select second (any other page) to view more results from grid, i 
get the error that "local variable grid is referenced before assignment". 
Can some one please help me on how to resolve this. (I actually have to 
build grid on another page)


*Controller :*
def results():
query = (db.Products.product_version==request.vars.product_name))
if request.vars.product_name and request.vars.makers_name:
grid = 
SQLFORM.grid(query=query,csv=False,create=False,deletable=False,)
return dict(grid=grid)

*Views:* (results.html)
{{extend 'layout.html'}}
{{=grid}}

*Form:*
{{extend 'layout.html'}}






-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Can I use/access Java Database (Derby) using web2py?

2014-05-01 Thread Sarbjit
Hello All,

Is it possible to access/use Java database (derby) with web2py application. 
So, the context is that I am having a Java application which uses Java DB 
as a database, I want to integrate the web2py application with the java db 
such that the user's can either use web2py application (accessed online) or 
use Java Application (standalone exe) together and both can access the same 
db.

Can some one please provide me some pointers on how to address this problem 
- Direct access available or a way to migrate javadb to web2py based db 
(exclusive for web2py app) ?

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Suggestions required for Sorting GRID

2014-01-12 Thread Sarbjit
As per suggestions from this 
post.I
 have solved the problem to view the grid results in a different 
controller by storing the grid results in a session and in the second 
controller, I am retrieving the results from session and displaying them.

*PROBLEM :-*

With this implantation, I am having problem using sort method on grid 
results header. On using sort, I get the following URL :

/test/default/search?keywords=&order=testdb.testname&_signature=.

So my controller, starts showing all the records and search query results 
are lost.

Is there a way I can sort the grid results stored in the session. So, I am 
planning to parse the URL and based on the order specified in the URL, I 
can sort the results.

Other solution could be to use "orderby" while retrieving the results from 
GRID. But I feel that if I recompute the results from GRID, my selection in 
the dynamic form (used to build query) would be lost and it will again end 
up showing all the results.

Please let me know what is the efficient way to handle this?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] How can I view the uploaded file name in grid instead of file?

2013-11-19 Thread Sarbjit
Its not so clear from Niphold answer's on how this can be achieved.

On Tuesday, November 19, 2013 9:52:56 PM UTC+5:30, Richard wrote:
>
> See Niphold answer here : 
> https://groups.google.com/d/msg/web2py/-ErAU2GkTUQ/ddAV4WEYNyQJ
>
>
> On Tue, Nov 19, 2013 at 5:50 AM, Sarbjit 
> > wrote:
>
>> With the below models and controllers, In the view corresponding to 
>> Mytable2, I am getting the uploaded file name as "file". How can I show the 
>> actual file name that was being uploaded instead of "file"
>>
>> *Model:*
>>
>> db.define_table('Mytable1', Field('Mytable1_field1'),
>> Field('Mytable1_field2','text')
>> )
>> 
>> db.define_table('Mytable2', Field('Mytable2_files', 'upload'),
>>  Field('Mytable2_ref' , 'reference 
>> Mytable1'))
>>
>> db.Mytable2.Mytable2_ref.requires = IS_IN_DB(db, db.Mytable1.id, 
>> '%(Mytable1_field1)s')
>>
>>
>> *Controller:*
>>
>> def viewdata():
>> grid = 
>> SQLFORM.smartgrid(db.Mytable1,csv=False,linked_tables=['Mytable2'],)
>> return dict(grid=grid) 
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] How can I view the uploaded file name in grid instead of file?

2013-11-19 Thread Sarbjit
With the below models and controllers, In the view corresponding to 
Mytable2, I am getting the uploaded file name as "file". How can I show the 
actual file name that was being uploaded instead of "file"

*Model:*

db.define_table('Mytable1', Field('Mytable1_field1'),
Field('Mytable1_field2','text')
)

db.define_table('Mytable2', Field('Mytable2_files', 'upload'),
 Field('Mytable2_ref' , 'reference 
Mytable1'))

db.Mytable2.Mytable2_ref.requires = IS_IN_DB(db, db.Mytable1.id, 
'%(Mytable1_field1)s')


*Controller:*

def viewdata():
grid = 
SQLFORM.smartgrid(db.Mytable1,csv=False,linked_tables=['Mytable2'],)
return dict(grid=grid) 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Storing and retrieving lists in web2py database for Google Charts

2013-11-16 Thread Sarbjit
Solved it using Pickle.

-Sarbjit

On Saturday, November 16, 2013 2:24:24 PM UTC+5:30, Sarbjit wrote:
>
> I am using the slice from 
> http://www.web2pyslices.com/slice/show/1721/google-charts-plugin.
>
> To store the data to be used for plotting in google charts, I am using the 
> following :
>
> To Create :- (Example)
>
> data = [['Year','Sales','Expenses'],["2004",1000,400],["2005",1100,440]]
>
> How I am doing :-
>
> list1 = [] # For Row2 (how to store and retrieve from db)
> list1.append("2004")
> list1.append(1000)
> list1.append(400)
>
> import json 
> list1b = json.dumps(list1)
> db.sampletable.insert(list1a=list1b)
> db.commit()
>
> >>>>>>
>  x = db(db.sampletable.id==1).select()[0].list1a
> json.load(x)
> AttributeError: 'str' object has no attribute 'read'
>
> Similarly, If I don't use the json.dumps method first, I get the same 
> error.
>
> I want to know how can I store the sublists in db and then can retrieve 
> them to make them as data list (pointed in the beginning).
>
> -Sarbjit
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Storing and retrieving lists in web2py database for Google Charts

2013-11-16 Thread Sarbjit
I am using the slice from 
http://www.web2pyslices.com/slice/show/1721/google-charts-plugin.

To store the data to be used for plotting in google charts, I am using the 
following :

To Create :- (Example)

data = [['Year','Sales','Expenses'],["2004",1000,400],["2005",1100,440]]

How I am doing :-

list1 = [] # For Row2 (how to store and retrieve from db)
list1.append("2004")
list1.append(1000)
list1.append(400)

import json 
list1b = json.dumps(list1)
db.sampletable.insert(list1a=list1b)
db.commit()

>>>>>>
 x = db(db.sampletable.id==1).select()[0].list1a
json.load(x)
AttributeError: 'str' object has no attribute 'read'

Similarly, If I don't use the json.dumps method first, I get the same error.

I want to know how can I store the sublists in db and then can retrieve 
them to make them as data list (pointed in the beginning).

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Value is not updated in db on submitting form from grid

2013-11-15 Thread Sarbjit
Thanks Anthony for feedback.

I am facing problem with this approach, since my ItemRecords could have 
multiple records with same name (In my actual application, there are 
different fields and it is logical to have same name in multiple records 
with different other values).

Can I make them unique, that's what I was trying to do with my code.

Thanks
Sarbjit

On Friday, November 15, 2013 7:04:38 PM UTC+5:30, Anthony wrote:
>
> Instead, why don't you try:
>
> db.define_table('ItemOwners',
> Field('ItemName', requires=IS_IN_DB(db, 'ItemRecords.ItemName')))
>
> Anthony
>
> On Friday, November 15, 2013 3:35:17 AM UTC-5, Sarbjit wrote:
>>
>>
>> My requirement was to show drop down list for a field generated using 
>> GRID by using the values defined in another table.
>>
>> Below is the code used: 
>>
>> *Models:*
>>
>> # coding: utf8
>> db = DAL('sqlite://storage.sqlite')
>> from gluon.tools import Crud, Auth
>> auth=Auth(globals(),db)
>> auth.define_tables(username=False)
>> db._common_fields.append(auth.signature) ## adds signature fields to all 
>> tables
>> db.define_table('ItemRecords', Field('ItemName'))
>> db.define_table('ItemOwners', Field('ItemName'))
>>
>> *Controllers:*
>>
>> def testpage():
>> table_name = 'ItemRecords'
>> field_name = 'ItemName'
>> rows1 = db(db.ItemRecords.ItemName!=None).select()
>> opts_dropdown = []
>> for row1 in rows1:
>> opts_dropdown.append(row1.ItemName)
>> opts_dropdown = list(set(opts_dropdown)) # Make it unique
>> element_id = 'ItemOwners_ItemName'
>> custom_select = SELECT(opts_dropdown, _id=element_id)
>> grid = SQLFORM.smartgrid(db.ItemOwners,csv=False,user_signature=False)
>> grid.element('input',_id=element_id, replace=custom_select)
>> return dict(grid=grid)   
>>
>> def testpage1():
>> grid = SQLFORM.grid(db.ItemRecords,csv=False,user_signature=False)
>> return dict(grid=grid)   
>>
>> *Views :*
>>
>> {{=grid}}
>>
>> # For both testpage and testpage1
>>
>> Now Insert few records to Itemrecords table using testpage1. Try to 
>> insert new record in ItemOwners table using testpage view, you'll see the 
>> drop down with the values from ItemRecords table. Add a record and reload 
>> testpage view, you;ll see that the ItemName record will be seen empty in 
>> grid.
>>
>> If I don't use replace in testpage view (To show drop down), then it 
>> works fine.
>>
>> Can some one please help me to resolve this issue, by using replace, I am 
>> getting drop down values, then why are those not getting saved.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: add new button in GRID with same look and feel

2013-11-15 Thread Sarbjit
Thanks !!


On Friday, November 15, 2013 2:20:44 PM UTC+5:30, Mirko wrote:
>
> Just figured out how to do that :
>
> links=[
> {'header':'...','body':lambda row: ...},
> lambda row: TAG.button(T('Accept'),_type="button",_onclick=
> 'alert("%s")'%row.id)
> ]
>
> the second item of links list goes with the delete/view/edit buttons...
>
> Hope it helps,
>
> Mirko
>
> On Friday, November 15, 2013 9:37:20 AM UTC+1, Sarbjit wrote:
>>
>> Hi Mirko,
>>
>> I am not able to figure out a way so far :(
>>
>> But I feel the best way is to create a new header and add existing 
>> buttons (Add/Delete/View) in them along with other buttons. But I still 
>> need to figure out how this can be done i.e. passing the correct arguments 
>> (signature) etc.
>>
>> -Sarbjit
>>  
>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: add new button in GRID with same look and feel

2013-11-15 Thread Sarbjit
Hi Mirko,

I am not able to figure out a way so far :(

But I feel the best way is to create a new header and add existing buttons 
(Add/Delete/View) in them along with other buttons. But I still need to 
figure out how this can be done i.e. passing the correct arguments 
(signature) etc.

-Sarbjit
 

>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Value is not updated in db on submitting form from grid

2013-11-15 Thread Sarbjit

My requirement was to show drop down list for a field generated using GRID 
by using the values defined in another table.

Below is the code used: 

*Models:*

# coding: utf8
db = DAL('sqlite://storage.sqlite')
from gluon.tools import Crud, Auth
auth=Auth(globals(),db)
auth.define_tables(username=False)
db._common_fields.append(auth.signature) ## adds signature fields to all 
tables
db.define_table('ItemRecords', Field('ItemName'))
db.define_table('ItemOwners', Field('ItemName'))

*Controllers:*

def testpage():
table_name = 'ItemRecords'
field_name = 'ItemName'
rows1 = db(db.ItemRecords.ItemName!=None).select()
opts_dropdown = []
for row1 in rows1:
opts_dropdown.append(row1.ItemName)
opts_dropdown = list(set(opts_dropdown)) # Make it unique
element_id = 'ItemOwners_ItemName'
custom_select = SELECT(opts_dropdown, _id=element_id)
grid = SQLFORM.smartgrid(db.ItemOwners,csv=False,user_signature=False)
grid.element('input',_id=element_id, replace=custom_select)
return dict(grid=grid)   

def testpage1():
grid = SQLFORM.grid(db.ItemRecords,csv=False,user_signature=False)
return dict(grid=grid)   

*Views :*

{{=grid}}

# For both testpage and testpage1

Now Insert few records to Itemrecords table using testpage1. Try to insert 
new record in ItemOwners table using testpage view, you'll see the drop 
down with the values from ItemRecords table. Add a record and reload 
testpage view, you;ll see that the ItemName record will be seen empty in 
grid.

If I don't use replace in testpage view (To show drop down), then it works 
fine.

Can some one please help me to resolve this issue, by using replace, I am 
getting drop down values, then why are those not getting saved.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: How to view the referenced table field name and not their id

2013-11-14 Thread Sarbjit
Thanks stifan for reply,

As stated earlier, this is an sample example. For the second problem, in my 
actual problem I am having different records present for same owner 
(Consider same NAME for person field). Now when I say, my PERSON table can 
have multiple records with the same name, it means the person is same but 
have records associated with him.

Since in my Person table, my person NAME field is referring to same person, 
it doesn't makes sense to show all the records from PERSON NAME field in 
DOG table as they are anyway referencing to same person. So I just want to 
show Person name once in case it finds duplicate records in PERSON. 
(Duplicate NAME but will have different other records)

-Sarbjit

On Friday, November 15, 2013 11:17:53 AM UTC+5:30, 黄祥 wrote:
>
> *Problem1 :- Referenced field id is seen in grid, I want to have the 
>> referenced field 'name' value*
>>
>> Please insert few records using appadmin/grid and view the records, it 
>> will show the NAME field (DOG table) having the value as ID for the PERSON 
>> table. How can I view the name of the person name here and not the ID from 
>> PERSON table.
>>
>
> please do with record representation.
> e.g.
> db.define_table('person', 
> Field('name'), 
> Field('country'), 
> *format = '%(name)s'* )
>
> ref:
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-representation
>  
>
>>
>> *Problem2: In my case, Person field can have duplicate names, i.e. 
>> multiple records with the same name can be present. But I want that in DOG 
>> table, unique name to be seen in drop down list (seen in edit/add record).*
>>
>
> hm, not sure in here, i think, it can be boomerang to you. because you 
> want person field name can have duplicate name, but you want to eliminate 
> it (make it unique) in dog table owner field.
> e.g.
> person :
> id : 1
> name : kiba
> country : sunagakure
>
> id : 2
> name : kiba
> country : konohagakure
>
> now, when i select the owner field in dog table, which kiba i refer to? it 
> will make the user confuse. you want to distinct it, then which kiba will 
> be eliminate then?
> if you want duplicate name, i think you can add a field for describe it. 
> e.g. last_name, nick_name, etc. then if the name field can have duplicate, 
> that fine, but not the combination name and the other field (last_name, 
> nick_name, etc).
> or for your current condition i think you can have the combination for 
> name and country field as record representation.
> e.g.
> db.define_table('person', 
> Field('name'), 
> Field('country'), 
> *format = '%(name)s **%(country)s**'* )
>
> best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] How to view the referenced table field name and not their id

2013-11-14 Thread Sarbjit
Below example can show the behavior, please do not mind over the table 
logic/names (this is just to show the  behavior)


*Model:*
db.define_table('person', 
Field('name'), 
Field('country'))

db.define_table('dog',
Field('name'),
Field('ownername', 'reference person'))

db.dog.ownername.requires = IS_IN_DB(db,db.person.id, '%(name)s')

*Controller:*

def testpage():
grid = SQLFORM.smartgrid(db.dog,csv=False,linked_tables=['person'],)
return dict(grid=grid) 

*View:*

{{=grid}}


*Problem1 :- Referenced field id is seen in grid, I want to have the 
referenced field 'name' value*

Please insert few records using appadmin/grid and view the records, it will 
show the NAME field (DOG table) having the value as ID for the PERSON 
table. How can I view the name of the person name here and not the ID from 
PERSON table.

*Problem2: In my case, Person field can have duplicate names, i.e. multiple 
records with the same name can be present. But I want that in DOG table, 
unique name to be seen in drop down list (seen in edit/add record).*

Please advise on how this can be accomplished.

-Sarbjit






-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Google charts plugin added

2013-11-13 Thread Sarbjit
Thanks Tim,

I have a question:

In your example, data is present in controller itself, how can I store the 
data effectively in database and then use that data for plotting graphs?

Can you please provide an example of how this can be stored/retrieved from 
db? I searched the net and found people suggesting pickle/json for 
storing/retrieving from db, but I'm not having any experience with both. 
Can you please help.

def plugin_return_data():
data = 
[['Year','Sales','Expenses'],["2004",1000,400],["2005",1100,440],["2006",1200,600],
["2007",1500,800],["2008",1600,850],["2009",1800,900]]
return dict(data=data)

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Import csv outside the web2py causes multiple entries in db corresponding to each column.

2013-11-04 Thread Sarbjit
I am using import csv option to insert records in the database. When I use 
the csv file from the web application, then  a single record is inserted in 
the database with all the records being updated properly as per the headers.

But If I try to use "import_from_csv_file" outside the web2py, it inserts 
multiple records in the database. This seems to be an bug to me.

Code for updating db outside web2py

libraryPath = r'D:\web2py'
dbPath = r'D:\web2py\applications\testapp\databases'

import sys
sys.path.append(libraryPath)
from gluon import DAL
db = DAL('sqlite://storage.sqlite',folder=dbPath,auto_import=True)
table = db['person']
file = r'D:\file.csv'
table.import_from_csv_file(file)
db.commit()

On using the same file (csv file) using the web2py, it works as expected, 
code :-

file = request.vars.csvfile.file
table.import_from_csv_file(file)

Can some one please comment on this behavior, what am I missing here?

-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: add new button in GRID with same look and feel

2013-11-04 Thread Sarbjit
I was wondering if I could add the grid default buttons 
('View','Edit','Delete') inside the links and turn off the default buttons 
visibility. This way the new button and other buttons would be of same 
style. Only problem is that the default buttons used to pass "signature" 
and other arguments, but I am not sure what arguments needs to be passed.

Please comment if this is the right approach or I could just append the new 
button to the existing buttons (row), also please let me know if this is 
feasible or not.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Downloading files from the disk using the path specfied in the db

2013-11-04 Thread Sarbjit
Actually I wanted to provide a download option for a file which was not 
uploaded using web2py, rather a database field was populated with the path 
of the file. I was not aware of response.stream, it solved my purpose.

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: add new button in GRID with same look and feel

2013-11-04 Thread Sarbjit


>  
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] add new button in GRID with same look and feel

2013-11-02 Thread Sarbjit
I have added a new button in grid using links as below :-

links = [dict(header='',  body=lambda row: 
A('CustomButton',_class="w2p_trap button btn", 
_href=URL('customhandler',args=[row.id])))]

Is it possible that I can have the placement of this button under the same 
header where the default grid buttons are placed and this should have the 
same look and feel.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Downloading files from the disk using the path specfied in the db

2013-11-02 Thread Sarbjit
I have a model which is having a field having the path of the file (could 
be of big size) and is present outside the web2py folder. In the web2py 
book, examples given for downloading files are specific to files uploaded 
or in the static folder.

Can some one please provide me an example of how to serve this?

example of download controller :

def download():
dbid = request.args(0,cast=int)
designPath = str(db(db.person.id==dbid).select()[0].DataPath)
print DataPath
   


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLFORM factory field width is less than the text on IE8, works fine on FF

2013-10-30 Thread Sarbjit



Thanks for reply.

Well, this issue that I am observing is not specific to my system only, I 
tried it on two other systems in IE8 and all of them were having the same 
issue.

Anyways, I was able to get the exact width in IE, if I added a width of 
400px to TD element containing the SELECT. So, I modified the web2py.css 
and added width for TD.w2p_fw and it resolved the issue. 

One question is :

What If I had to modify the style using my controller i.e I want to modify 
the style for the element using controller only and not modifying the css 
file. What should be the code for the same.


-Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLFORM factory field width is less than the text on IE8, works fine on FF

2013-10-30 Thread Sarbjit
Sorry, I didn;t noticed that the pictures were not visible, I have uploaded 
them again. I have tried cleaning the cache of IE and reloaded the page, 
but I am getting the same results. Do I need to try something else?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLFORM factory field width is less than the text on IE8, works fine on FF

2013-10-30 Thread Sarbjit



Internet Explorer (8.0)





Firefox




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] SQLFORM factory field width is less than the text on IE8, works fine on FF

2013-10-30 Thread Sarbjit
Hi,

You can use the car appliance available in web2py appliances (github) to 
show this issue 
(https://github.com/mdipierro/web2py-appliances/tree/master/CarSales).

*In Controller, add a function as :-*
def testform():
form = SQLFORM.factory(
Field('TestField', requires=IS_IN_SET(['Test Subfield1 to be 
selected','Test Subfield1 to be selected'],zero=T('Select 
Subfield'),error_message='Select Subfield')))
if form.process().accepted:
response.flash = 'Thanks for the feedback'
elif form.errors:
response.flash = 'Error submitting feedback'
return dict(form=form)  
*
Views (testform.html)*
{{extend 'layout.html'}}
{{=form}}

*Results:*

Firefox :



Internet Explorer :



Can some one please explain, why is this behavior and how can this be 
fixed. I tried adding the below statement to controller, but it didn't 
fixed the problem. Also, I have tried playing with the css without any 
success :(

form.element('select[name=TestField]')['_style']='width400px'

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: drop down for grid or smart grid search fields

2013-10-25 Thread Sarbjit
Thanks a lot Paolo Caruccio!!



On Friday, October 25, 2013 6:39:46 PM UTC+5:30, Paolo Caruccio wrote:
>
> It's not necessary modify the code in gluon.
> You could replace the text input in the query panel. For example:
>
> 1) in db.py we define our table
>
> db.define_table('contact',
>Field('name'),
>Field('phone'))
>
> 2) in default.py we define our controller to create the grid
>
> def contacts():
> grid=SQLFORM.grid(db.contact, user_signature=False)
> table_name = 'contact'
> field_name = 'phone'
> element_id = 'w2p_value_%s-%s' % (table_name, field_name)
> custom_select = SELECT('', 'value1', 'value2', 'value3', _id=
> element_id)
> grid.element('input',_id=element_id, replace=custom_select)
> return locals()
>
> 3) we create our view default/contacts.html
>
> {{extend 'layout.html'}}
> Manage My Contacts
> {{=grid}}
>
> The code in step2 should put you on the right way.
>
> Il giorno venerdì 25 ottobre 2013 13:57:21 UTC+2, Sarbjit ha scritto:
>>
>> I was looking at the code in gucon.sqlform
>>
>> elif (field.type.startswith('reference ') or
>>   field.type.startswith('list:reference ')) and \
>>   hasattr(field.requires,'options'):
>> value_input = SELECT(
>> *[OPTION(v, _value=k)
>>   for k,v in field.requires.options()],
>>  **dict(_id=_id))
>> elif field.type == 'integer' or \
>> field.type.startswith('reference ') or \
>> field.type.startswith('list:integer') or \
>> field.type.startswith('list:reference '):
>> value_input = 
>> SQLFORM.widgets.integer.widget(field,field.default,_id=_id)
>> else:
>> value_input = INPUT(
>>     _type='text', _id=_id, _class=field.type)
>>
>>
>> Can this be enhanced to view Selection Dropdown with the values for all 
>> the fields. I have not much experience in web2py, so can some one please 
>> suggest a change here.
>>
>> On Wednesday, October 23, 2013 9:01:23 AM UTC+5:30, Sarbjit wrote:
>>>
>>> Can someone please help.
>>>
>>> On Tuesday, October 22, 2013 4:39:00 PM UTC+5:30, Sarbjit wrote:
>>>>
>>>> I am using GRID for displaying my database results. I want to use 
>>>> search feature provided by GRID/SMARTGRID where users can build queries 
>>>> and 
>>>> get the results. I want to have a drop down field populated with the 
>>>> values 
>>>> defined in the database for the fields which are defined as strings in 
>>>> database.
>>>>
>>>> In my case, some fields needs to have exact match and are used very 
>>>> frequent for searching the records. Since it is very difficult to fill in 
>>>> the exact name every time you are searching the records using that field, 
>>>> I 
>>>> want that for few fields, it should present a drop down.
>>>>
>>>> Can some one please suggest me on how on to do this.
>>>>
>>>> Thanks
>>>> Sarbjit
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: drop down for grid or smart grid search fields

2013-10-25 Thread Sarbjit
I was looking at the code in gucon.sqlform

elif (field.type.startswith('reference ') or
  field.type.startswith('list:reference ')) and \
  hasattr(field.requires,'options'):
value_input = SELECT(
*[OPTION(v, _value=k)
  for k,v in field.requires.options()],
 **dict(_id=_id))
elif field.type == 'integer' or \
field.type.startswith('reference ') or \
field.type.startswith('list:integer') or \
field.type.startswith('list:reference '):
value_input = 
SQLFORM.widgets.integer.widget(field,field.default,_id=_id)
else:
value_input = INPUT(
_type='text', _id=_id, _class=field.type)


Can this be enhanced to view Selection Dropdown with the values for all the 
fields. I have not much experience in web2py, so can some one please 
suggest a change here.

On Wednesday, October 23, 2013 9:01:23 AM UTC+5:30, Sarbjit wrote:
>
> Can someone please help.
>
> On Tuesday, October 22, 2013 4:39:00 PM UTC+5:30, Sarbjit wrote:
>>
>> I am using GRID for displaying my database results. I want to use search 
>> feature provided by GRID/SMARTGRID where users can build queries and get 
>> the results. I want to have a drop down field populated with the values 
>> defined in the database for the fields which are defined as strings in 
>> database.
>>
>> In my case, some fields needs to have exact match and are used very 
>> frequent for searching the records. Since it is very difficult to fill in 
>> the exact name every time you are searching the records using that field, I 
>> want that for few fields, it should present a drop down.
>>
>> Can some one please suggest me on how on to do this.
>>
>> Thanks
>> Sarbjit
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: drop down for grid or smart grid search fields

2013-10-25 Thread Sarbjit


On Wednesday, October 23, 2013 9:01:23 AM UTC+5:30, Sarbjit wrote:
>
> Can someone please help.
>
> On Tuesday, October 22, 2013 4:39:00 PM UTC+5:30, Sarbjit wrote:
>>
>> I am using GRID for displaying my database results. I want to use search 
>> feature provided by GRID/SMARTGRID where users can build queries and get 
>> the results. I want to have a drop down field populated with the values 
>> defined in the database for the fields which are defined as strings in 
>> database.
>>
>> In my case, some fields needs to have exact match and are used very 
>> frequent for searching the records. Since it is very difficult to fill in 
>> the exact name every time you are searching the records using that field, I 
>> want that for few fields, it should present a drop down.
>>
>> Can some one please suggest me on how on to do this.
>>
>> Thanks
>> Sarbjit
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: drop down for grid or smart grid search fields

2013-10-22 Thread Sarbjit
Can someone please help.

On Tuesday, October 22, 2013 4:39:00 PM UTC+5:30, Sarbjit wrote:
>
> I am using GRID for displaying my database results. I want to use search 
> feature provided by GRID/SMARTGRID where users can build queries and get 
> the results. I want to have a drop down field populated with the values 
> defined in the database for the fields which are defined as strings in 
> database.
>
> In my case, some fields needs to have exact match and are used very 
> frequent for searching the records. Since it is very difficult to fill in 
> the exact name every time you are searching the records using that field, I 
> want that for few fields, it should present a drop down.
>
> Can some one please suggest me on how on to do this.
>
> Thanks
> Sarbjit
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] drop down for grid or smart grid search fields

2013-10-22 Thread Sarbjit
I am using GRID for displaying my database results. I want to use search 
feature provided by GRID/SMARTGRID where users can build queries and get 
the results. I want to have a drop down field populated with the values 
defined in the database for the fields which are defined as strings in 
database.

In my case, some fields needs to have exact match and are used very 
frequent for searching the records. Since it is very difficult to fill in 
the exact name every time you are searching the records using that field, I 
want that for few fields, it should present a drop down.

Can some one please suggest me on how on to do this.

Thanks
Sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Question on SQLFORM.grid layout update

2013-10-21 Thread Sarbjit
Thanks Cliff,

Firebug was really powerful. It solved my problem in seconds.

-Sarbjit

On Monday, October 21, 2013 11:48:41 PM UTC+5:30, Cliff Kachinske wrote:
>
> You can use Firebug to look at the css classes and their attributes. You 
> can also  change them on the fly to see the results.
>
> On Monday, October 21, 2013 9:49:09 AM UTC-4, Sarbjit wrote:
>>
>> I am using SQLFORM.grid and smartgrid for viewing the records, I noticed 
>> that when I use view record button, the text seems to be on right side 
>> making the left side of the screen empty.
>>
>> It looks like 
>>  Name : 
>> John
>>Date of Birth : 
>> 21/10/1980
>>
>> I want it to look like:
>>
>> Name:  John
>> Date of Birth :   21/10/1980
>>
>> How can I modify the layout of grid and smartgrid, I tried locating the 
>> default settings in web2py.css but I was not able to figure out the proper 
>> section.
>>
>> Can some one please guide me on how this can be achieved.
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Question on SQLFORM.grid layout update

2013-10-21 Thread Sarbjit
I am using SQLFORM.grid and smartgrid for viewing the records, I noticed 
that when I use view record button, the text seems to be on right side 
making the left side of the screen empty.

It looks like 
 Name : John
   Date of Birth : 
21/10/1980

I want it to look like:

Name:  John
Date of Birth :   21/10/1980

How can I modify the layout of grid and smartgrid, I tried locating the 
default settings in web2py.css but I was not able to figure out the proper 
section.

Can some one please guide me on how this can be achieved.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Insert table fields dynamically using Import CSV

2013-10-19 Thread Sarbjit
Hi,

I am using "table.import_from_csv_file(file)" option for adding entries in 
the database. But in my application, table fields are dynamic and I want 
that on import csv, if a new column (header) is specified in csv file, a 
new field should be created in database.

Is it feasible to do so, any pointers?

Thanks
sarbjit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Use import csv option to populate the SQLFORM

2013-09-29 Thread Sarbjit singh
Hi,

I am having controller as :

@auth.requires_login()
def add():
form = SQLFORM(db.table)
if form.process(formname='test').accepted:
response.flash = 'Database Updated'
elif form.errors:
response.flash = 'Please fill all the required details'
else:
response.flash = 'Enter the required details'
return dict(form=form)

In views, I am using custom widgets for the view of the add form.

My requirement is that, I want to give an option like "populate from csv" 
(just like import csv option in appadmin, which should just populate this 
form only and do not update the table).

Since I am new to web2py and have no experience using "export/import csv" 
options, will it be possible that I can use the existing import csv code 
and meet my requirement.

Any other pointers/options are welcome.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] How can I check if a IS_IN_SET validator is set for a field and get the validtor values?

2013-07-26 Thread Sarbjit singh
Thanks a lot !!

That's what I was looking for.

-Sarbjit

On Friday, July 26, 2013 7:53:28 PM UTC+5:30, Anthony wrote:
>
> isinstance(table[field].requires, IS_IN_SET)
>
> Anthony
>
> On Friday, July 26, 2013 8:56:13 AM UTC-4, Sarbjit singh wrote:
>>
>> Thanks a lot Anthony for  your help. 
>>
>> I am facing problem while using the variable name with the isinstance 
>> method.
>>
>> i.e. isinstance(db.person.gender.requires, IS_IN_SET) returns TRUE
>>
>> But If I use it like :
>>
>> field = db.person.gender
>> isinstance(field.requires, IS_IN_SET)   ==> Exception that string has no 
>> attribute requires.
>>
>> Since my code is iterating over all the fields and doing some other 
>> operations, I have to store field in variable.
>>
>> Is there any way I can convert string back to gluon object ?
>>
>> Thanks
>> Sarbjit
>>
>> On Friday, July 26, 2013 5:30:52 PM UTC+5:30, Anthony wrote:
>>>
>>> You can do:
>>>
>>> if hasattr(field.requires, 'options'):
>>>
>>> which will identify IS_IN_SET and IS_IN_DB validators. If you only want 
>>> to identify IS_IN_SET, you can do:
>>>
>>> if isinstance(field.requires, IS_IN_SET):
>>>
>>> To get the list of options, you can do field.requires.theset (for the 
>>> values), field.requires.labels (for the labels), or 
>>> field.requires.options() for a list of tuples of values and labels.
>>>
>>> You can also create a SELECT object via 
>>> SQLFORM.widgets.options.widget(field, 
>>> value=field.default).
>>>
>>> Anthony
>>>
>>> On Friday, July 26, 2013 4:55:41 AM UTC-4, Sarbjit singh wrote:
>>>>
>>>> Actually I am not using the SQLFORM. I am using the code for dynamic 
>>>> search form from (
>>>> http://www.web2pyslices.com/slice/show/1403/dynamic-search). I want to 
>>>> modify the code such that for the fields with validators, it should show 
>>>> the selection menu. So I want to add  a check in the code below to detect 
>>>> if a field is having validator set, then use the SELECT command with the 
>>>> validator set values as argument. So far, I am not able to achieve it.
>>>>
>>>> Can you please recommend something in context here?
>>>>
>>>> Here is the code from the slice :
>>>>
>>>> def dynamic_search(table):
>>>> tbl = TABLE()
>>>> selected = []
>>>> ops = ['equals','not equal','greater than','less than',
>>>>'starts with','ends with','contains']
>>>> query = table.id > 0
>>>> for field in table.fields:
>>>> chkval = request.vars.get('chk'+field,None)
>>>> txtval = request.vars.get('txt'+field,None)
>>>> opval = request.vars.get('op'+field,None)
>>>> row = TR(TD(INPUT(_type="checkbox",_name="chk"+field,
>>>>   value=chkval=='on')),
>>>>  TD(field),TD(SELECT(ops,_name="op"+field,
>>>>  value=opval)),
>>>>  TD(INPUT(_type="text",_name="txt"+field,
>>>>   _value=txtval)))
>>>> tbl.append(row)
>>>> if chkval:
>>>> if txtval:
>>>> query &= build_query(table[field], 
>>>> opval,txtval)
>>>> selected.append(table[field])   
>>>> form = FORM(tbl,INPUT(_type="submit"))
>>>> results = db(query).select(*selected)
>>>> return form, results
>>>>
>>>> Thanks,
>>>> Sarbjit
>>>>
>>>>
>>>>
>>>> On Friday, July 26, 2013 1:37:26 PM UTC+5:30, Massimo Di Pierro wrote:
>>>>>
>>>>> Exactly. Complete code in case you have errors:
>>>>>
>>>>> #model
>>>>> db.define_table('persons',Field('gender'))
>>>>> db.persons.gender.requires = IS_IN_SET(['Male', 'Female'])
>>>>>
>>>>> #controller default.py
>>>>> def index():
>>>>> form = SQLFORM(db.persons).proces

Re: [web2py] How can I check if a IS_IN_SET validator is set for a field and get the validtor values?

2013-07-26 Thread Sarbjit singh
Thanks a lot Anthony for  your help. 

I am facing problem while using the variable name with the isinstance 
method.

i.e. isinstance(db.person.gender.requires, IS_IN_SET) returns TRUE

But If I use it like :

field = db.person.gender
isinstance(field.requires, IS_IN_SET)   ==> Exception that string has no 
attribute requires.

Since my code is iterating over all the fields and doing some other 
operations, I have to store field in variable.

Is there any way I can convert string back to gluon object ?

Thanks
Sarbjit

On Friday, July 26, 2013 5:30:52 PM UTC+5:30, Anthony wrote:
>
> You can do:
>
> if hasattr(field.requires, 'options'):
>
> which will identify IS_IN_SET and IS_IN_DB validators. If you only want to 
> identify IS_IN_SET, you can do:
>
> if isinstance(field.requires, IS_IN_SET):
>
> To get the list of options, you can do field.requires.theset (for the 
> values), field.requires.labels (for the labels), or 
> field.requires.options() for a list of tuples of values and labels.
>
> You can also create a SELECT object via SQLFORM.widgets.options.widget(field, 
> value=field.default).
>
> Anthony
>
> On Friday, July 26, 2013 4:55:41 AM UTC-4, Sarbjit singh wrote:
>>
>> Actually I am not using the SQLFORM. I am using the code for dynamic 
>> search form from (
>> http://www.web2pyslices.com/slice/show/1403/dynamic-search). I want to 
>> modify the code such that for the fields with validators, it should show 
>> the selection menu. So I want to add  a check in the code below to detect 
>> if a field is having validator set, then use the SELECT command with the 
>> validator set values as argument. So far, I am not able to achieve it.
>>
>> Can you please recommend something in context here?
>>
>> Here is the code from the slice :
>>
>> def dynamic_search(table):
>> tbl = TABLE()
>> selected = []
>> ops = ['equals','not equal','greater than','less than',
>>'starts with','ends with','contains']
>> query = table.id > 0
>> for field in table.fields:
>> chkval = request.vars.get('chk'+field,None)
>> txtval = request.vars.get('txt'+field,None)
>> opval = request.vars.get('op'+field,None)
>> row = TR(TD(INPUT(_type="checkbox",_name="chk"+field,
>>   value=chkval=='on')),
>>  TD(field),TD(SELECT(ops,_name="op"+field,
>>  value=opval)),
>>  TD(INPUT(_type="text",_name="txt"+field,
>>       _value=txtval)))
>> tbl.append(row)
>> if chkval:
>> if txtval:
>> query &= build_query(table[field], 
>> opval,txtval)
>> selected.append(table[field])   
>> form = FORM(tbl,INPUT(_type="submit"))
>> results = db(query).select(*selected)
>> return form, results
>>
>> Thanks,
>> Sarbjit
>>
>>
>>
>> On Friday, July 26, 2013 1:37:26 PM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> Exactly. Complete code in case you have errors:
>>>
>>> #model
>>> db.define_table('persons',Field('gender'))
>>> db.persons.gender.requires = IS_IN_SET(['Male', 'Female'])
>>>
>>> #controller default.py
>>> def index():
>>> form = SQLFORM(db.persons).process()
>>> return locals()
>>>
>>> #views default/index.html
>>> {{extend 'layout.html'}}
>>> {{=form}}
>>>
>>>
>>> Mind we tend to call table names with singular not plural (person, not 
>>> persons). This will make your code more readable.
>>>
>>> On Friday, 26 July 2013 02:57:21 UTC-5, viniciusban wrote:
>>>>
>>>> It's done automaticaly by web2py. 
>>>>
>>>> On Fri, Jul 26, 2013 at 2:29 AM, Sarbjit singh  
>>>> wrote: 
>>>> > I have a db where I have set validator IS_IN_SET on a particular 
>>>> field. I am 
>>>> > generating table rows (to be used as form), so I need to check if a 
>>>> > particular field is having IS_IN_SET validator set and I want to 
>>>> retrieve 
>>>> > the set values. Reason I want to do this is that I am generating a 
>>>> dynamic 
>>>> > form based on the tabl

Re: [web2py] How can I check if a IS_IN_SET validator is set for a field and get the validtor values?

2013-07-26 Thread Sarbjit singh
Actually I am not using the SQLFORM. I am using the code for dynamic search 
form from (http://www.web2pyslices.com/slice/show/1403/dynamic-search). I 
want to modify the code such that for the fields with validators, it should 
show the selection menu. So I want to add  a check in the code below to 
detect if a field is having validator set, then use the SELECT command with 
the validator set values as argument. So far, I am not able to achieve it.

Can you please recommend something in context here?

Here is the code from the slice :

def dynamic_search(table):
tbl = TABLE()
selected = []
ops = ['equals','not equal','greater than','less than',
   'starts with','ends with','contains']
query = table.id > 0
for field in table.fields:
chkval = request.vars.get('chk'+field,None)
txtval = request.vars.get('txt'+field,None)
opval = request.vars.get('op'+field,None)
row = TR(TD(INPUT(_type="checkbox",_name="chk"+field,
  value=chkval=='on')),
 TD(field),TD(SELECT(ops,_name="op"+field,
 value=opval)),
 TD(INPUT(_type="text",_name="txt"+field,
  _value=txtval)))
tbl.append(row)
if chkval:
if txtval:
query &= build_query(table[field], 
opval,txtval)
    selected.append(table[field])   
form = FORM(tbl,INPUT(_type="submit"))
results = db(query).select(*selected)
return form, results

Thanks,
Sarbjit



On Friday, July 26, 2013 1:37:26 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Exactly. Complete code in case you have errors:
>
> #model
> db.define_table('persons',Field('gender'))
> db.persons.gender.requires = IS_IN_SET(['Male', 'Female'])
>
> #controller default.py
> def index():
> form = SQLFORM(db.persons).process()
> return locals()
>
> #views default/index.html
> {{extend 'layout.html'}}
> {{=form}}
>
>
> Mind we tend to call table names with singular not plural (person, not 
> persons). This will make your code more readable.
>
> On Friday, 26 July 2013 02:57:21 UTC-5, viniciusban wrote:
>>
>> It's done automaticaly by web2py. 
>>
>> On Fri, Jul 26, 2013 at 2:29 AM, Sarbjit singh  
>> wrote: 
>> > I have a db where I have set validator IS_IN_SET on a particular field. 
>> I am 
>> > generating table rows (to be used as form), so I need to check if a 
>> > particular field is having IS_IN_SET validator set and I want to 
>> retrieve 
>> > the set values. Reason I want to do this is that I am generating a 
>> dynamic 
>> > form based on the table fields and for the fields having IS_IN_SET 
>> validtor, 
>> > I want to show the "Drop Down" menu rather than Text Field and wants to 
>> > populate it with the Validator values. 
>> > 
>> > db.define_table('persons',Field('gender') 
>> > db.persons.gender.requires = IS_IN_SET(['Male', 'Female']) 
>> > 
>> > -Sarbjit 
>> > 
>> > -- 
>> > 
>> > --- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "web2py-users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an 
>> > email to web2py+un...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/groups/opt_out. 
>> > 
>> > 
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How can I check if a IS_IN_SET validator is set for a field and get the validtor values?

2013-07-25 Thread Sarbjit singh
I have a db where I have set validator IS_IN_SET on a particular field. I 
am generating table rows (to be used as form), so I need to check if a 
particular field is having IS_IN_SET validator set and I want to retrieve 
the set values. Reason I want to do this is that I am generating a dynamic 
form based on the table fields and for the fields having IS_IN_SET 
validtor, I want to show the "Drop Down" menu rather than Text Field and 
wants to populate it with the Validator values.

db.define_table('persons',Field('gender')
db.persons.gender.requires = IS_IN_SET(['Male', 'Female'])

-Sarbjit

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I pass a query object to a different controller?

2013-07-18 Thread Sarbjit singh
Now all the problems are solved, with problem remaining. Here is what I did 
to solve the problem :

In the view for search2, I added the code as :

{{extend 'layout.html'}}
This is the default/search2.html template
{{if results.update_form:}}
{{=results}}
{{elif results.view_form:}}
{{=results}}
{{else:}}
{{=form}}
{{pass}}

Problem that is remaining is, when I click on "Back" button from the 
Edit/View operation of grid, it took me back to search form, but I want to 
see the search results. Can some one please help me on how to handle it?

-Sarbjit

On Thursday, July 18, 2013 12:36:25 PM UTC+5:30, Sarbjit singh wrote:
>
> Just to be clear on exception (crash) :
>
> On clicking search, pickle error is seen if the url is like :
>
>
> http://127.0.0.1:8000/sampleapp/default/search2/edit/customer/2?_signature=.
> ..
>
> If it is simple : (first time search which works) :
>
> http://127.0.0.1:8000/sampleapp/default/search2
>
> But no edit/view forms are seen on redirection from "results" view back to 
> "search2".
>
> -Sarbjit
>
>
>
>
>
> On Thursday, July 18, 2013 9:18:18 AM UTC+5:30, Sarbjit singh wrote:
>>
>> Thanks guys for the help.
>>
>> I followed the approach as suggested by Massimo, so I did the following :
>>
>> @auth.requires_login()  
>> def search2():
>> form,results = dynamic_search(db.customer)
>> if form.process().accepted:
>> session.results = results
>> redirect(URL('results'))
>> return dict(form=form)
>>
>> @auth.requires_login() 
>> def results():
>> results = session.results
>> return dict(results=results)
>>
>> Please note that the dynamic_search is returning grid and form, so I am 
>> storing grid in the session.
>>
>>
>> But I am still facing problems, not sure what wrong steps I am doing. For 
>> the first time, when I click on search, desired results are opened in 
>> controller "results" (in a new page). But when I click on edit/view of grid 
>> operation, some how the page gets redirected to "search" page and on 
>> subsequent search it crashes with the same problem (can't pickle ..). My 
>> question is when i click on edit operations on a grid, why it is 
>> redirecting to search. Isn't it is supposed to open edit form there itself?
>>
>> To me it looks like, since the grid was generated when the control was in 
>> the "search2", so the links of the grid operations are pointing to 
>> "search2" view though the results are now seen in different view "results". 
>> So when I click on any operation, it is redirected to "search2" view - BUT 
>> strangely contents of edit form are not seen (Not sure of the reason?). 
>>
>> Can some one please help me to resolve this issue ? Is there a way I can 
>> recompute the grid links in "results" controller such that they do not 
>> redirect to "search2" view. Also what could be the check added to avoid 
>> crash on subsequent search.
>>
>> Thanks
>> Sarbjit
>>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I pass a query object to a different controller?

2013-07-18 Thread Sarbjit singh
Just to be clear on exception (crash) :

On clicking search, pickle error is seen if the url is like :

http://127.0.0.1:8000/sampleapp/default/search2/edit/customer/2?_signature=...

If it is simple : (first time search which works) :

http://127.0.0.1:8000/sampleapp/default/search2

But no edit/view forms are seen on redirection from "results" view back to 
"search2".

-Sarbjit





On Thursday, July 18, 2013 9:18:18 AM UTC+5:30, Sarbjit singh wrote:
>
> Thanks guys for the help.
>
> I followed the approach as suggested by Massimo, so I did the following :
>
> @auth.requires_login()  
> def search2():
> form,results = dynamic_search(db.customer)
> if form.process().accepted:
> session.results = results
> redirect(URL('results'))
> return dict(form=form)
>
> @auth.requires_login() 
> def results():
> results = session.results
> return dict(results=results)
>
> Please note that the dynamic_search is returning grid and form, so I am 
> storing grid in the session.
>
>
> But I am still facing problems, not sure what wrong steps I am doing. For 
> the first time, when I click on search, desired results are opened in 
> controller "results" (in a new page). But when I click on edit/view of grid 
> operation, some how the page gets redirected to "search" page and on 
> subsequent search it crashes with the same problem (can't pickle ..). My 
> question is when i click on edit operations on a grid, why it is 
> redirecting to search. Isn't it is supposed to open edit form there itself?
>
> To me it looks like, since the grid was generated when the control was in 
> the "search2", so the links of the grid operations are pointing to 
> "search2" view though the results are now seen in different view "results". 
> So when I click on any operation, it is redirected to "search2" view - BUT 
> strangely contents of edit form are not seen (Not sure of the reason?). 
>
> Can some one please help me to resolve this issue ? Is there a way I can 
> recompute the grid links in "results" controller such that they do not 
> redirect to "search2" view. Also what could be the check added to avoid 
> crash on subsequent search.
>
> Thanks
> Sarbjit
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I pass a query object to a different controller?

2013-07-17 Thread Sarbjit singh
Thanks guys for the help.

I followed the approach as suggested by Massimo, so I did the following :

@auth.requires_login()  
def search2():
form,results = dynamic_search(db.customer)
if form.process().accepted:
session.results = results
redirect(URL('results'))
return dict(form=form)

@auth.requires_login() 
def results():
results = session.results
return dict(results=results)

Please note that the dynamic_search is returning grid and form, so I am 
storing grid in the  form.


But I am still facing problems, not sure what wrong steps I am doing. For 
the first time, when I click on search, desired results are opened in 
controller "results" (in a new page). But when I click on edit/view of grid 
operation, some how the page gets redirected to "search" page and on 
subsequent search it crashes with the same problem (can't pickle ..). My 
question is when i click on edit operations on a grid, why it is 
redirecting to search. Isn't it is supposed to open edit form there itself?

Thanks
Sarbjit
 
On Thursday, July 18, 2013 1:00:12 AM UTC+5:30, Dmitri Husti wrote:
>
> Hi,
> Is it possible to pass the request vars and call the function 
> dynamic_search twice?
> redirect(URL("test",vars=request.vars))
>
>
>
> Am Mittwoch, 17. Juli 2013 18:46:07 UTC+2 schrieb Massimo Di Pierro:
>>
>> You can store the results in session then.
>>
>> session.rows = db(...).select()
>>
>> Passing to much data in request.vars can be a problem. For example nginx 
>> limits the size of the query string.
>>
>>
>>
>>
>> On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote:
>>>
>>> HI,
>>> you can pass results to the next page;
>>> redirect(URL("test",vars=dict(results=results))
>>>
>>> On the next page you can do 
>>> return dict(results=request.vars["results"])
>>>
>>> Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh:
>>>>
>>>> Hi,
>>>>
>>>> I am trying to use "dynamic search form" from 
>>>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>>>> implementation shows both the form and results on the same page.
>>>>
>>>> I want to display the search results (using GRID) in a new page and 
>>>> wants to use customized forms for edit/view operations associated with 
>>>> GRID.
>>>>
>>>> As of now, I tried handling it in the view to not to show form contents 
>>>> once the form is accessed but some how it is not working on subsequent 
>>>> operations.
>>>>
>>>> So, I am thinking to pass query to a new controller and can hence 
>>>> handle the custom forms there. But I am not able to do so.
>>>>
>>>> So here is what I tried :
>>>>
>>>> @auth.requires_login()  
>>>> def search2():
>>>> form,query = dynamic_search(db.customer)
>>>> if form.process().accepted:
>>>> session.sqlquery = query
>>>> redirect(URL('results'))
>>>> return dict(form=form)
>>>>
>>>> @auth.requires_login()     
>>>> def results():
>>>> query = session.sqlquery
>>>> print query
>>>> results =  
>>>> SQLFORM.grid(query,searchable=False,create=False,csv=False)
>>>> results = None
>>>> return dict(results=results)
>>>>
>>>> With this code, first error that is encountered is in "session.sqlquery 
>>>> = query" -> Can't pickle objects 
>>>>
>>>> So I modified it as 
>>>>
>>>> session.sqlquery = str(query)
>>>>
>>>> With this error appeared in "query = session.sqlquery" -> str object 
>>>> has no attribute _db
>>>>
>>>> Can some one please suggest what is the right way to achieve this?
>>>>
>>>> -Sarbjit
>>>>
>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I pass a query object to a different controller?

2013-07-17 Thread Sarbjit singh
I am  not aware of the word "serialize", Is there any possibility to 
achieve it?



On Wednesday, July 17, 2013 5:36:33 PM UTC+5:30, Massimo Di Pierro wrote:
>
> A query object cannot be put into a session unless you somehow serialize 
> (but not with automated pickle/marshall/etc).
>
> On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote:
>>
>> Hi,
>>
>> I am trying to use "dynamic search form" from 
>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>> implementation shows both the form and results on the same page.
>>
>> I want to display the search results (using GRID) in a new page and wants 
>> to use customized forms for edit/view operations associated with GRID.
>>
>> As of now, I tried handling it in the view to not to show form contents 
>> once the form is accessed but some how it is not working on subsequent 
>> operations.
>>
>> So, I am thinking to pass query to a new controller and can hence handle 
>> the custom forms there. But I am not able to do so.
>>
>> So here is what I tried :
>>
>> @auth.requires_login()  
>> def search2():
>> form,query = dynamic_search(db.customer)
>> if form.process().accepted:
>> session.sqlquery = query
>> redirect(URL('results'))
>> return dict(form=form)
>>
>> @auth.requires_login() 
>> def results():
>> query = session.sqlquery
>> print query
>> results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
>> results = None
>> return dict(results=results)
>>
>> With this code, first error that is encountered is in "session.sqlquery = 
>> query" -> Can't pickle objects 
>>
>> So I modified it as 
>>
>> session.sqlquery = str(query)
>>
>> With this error appeared in "query = session.sqlquery" -> str object has 
>> no attribute _db
>>
>> Can some one please suggest what is the right way to achieve this?
>>
>> -Sarbjit
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   >