[web2py] ST_X function on POSTGIS geography() fields

2014-04-23 Thread libertil
Hi everyone,
I am trying to extract latitude and longitude from a POSTGIS geography() 
field. Unfortunately the usual st_x() and st_y() functions normally used
for geometry() fields won't work.
How can I extract the required values or transform geography in geometry?

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] Unexpected behavior using GRID form with selectable option.

2014-04-23 Thread alex
Hello guys, I'm experiencing an unexpected behavior using grid form with 
selectable option, need help.

I have a temporal table 'rogue_rows' in a database 'dyn_db'. This table 
includes rows from different tables of another database. Please refer to 
the controller index() code:

def index():
dyn_db.rogue_rows.truncate()   
   # truncate table each time index is called 

for table in tables_list :  # table list contains needed tables. 
query=(cam_db[table].trunk==0)  (cam_db[table].rogue==1)
rows = 
cam_db(query).select()# 
extract needed rows from current table
for row in rows :  
   # insert each row in temporal table
dyn_db.rogue_rows.insert(table_name=table,
 node_name=row.node_name,
 mac=row.mac,
 port=row.port,
 )

grid=SQLFORM.grid(dyn_db.rogue_rows,
# convey dyn_db.rogue_rows table to the grid form
  fields=[dyn_db.rogue_rows.node_name,
  dyn_db.rogue_rows.mac,
  dyn_db.rogue_rows.port],
  selectable=lambda ids : 
allow_mac(ids)# add checkboxes to each row, hand over 
selected row ids to function allow_macs()
  )
return dict(grid=grid)

The index() function works great, it displays all the rows from the 
different tables. When I check all the boxes, let's say there were 5 rows, 
and click submit - grid calls allow_macs() with ids = [1,2,3,4,5]. Until 
now, it was all fine. Please refer to allow_mac() func:

def allow_mac(ids) :
for id in ids :  # iterate 
over all checked row ids
query = dyn_db.rogue_rows.id == id 
rows = dyn_db(query).select() # select each 
selected row
for row in rows :
cam_db(cam_db[row.table_name].mac==row.mac).update(rogue=0) 
  # update rows in main tables 

The problem is when I check all the boxes and click submit, only top rows 
from one table are updated, then I have to check remained rows again and 
submit them as well - another top rows from another table will be updated 
etc... I would like them to be updated all at once...

I mentioned that if I comment truncate string, then it works but with a 
flaw - if I refresh page the rows in temporal page duplicate each time. Any 
ideas ??

-- 
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] Change button to loading after clicked

2014-04-23 Thread LoveWeb2py
Hello,

I'm using the form=FORM('Search text:', INPUT(_name='texttofind', 
INPUT(_type='submit')) which generates a button and a search field on a web 
page when I type {{=form}}

How can I change the button to loading when a user clicks it

I found this documentation on jquery 
http://getbootstrap.com/2.3.2/javascript.html#buttons but I'm not sure how 
to assign it to the 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 can I open a temporary PDF in a new tab

2014-04-23 Thread csavorgn
Hi everyone,
I'm using a SQLFORM.factory to get the data I need to generate a PDF file 
using ReportLab.
I'm using a submit  button to check for the data entered and to open a new 
page using redirect:

redirect(URL(default,result, vars=dict(start=form.vars.date_start,
   end=form.vars.date_end)))

In the controller default.py I defined
def result():
start = request.vars['start']
end = request.vars['end']
filename = os.path.join(request.folder,'private',str(uuid4()))
create_pdf(filename, db, start, end)
response.headers['Content-Type']='application/pdf'
data = open(filename,rb).read()
os.unlink(filename)
return data

(The code I'm using is more complex than this.)

Maybe it is not the cleanest way to do this, but when I click on the button 
the temporary PDF opens on the same tab in the browser.

In my app I would like to get a different behaviour: when I click on the 
submit button the PDF should open on a new tab. The PDF should be temporary 
as it is in my current code.
How can I achieve the behaviour I want?

Thanks

Carlo

-- 
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 can I open a temporary PDF in a new tab

2014-04-23 Thread Oli
 
URL('Link for a new tab', _class=btn , _title=T(in a new tab), 
_href=URL(default,yourcontroller,args=[*row.id* http://row.id/]), 
*_target='_blank'*)

Am Mittwoch, 23. April 2014 15:55:50 UTC+2 schrieb csavorgn:

 Hi everyone,
 I'm using a SQLFORM.factory to get the data I need to generate a PDF file 
 using ReportLab.
 I'm using a submit  button to check for the data entered and to open a new 
 page using redirect:

 redirect(URL(default,result, vars=dict(start=form.vars.date_start,
end=form.vars.date_end)))

 In the controller default.py I defined
 def result():
 start = request.vars['start']
 end = request.vars['end']
 filename = os.path.join(request.folder,'private',str(uuid4()))
 create_pdf(filename, db, start, end)
 response.headers['Content-Type']='application/pdf'
 data = open(filename,rb).read()
 os.unlink(filename)
 return data

 (The code I'm using is more complex than this.)

 Maybe it is not the cleanest way to do this, but when I click on the 
 button the temporary PDF opens on the same tab in the browser.

 In my app I would like to get a different behaviour: when I click on the 
 submit button the PDF should open on a new tab. The PDF should be temporary 
 as it is in my current code.
 How can I achieve the behaviour I want?

 Thanks

 Carlo


-- 
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: Issue 1865 code sample as requested

2014-04-23 Thread Remco Boerma
Massimo, 

Thanks for responding in the comment. I've responded to yours but don't 
know if you'd prefer bringing that over to the mailing list or not. 
What's the rule of thumb for that - when to file a bug and keep on posting 
there and when to write to the mailinglist?

Regards, 
Remco 

Op dinsdag 15 april 2014 14:48:43 UTC+2 schreef Remco Boerma:

 Hi, 

 I've finally had the time to play a little with the code sample that was 
 requested on issue 1865. It's in the comment there. 

 https://code.google.com/p/web2py/issues/detail?id=1865

 -- 
 Cheers / Met vr. gr. 
 Remco Boerma 


-- 
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] Please help with Absolute URL

2014-04-23 Thread JoeCodeswell
Dear web2py users group,

I am trying to generate an absolute URL using the URL helper to connect 
with WordPress.com.
Here's the code:
wpcc_consts = {

client_id: '12345', #Joe's
redirect_uri: URL(f='connected', scheme='http', host=
'joecodeswell.com', url_encode=False),

# see http://developer.wordpress.com/docs/oauth2/
wp_authorize_endpoint: 
https://public-api.wordpress.com/oauth2/authorize;,
wp_token_request_endpoint: 
https://public-api.wordpress.com/oauth2/token;,
client_secret: blablabla, #Joes
}

params = {
response_type: code,
client_id: wpcc_consts['client_id'],
redirect_uri: URL(f='connected', scheme='http', host=
'joecodeswell.com', url_encode=False),
}

authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params, scheme=
'https', host='public-api.wordpress.com', url_encode=False)

In [16]: authorize_url_0
Out[16]: 
'https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code'


Question

Why is 'wpcomconn', the name of the app in which this is getting executed, 
showing up right after 'public-api.wordpress.com/'? In the absolute URL 
spec i defined a='oauth2', but it shows up after the current app.

Thanks for the help in advance.
Love and peace,

Joe
Love and peace,

Joe



-- 
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: Please help with Absolute URL

2014-04-23 Thread Anthony
Is this a web2py URL, or are you just trying to use the URL() function to 
generate an external URL (not its intended purpose)? Anyway, you cannot 
leave out the function -- in that case, it assumes the app is the 
controller, the controller is the function, and the current app is the true 
app.

Anthony

On Wednesday, April 23, 2014 11:11:45 AM UTC-4, JoeCodeswell wrote:

 Dear web2py users group,

 I am trying to generate an absolute URL using the URL helper to connect 
 with WordPress.com.
 Here's the code:
 wpcc_consts = {

 client_id: '12345', #Joe's
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),

 # see http://developer.wordpress.com/docs/oauth2/
 wp_authorize_endpoint: 
 https://public-api.wordpress.com/oauth2/authorize;,
 wp_token_request_endpoint: 
 https://public-api.wordpress.com/oauth2/token;,
 client_secret: blablabla, #Joes
 }

 params = {
 response_type: code,
 client_id: wpcc_consts['client_id'],
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),
 }

 authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params, scheme
 ='https', host='public-api.wordpress.com', url_encode=False)

 In [16]: authorize_url_0
 Out[16]: '
 https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code
 '


 Question

 Why is 'wpcomconn', the name of the app in which this is getting 
 executed, showing up right after 'public-api.wordpress.com/'? In the 
 absolute URL spec i defined a='oauth2', but it shows up after the current 
 app.

 Thanks for the help in advance.
 Love and peace,

 Joe
 Love and peace,

 Joe





-- 
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: Please help with Absolute URL

2014-04-23 Thread JoeCodeswell
Dear Anthony,

Thanks for the response. 

Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)?


I am trying to use the URL() function to generate an external URL. I didn't 
know that was not its intended purpose.

you cannot leave out the function -- in that case,...


I thought I specified a value for f==''. 

authorize_url_0 = URL(a='oauth2', c='authorize', f='',   ...

How do I make the f == '' i.e. blank? 

Thanks again, Anthony.

Love and peace,

Joe


On Wednesday, April 23, 2014 9:04:22 AM UTC-7, Anthony wrote:

 Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)? Anyway, you cannot 
 leave out the function -- in that case, it assumes the app is the 
 controller, the controller is the function, and the current app is the true 
 app.

 Anthony

 On Wednesday, April 23, 2014 11:11:45 AM UTC-4, JoeCodeswell wrote:

 Dear web2py users group,

 I am trying to generate an absolute URL using the URL helper to connect 
 with WordPress.com.
 Here's the code:
 wpcc_consts = {

 client_id: '12345', #Joe's
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),

 # see http://developer.wordpress.com/docs/oauth2/
 wp_authorize_endpoint: 
 https://public-api.wordpress.com/oauth2/authorize;,
 wp_token_request_endpoint: 
 https://public-api.wordpress.com/oauth2/token;,
 client_secret: blablabla, #Joes
 }

 params = {
 response_type: code,
 client_id: wpcc_consts['client_id'],
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),
 }

 authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params,scheme
 ='https', host='public-api.wordpress.com', url_encode=False)

 In [16]: authorize_url_0
 Out[16]: '
 https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code
 '


 Question

 Why is 'wpcomconn', the name of the app in which this is getting 
 executed, showing up right after 'public-api.wordpress.com/'? In the 
 absolute URL spec i defined a='oauth2', but it shows up after the 
 current app.

 Thanks for the help in advance.
 Love and peace,

 Joe
 Love and peace,

 Joe





-- 
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: Best way to migrate from sqlite to postgresql (or other db)

2014-04-23 Thread Michael Beller
Over the past week I've experimented with several options (I'm moving from 
sqlite to mysql on python anywhere) and here's what worked for me (and hope 
this helps others) ...

The book describes two methods:

   - export/import all data using CSV files (
   
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--all-tables-at-once-
   )
   - copy between databases using script cpdb.py (
   
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=cpdb#Copy-data-from-one-db-into-another
   )

Previous comments in this thread highlight two other options:

   - sqlite .dump and mysql migration per 
   
http://www.realpython.com/blog/python/web2py-migrating-from-sqlite-to-mysql/#.Ulm3xmTTXCU
   - Mariano/Alan Etkin experimental script - 
   https://groups.google.com/d/msg/web2py-developers/QxeJNByj6qc/cpBHsa1ymUkJ
   
I couldn't get cpdb to work except for a simple model.  I'm still learning 
both python and web2py and couldn't debug the script but believe it has 
something to do with the sequence and dependencies between tables (I have 
about 12 tables with numerous foreign keys).  This is also true of using 
sqlite .dump and mysql migrate (and I also felt this bypassed web2py which 
requires a fake_migrate and preferred an option within web2py since I'm 
also learning MySQL at the same time).

The experimental script seemed straightforward but (1) I wasn't sure how 
to execute the script with both DAL's simultaneously and (2) the primary 
advantage over CSV export/import is the retention of the source row id's 
(which isn't needed if you start with a new database schema - see my 
comments below).

In the end, I used the following procedure using web2py cdv 
export/import to move my production sqlite db to mysql (which only took 
about 7 minutes to execute after learning/testing/experimenting with the 
various options) ...

1. Export all data in CSV format
a. open console and navigate to the web2py folder
b. start web2py in interactive console mode with:
python web2py.py -S your_app_name -M –P
c. export data in csv format with:
db.export_to_csv_file(open('your_app_name_export.csv', 'wb'))
[this stores the file in the root of the web2py directory]
d. exit web2py interactive console mode with:
exit()
2. Prepare web2py application for new database and create new database
a. in console, navigate to application folder
b. backup existing SQLite database (and corresponding .table files) 
with:
cp -r databases databases_bak
c. create empty databases folder with:
rm -r databases
mkdir databases
d. change DAL connection string in app to:
db = DAL('mysql://user_name:password@mysql.server/database_name')
[for pythonanywhere, the database_name is in the form 
user_name$database_name]
e. create new empty mysql database schema (from control panel in 
pythonanywhere or mysql command prompt)
3. Generate database tables and load data
a. start web2py in interactive console mode with:
python web2py.py -S your_app_name -M –P
[this will execute the models and generate the mysql database 
tables and the .table files in the database directory]
c. import data in csv format with:
db.import_from_csv_file(open('your_app_name_export.csv', 'rb'))
db.commit() # this is missing from some of the other instructions 
but is required
d. exit web2py interactive console mode with:
exit()
4. Celebrate!

If you start with a new empty database, all record id's will be the same as 
the source database (and all foreign key references are maintained).  If 
the database had previous transactions, the new data will maintain all 
foreign key references but the id's will not match the source data (which 
is only important if there are any code or external references to specific 
id's as Alan pointed out in his posts).

-- 
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: Bug in deflate of json fields

2014-04-23 Thread Sebastian Ortiz Vasquez


On Monday, April 21, 2014 3:38:08 PM UTC-5, Sebastian Ortiz Vasquez wrote:

 Hi, i discovered a bug, but don't have enoght time to solve this.

 The problem is this, i'm using psycopg2==2.5.2 to get this working, 
 because pg8000 still in web2py distribution does not work.

 I defined a field of type 'json', (postgresql supports it), when web2py 
 inflates the json field as a dict, thats good, but if i do change the json 
 field, and i do a row.update_record() it fails as follows, becuse DAL is 
 not able to deflate the field as json, a work arround i used is to set the 
 field using row[field] = gluon.contrib.simplejson.dumps(dict) and it works, 
 but is really annoying if i do change any other field in this way 
 row[any_field] = 'some data', and the call the row.update_record() it fails 
 becuase the same problem with the json field.


 Thank you,


 File applications/pyforms/modules/pyform_forms.py, line 339, in 
 _edit_grid_data
 if row.update_record():
   File /home/sebas/dev/orfeo_pyforms/web2py/gluon/dal.py, line 10640, in 
 __call__
 table._db(table._id==id,ignore_common_filters=True).update(**newfields)
   File /home/sebas/dev/orfeo_pyforms/web2py/gluon/dal.py, line 10549, in 
 update
 ret = db._adapter.update(%s % table._tablename,self.query,fields)
   File /home/sebas/dev/orfeo_pyforms/web2py/gluon/dal.py, line 1620, in 
 update
 raise e
 DataError: invalid input syntax for type json
 LINE 1: ...topografica=NULL,reviso=NULL,estructura_ecologica='{u''1'': ...



I have been debugging a little bit this problem and found the following, in 
the model a json field is marked as  readable=True, writable=False, i 
build my own JqGridWidget for allowing insert data via ajax request from 
the jqGrid widget, and the  SQLForm, in conjunction with the inflated that 
from the DAL gives this erratic behaviuor.

When a field is not writable the FORM send the update with the data from 
the record, if exists, and the data on the record was inflated to a dict, 
but when the RecordUpdates tries to write to the database it does not 
deflates the dict to a proper json string, and fails. One workarround is 
the following, other more general could be if the db adapter could do the 
proper deflate.

in sqlhtml.py

if dbio:
if 'delete_this_record' in fields:
# this should never happen but seems to happen to some
del fields['delete_this_record']
for field in self.table:
if not field.name in fields and field.writable is False \
and field.update is None and field.compute is None:
if record_id and self.record:
#: Added valitation for deflate the data correctly. 
if field.type == 'json':
fields[field.name] = 
serializers.json(self.record[field.name])
else:
fields[field.name] = self.record[field.name]
elif not self.table[field.name].default is None:
fields[field.name] = self.table[field.name].default






-- 
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: Please help with Absolute URL

2014-04-23 Thread Anthony
You have to specify a non-falsey value for f. Sorry, but I don't think you 
can do what you want to do with the URL() function. Since it's an external 
URL, just write the URL by hand. To build the query string, just do:

import urllib
query = urllib.urlencode(params)

And if you don't want the encoding:

query = urllib.unquote(query)

Anthony

On Wednesday, April 23, 2014 12:15:19 PM UTC-4, JoeCodeswell wrote:

 Dear Anthony,

 Thanks for the response. 

 Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)?


 I am trying to use the URL() function to generate an external URL. I 
 didn't know that was not its intended purpose.

 you cannot leave out the function -- in that case,...


 I thought I specified a value for f==''. 

 authorize_url_0 = URL(a='oauth2', c='authorize', f='',   ...

 How do I make the f == '' i.e. blank? 

 Thanks again, Anthony.

 Love and peace,

 Joe


 On Wednesday, April 23, 2014 9:04:22 AM UTC-7, Anthony wrote:

 Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)? Anyway, you cannot 
 leave out the function -- in that case, it assumes the app is the 
 controller, the controller is the function, and the current app is the true 
 app.

 Anthony

 On Wednesday, April 23, 2014 11:11:45 AM UTC-4, JoeCodeswell wrote:

 Dear web2py users group,

 I am trying to generate an absolute URL using the URL helper to connect 
 with WordPress.com.
 Here's the code:
 wpcc_consts = {

 client_id: '12345', #Joe's
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),

 # see http://developer.wordpress.com/docs/oauth2/
 wp_authorize_endpoint: 
 https://public-api.wordpress.com/oauth2/authorize;,
 wp_token_request_endpoint: 
 https://public-api.wordpress.com/oauth2/token;,
 client_secret: blablabla, #Joes
 }

 params = {
 response_type: code,
 client_id: wpcc_consts['client_id'],
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),
 }

 authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params,scheme
 ='https', host='public-api.wordpress.com', url_encode=False)

 In [16]: authorize_url_0
 Out[16]: '
 https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code
 '


 Question

 Why is 'wpcomconn', the name of the app in which this is getting 
 executed, showing up right after 'public-api.wordpress.com/'? In the 
 absolute URL spec i defined a='oauth2', but it shows up after the 
 current app.

 Thanks for the help in advance.
 Love and peace,

 Joe
 Love and peace,

 Joe





-- 
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 can I open a temporary PDF in a new tab

2014-04-23 Thread csavorgn
I tried to use your code (with the obvious modifications) but I can't 
really figure out how to use it... 
Could you better explain your solution?
Thanks
Carlo

On Wednesday, April 23, 2014 4:00:26 PM UTC+2, Oli wrote:

  
 URL('Link for a new tab', _class=btn , _title=T(in a new tab), 
 _href=URL(default,yourcontroller,args=[*row.id* http://row.id/]), 
 *_target='_blank'*)

 Am Mittwoch, 23. April 2014 15:55:50 UTC+2 schrieb csavorgn:

 Hi everyone,
 I'm using a SQLFORM.factory to get the data I need to generate a PDF file 
 using ReportLab.
 I'm using a submit  button to check for the data entered and to open a 
 new page using redirect:

 redirect(URL(default,result, vars=dict(start=form.vars.date_start,
end=form.vars.date_end)))

 In the controller default.py I defined
 def result():
 start = request.vars['start']
 end = request.vars['end']
 filename = os.path.join(request.folder,'private',str(uuid4()))
 create_pdf(filename, db, start, end)
 response.headers['Content-Type']='application/pdf'
 data = open(filename,rb).read()
 os.unlink(filename)
 return data

 (The code I'm using is more complex than this.)

 Maybe it is not the cleanest way to do this, but when I click on the 
 button the temporary PDF opens on the same tab in the browser.

 In my app I would like to get a different behaviour: when I click on the 
 submit button the PDF should open on a new tab. The PDF should be temporary 
 as it is in my current code.
 How can I achieve the behaviour I want?

 Thanks

 Carlo



-- 
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] SQLFORM.grid() simple search vs complex search

2014-04-23 Thread Richard
Hello,

Is there a way to tell SQLFORM.grid to only allow simple search? I mean, 
not have the query constructor to appear, just the search box where we can 
search in all the fields?

Thanks

Richard

-- 
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: 'Table' object has no attribute 'db' in appadmin deleting db.auth_user entry

2014-04-23 Thread DenesL
Hi all,

web2py™ Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Python Python 2.7.5+: /usr/local/bin/uwsgi (prefix: /usr)
on pythonanywhere.com
   
  
Trying to delete an entry from db.auth_user via appadmin I get

Traceback (most recent call last):
  File /home/w2eca/web2py/gluon/restricted.py, line 220, in restricted
exec ccode in environment
  File /home/w2eca/web2py/applications/welcome/controllers/appadmin.py 
https://w2eca.pythonanywhere.com/admin/default/edit/welcome/controllers/appadmin.py,
 line 674, in module
  File /home/w2eca/web2py/gluon/globals.py, line 385, in lambda
self._caller = lambda f: f()
  File /home/w2eca/web2py/applications/welcome/controllers/appadmin.py 
https://w2eca.pythonanywhere.com/admin/default/edit/welcome/controllers/appadmin.py,
 line 346, in update
if form.accepts(request.vars, session):
  File /home/w2eca/web2py/gluon/sqlhtml.py, line 1381, in accepts
**kwargs
  File /home/w2eca/web2py/gluon/html.py, line 2100, in accepts
status = self._traverse(status, hideerror)
  File /home/w2eca/web2py/gluon/html.py, line 872, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File /home/w2eca/web2py/gluon/html.py, line 872, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File /home/w2eca/web2py/gluon/html.py, line 872, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File /home/w2eca/web2py/gluon/html.py, line 872, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File /home/w2eca/web2py/gluon/html.py, line 879, in _traverse
newstatus = self._validate()
  File /home/w2eca/web2py/gluon/html.py, line 1843, in _validate
(value, errors) = validator(value)
  File /home/w2eca/web2py/gluon/validators.py, line 657, in __call__
table = self.dbset.db[tablename]
  File /home/w2eca/web2py/gluon/dal.py, line 8912, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'db'

File /home/w2eca/web2py/gluon/restricted.py in restricted at line 220
File /home/w2eca/web2py/applications/welcome/controllers/appadmin.py in 
module at line 674
File /home/w2eca/web2py/gluon/globals.py in lambda at line 385
File /home/w2eca/web2py/applications/welcome/controllers/appadmin.py in update 
at line 346
File /home/w2eca/web2py/gluon/sqlhtml.py in accepts at line 1381
File /home/w2eca/web2py/gluon/html.py in accepts at line 2100
File /home/w2eca/web2py/gluon/html.py in _traverse at line 872
File /home/w2eca/web2py/gluon/html.py in _traverse at line 872
File /home/w2eca/web2py/gluon/html.py in _traverse at line 872
File /home/w2eca/web2py/gluon/html.py in _traverse at line 872
File /home/w2eca/web2py/gluon/html.py in _traverse at line 879
File /home/w2eca/web2py/gluon/html.py in _validate at line 1843
File /home/w2eca/web2py/gluon/validators.py in __call__ at line 657
File /home/w2eca/web2py/gluon/dal.py in __getitem__ at line 8912

Thanks for any suggestions to debug,
Denes


-- 
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] SQLFORM.grid() simple search vs complex search

2014-04-23 Thread Richard Vézina
This could be a new feature for .grid()...

In gluon/sqlhtml.py near line 2261...

This :

INPUT(_name='keywords', _value=request.vars.keywords,
   _id=skeywords_id,
   _onfocus=jQuery('#%s').change();jQuery('#%s').slideDown(); %
(spanel_id, sfields_id)),

Could become this :

INPUT(_name='keywords', _value=request.vars.keywords,
   _id=skeywords_id,
   _onfocus=jQuery('#%s').change();jQuery('#%s').slideDown(); %
(spanel_id, sfields_id) if complexe_search else ''
   ),


We need to add complexe_search at line 1832 insert :

complexe_search=True

What do you think??

Richard





On Wed, Apr 23, 2014 at 1:26 PM, Richard ml.richard.vez...@gmail.comwrote:

 Hello,

 Is there a way to tell SQLFORM.grid to only allow simple search? I mean,
 not have the query constructor to appear, just the search box where we can
 search in all the fields?

 Thanks

 Richard

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


-- 
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] SQLFORM.grid() simple search vs complex search

2014-04-23 Thread Anthony
Maybe call it advanced_search.

On Wednesday, April 23, 2014 1:52:59 PM UTC-4, Richard wrote:

 This could be a new feature for .grid()...

 In gluon/sqlhtml.py near line 2261...

 This :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown(); % 
 (spanel_id, sfields_id)),

 Could become this :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown(); % 
 (spanel_id, sfields_id) if complexe_search else ''
),


 We need to add complexe_search at line 1832 insert :

 complexe_search=True

 What do you think??

 Richard





 On Wed, Apr 23, 2014 at 1:26 PM, Richard ml.richard.vez...@gmail.comwrote:

 Hello,

 Is there a way to tell SQLFORM.grid to only allow simple search? I mean, 
 not have the query constructor to appear, just the search box where we can 
 search in all the fields?

 Thanks

 Richard

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




-- 
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] SQLFORM.grid() simple search vs complex search

2014-04-23 Thread Richard Vézina
Yop, you are right!

I will send a PR on github and see what happen...

Richard


On Wed, Apr 23, 2014 at 2:19 PM, Anthony abasta...@gmail.com wrote:

 Maybe call it advanced_search.


 On Wednesday, April 23, 2014 1:52:59 PM UTC-4, Richard wrote:

 This could be a new feature for .grid()...

 In gluon/sqlhtml.py near line 2261...

 This :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown();
 % (spanel_id, sfields_id)),

 Could become this :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown();
 % (spanel_id, sfields_id) if complexe_search else ''
),


 We need to add complexe_search at line 1832 insert :

 complexe_search=True

 What do you think??

 Richard





 On Wed, Apr 23, 2014 at 1:26 PM, Richard ml.richard.vez...@gmail.comwrote:

 Hello,

 Is there a way to tell SQLFORM.grid to only allow simple search? I mean,
 not have the query constructor to appear, just the search box where we can
 search in all the fields?

 Thanks

 Richard

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


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


-- 
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] SQLFORM.grid() simple search vs complex search

2014-04-23 Thread Richard Vézina
https://github.com/web2py/web2py/pull/428


On Wed, Apr 23, 2014 at 2:24 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Yop, you are right!

 I will send a PR on github and see what happen...

 Richard


 On Wed, Apr 23, 2014 at 2:19 PM, Anthony abasta...@gmail.com wrote:

 Maybe call it advanced_search.


 On Wednesday, April 23, 2014 1:52:59 PM UTC-4, Richard wrote:

 This could be a new feature for .grid()...

 In gluon/sqlhtml.py near line 2261...

 This :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown();
 % (spanel_id, sfields_id)),

 Could become this :

 INPUT(_name='keywords', _value=request.vars.keywords,
_id=skeywords_id,
_onfocus=jQuery('#%s').change();jQuery('#%s').slideDown();
 % (spanel_id, sfields_id) if complexe_search else ''
),


 We need to add complexe_search at line 1832 insert :

 complexe_search=True

 What do you think??

 Richard





 On Wed, Apr 23, 2014 at 1:26 PM, Richard ml.richard.vez...@gmail.comwrote:

 Hello,

 Is there a way to tell SQLFORM.grid to only allow simple search? I
 mean, not have the query constructor to appear, just the search box where
 we can search in all the fields?

 Thanks

 Richard

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


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




-- 
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: Please help with Absolute URL

2014-04-23 Thread JoeCodeswell


On Wednesday, April 23, 2014 9:31:51 AM UTC-7, Anthony wrote:

 You have to specify a non-falsey value for f. Sorry, but I don't think you 
 can do what you want to do with the URL() function. Since it's an external 
 URL, just write the URL by hand. To build the query string, just do:

 import urllib
 query = urllib.urlencode(params)

 And if you don't want the encoding:

 query = urllib.unquote(query)

 Anthony

 On Wednesday, April 23, 2014 12:15:19 PM UTC-4, JoeCodeswell wrote:

 Dear Anthony,

 Thanks for the response. 

 Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)?


 I am trying to use the URL() function to generate an external URL. I 
 didn't know that was not its intended purpose.

 you cannot leave out the function -- in that case,...


 I thought I specified a value for f==''. 

 authorize_url_0 = URL(a='oauth2', c='authorize', f='',   ...

 How do I make the f == '' i.e. blank? 

 Thanks again, Anthony.

 Love and peace,

 Joe


 On Wednesday, April 23, 2014 9:04:22 AM UTC-7, Anthony wrote:

 Is this a web2py URL, or are you just trying to use the URL() function 
 to generate an external URL (not its intended purpose)? Anyway, you cannot 
 leave out the function -- in that case, it assumes the app is the 
 controller, the controller is the function, and the current app is the true 
 app.

 Anthony

 On Wednesday, April 23, 2014 11:11:45 AM UTC-4, JoeCodeswell wrote:

 Dear web2py users group,

 I am trying to generate an absolute URL using the URL helper to connect 
 with WordPress.com.
 Here's the code:
 wpcc_consts = {

 client_id: '12345', #Joe's
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),

 # see http://developer.wordpress.com/docs/oauth2/
 wp_authorize_endpoint: 
 https://public-api.wordpress.com/oauth2/authorize;,
 wp_token_request_endpoint: 
 https://public-api.wordpress.com/oauth2/token;,
 client_secret: blablabla, #Joes
 }

 params = {
 response_type: code,
 client_id: wpcc_consts['client_id'],
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),
 }

 authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params,scheme
 ='https', host='public-api.wordpress.com', url_encode=False)

 In [16]: authorize_url_0
 Out[16]: '
 https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code
 '


 Question

 Why is 'wpcomconn', the name of the app in which this is getting 
 executed, showing up right after 'public-api.wordpress.com/'? In the 
 absolute URL spec i defined a='oauth2', but it shows up after the 
 current app.

 Thanks for the help in advance.
 Love and peace,

 Joe
 Love and peace,

 Joe





-- 
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: Please help with Absolute URL

2014-04-23 Thread JoeCodeswell
Thanks, Anthony.

Sounds like a plan.

Love and peace,

Joe

On Wednesday, April 23, 2014 9:31:51 AM UTC-7, Anthony wrote:

 You have to specify a non-falsey value for f. Sorry, but I don't think you 
 can do what you want to do with the URL() function. Since it's an external 
 URL, just write the URL by hand. To build the query string, just do:

 import urllib
 query = urllib.urlencode(params)

 And if you don't want the encoding:

 query = urllib.unquote(query)

 Anthony

 On Wednesday, April 23, 2014 12:15:19 PM UTC-4, JoeCodeswell wrote:

 Dear Anthony,

 Thanks for the response. 

 Is this a web2py URL, or are you just trying to use the URL() function to 
 generate an external URL (not its intended purpose)?


 I am trying to use the URL() function to generate an external URL. I 
 didn't know that was not its intended purpose.

 you cannot leave out the function -- in that case,...


 I thought I specified a value for f==''. 

 authorize_url_0 = URL(a='oauth2', c='authorize', f='',   ...

 How do I make the f == '' i.e. blank? 

 Thanks again, Anthony.

 Love and peace,

 Joe


 On Wednesday, April 23, 2014 9:04:22 AM UTC-7, Anthony wrote:

 Is this a web2py URL, or are you just trying to use the URL() function 
 to generate an external URL (not its intended purpose)? Anyway, you cannot 
 leave out the function -- in that case, it assumes the app is the 
 controller, the controller is the function, and the current app is the true 
 app.

 Anthony

 On Wednesday, April 23, 2014 11:11:45 AM UTC-4, JoeCodeswell wrote:

 Dear web2py users group,

 I am trying to generate an absolute URL using the URL helper to connect 
 with WordPress.com.
 Here's the code:
 wpcc_consts = {

 client_id: '12345', #Joe's
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),

 # see http://developer.wordpress.com/docs/oauth2/
 wp_authorize_endpoint: 
 https://public-api.wordpress.com/oauth2/authorize;,
 wp_token_request_endpoint: 
 https://public-api.wordpress.com/oauth2/token;,
 client_secret: blablabla, #Joes
 }

 params = {
 response_type: code,
 client_id: wpcc_consts['client_id'],
 redirect_uri: URL(f='connected', scheme='http', host='
 joecodeswell.com', url_encode=False),
 }

 authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params,scheme
 ='https', host='public-api.wordpress.com', url_encode=False)

 In [16]: authorize_url_0
 Out[16]: '
 https://public-api.wordpress.com/wpcomconn/oauth2/authorize?client_id=34759redirect_uri=http://joecodeswell.com/wpcomconn/default/connectedresponse_type=code
 '


 Question

 Why is 'wpcomconn', the name of the app in which this is getting 
 executed, showing up right after 'public-api.wordpress.com/'? In the 
 absolute URL spec i defined a='oauth2', but it shows up after the 
 current app.

 Thanks for the help in advance.
 Love and peace,

 Joe
 Love and peace,

 Joe





-- 
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] list:reference field number of entries

2014-04-23 Thread BlueShadow
Hi,
I got a list:reference field where there are very many entries to choose 
from and the default field shows only 5 entries is there a way to increase 
that number or get a better field to select multiple entries?
thanks for your 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.


Re: [web2py] list:reference field number of entries

2014-04-23 Thread Richard Vézina
Use a jquery multiselect plugin... Or set a size to the select :

select size=10 multiple

With _size='10' maybe...

Richard


On Wed, Apr 23, 2014 at 3:18 PM, BlueShadow kevin.bet...@gmail.com wrote:

 Hi,
 I got a list:reference field where there are very many entries to choose
 from and the default field shows only 5 entries is there a way to increase
 that number or get a better field to select multiple entries?
 thanks for your 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.


-- 
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] list:reference field number of entries

2014-04-23 Thread Niphlod
this should work

db.table.field.widget = lambda field,value: 
SQLFORM.widgets.multiple.widget(field,value,size=10)


-- 
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: Unexpected behavior using GRID form with selectable option.

2014-04-23 Thread Niphlod
first of all: a simpler example reproducing the erroneous behaviour may 
pinpoint better the cause.
To help debugging, I'd avoid truncating and reinserting records every time 
you land on index()
Then, I have a question: what does it mean only top rows from one table 
are updated ?


On Wednesday, April 23, 2014 1:29:10 PM UTC+2, alex wrote:

 Hello guys, I'm experiencing an unexpected behavior using grid form with 
 selectable option, need help.

 I have a temporal table 'rogue_rows' in a database 'dyn_db'. This table 
 includes rows from different tables of another database. Please refer to 
 the controller index() code:

 def index():
 dyn_db.rogue_rows.truncate()   
# truncate table each time index is called 
 
 for table in tables_list :  # table list contains needed tables. 
 query=(cam_db[table].trunk==0)  (cam_db[table].rogue==1)
 rows = 
 cam_db(query).select()# 
 extract needed rows from current table
 for row in rows :  
# insert each row in temporal table
 dyn_db.rogue_rows.insert(table_name=table,
  node_name=row.node_name,
  mac=row.mac,
  port=row.port,
  )
 
 
 grid=SQLFORM.grid(dyn_db.rogue_rows,# 
 convey dyn_db.rogue_rows table to the grid form
   fields=[dyn_db.rogue_rows.node_name,
   dyn_db.rogue_rows.mac,
   dyn_db.rogue_rows.port],
   selectable=lambda ids : 
 allow_mac(ids)# add checkboxes to each row, hand over 
 selected row ids to function allow_macs()
   )
 return dict(grid=grid)

 The index() function works great, it displays all the rows from the 
 different tables. When I check all the boxes, let's say there were 5 rows, 
 and click submit - grid calls allow_macs() with ids = [1,2,3,4,5]. Until 
 now, it was all fine. Please refer to allow_mac() func:

 def allow_mac(ids) :
 for id in ids :  # iterate 
 over all checked row ids
 query = dyn_db.rogue_rows.id == id 
 rows = dyn_db(query).select() # select each 
 selected row
 for row in rows :
 cam_db(cam_db[row.table_name].mac==row.mac).update(rogue=0)   
 # update rows in main tables 

 The problem is when I check all the boxes and click submit, only top rows 
 from one table are updated, then I have to check remained rows again and 
 submit them as well - another top rows from another table will be updated 
 etc... I would like them to be updated all at once...

 I mentioned that if I comment truncate string, then it works but with a 
 flaw - if I refresh page the rows in temporal page duplicate each time. Any 
 ideas ??



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

2014-04-23 Thread Niphlod
you're doing all wrong. Stop copy/pasting for a sec and take a look to 
docs.it'll save you from multiple headaches.

in this case, you're doing wrong form processing.

It's either

form = SQLFORM(...)
if form.accepts(request.vars, session):
things to do when form is valid
elif form.errors:
things to do when form has errors
else:
things to do when page is loaded the first time
return dict(form=form)



or (newer)

form = SQLFORM(...)
if form.process().accepted:
things to do when form is valid
elif form.errors:
things to do when form has errors
else:
things to do when page is loaded the first time
return dict(form=form)




On Tuesday, April 22, 2014 7:32:03 PM UTC+2, ureal frank wrote:

 Hi,

 /newbie here/

 I’ve up and running a very very simple task scheduler but I think it’s not 
 well designed :/

 under models/scheduler.py I have:

 
 from gluon.scheduler import Scheduler

 def task_add(name, target):
 sum = 'hello ' + name + ' ' + target + '\n'
 with open('/tmp/tasks', 'w') as f:
 f.write(sum)

 scheduler = Scheduler(db, dict(task_add=task_add))
 “

 and in controller:

 “
 def new():

 form = SQLFORM(db.scan)
  
 name = “”
 target = “

 if form.process().accepts(request.vars, session):

 name = form.vars.name
 target = form.vars.target

 response.flash = ‘Great scan'

 elif form.errors:
 response.flash = 'Error, try again'

 scheduler.queue_task('task_add’,
 pargs=[],
 pvars={'name': name, 'target': target},
 start_time=request.now, #datetime
 stop_time = None,   #datetime
 timeout = 60,   #seconds
 prevent_drift=False,
 period=60,  #seconds
 immediate=False,
 repeats = 1)

 return dict(scans=scans, form=form)
 “

 This snippet is working but I think this “scheduler.queue_task(…)” should 
 be processed inside “if form.process().accepts()”. But if I change the 
 scheduler snipper into that code section, the task wont run and I don’t 
 know why.

 two: questions
 1) what I am  doing wrong?
 1.1) Maybe I should db.commit when the task is over. Should I code this 
 under scheduler.py? 
 2) where can I learn more about debugging?

 Many many thanks in advance :)

 Cheers,
 -- 
 Frank


-- 
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] define my own HTML helper function?

2014-04-23 Thread Sharon Correll
Is there any way to define your own helper-like function that will generate 
a bit of parameterized HTML? What I'd like to do is:

table
  tr
{{=TD_custom(data[field1])}}
{{=TD_custom(data[field2])}}
{{=TD_custom(data[field3])}}
{{=TD_custom(data[field4])}}
{{=TD_custom(data[field5])}}
{{=TD_custom(data[field6])}}
{{=TD_custom(data[field7])}}
...
  tr
table

where the function is defined somewhere in my files:

def TD_custom(string) :
return TD(DIV(string, _class=custom, ...))


Something that would allow me to avoid duplicating the detailed structure 
of the td for every field.

-- 
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: define my own HTML helper function?

2014-04-23 Thread Niphlod
either you put that function in models (works out of the box throughout all 
the app), or you write the function in every view it's needed. For the 
latter, please read 
http://web2py.com/books/default/chapter/29/05/the-views#Functions-in-views

On Wednesday, April 23, 2014 10:19:55 PM UTC+2, Sharon Correll wrote:

 Is there any way to define your own helper-like function that will 
 generate a bit of parameterized HTML? What I'd like to do is:

 table
   tr
 {{=TD_custom(data[field1])}}
 {{=TD_custom(data[field2])}}
 {{=TD_custom(data[field3])}}
 {{=TD_custom(data[field4])}}
 {{=TD_custom(data[field5])}}
 {{=TD_custom(data[field6])}}
 {{=TD_custom(data[field7])}}
 ...
   tr
 table

 where the function is defined somewhere in my files:

 def TD_custom(string) :
 return TD(DIV(string, _class=custom, ...))


 Something that would allow me to avoid duplicating the detailed structure 
 of the td for every field.



-- 
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: define my own HTML helper function?

2014-04-23 Thread Sharon Correll
Great, 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.


Re: [web2py] list:reference field number of entries

2014-04-23 Thread BlueShadow
Thanks Niphlod yours works.
Richard can you tell me how one can implement the jquery multiple select 
plugin.
I tried a fancy one some time ago which had two windows one showing the 
selected and one showing the unselected. but I could never get it to work.

-- 
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 can I open a temporary PDF in a new tab

2014-04-23 Thread csavorgn
Would there be a way to do what I explained if I give up using the 
SQLFORM.factory? How could I validate my form using e.g. JavaScript?

On Wednesday, April 23, 2014 3:55:50 PM UTC+2, csavorgn wrote:

 Hi everyone,
 I'm using a SQLFORM.factory to get the data I need to generate a PDF file 
 using ReportLab.
 I'm using a submit  button to check for the data entered and to open a new 
 page using redirect:

 redirect(URL(default,result, vars=dict(start=form.vars.date_start,
end=form.vars.date_end)))

 In the controller default.py I defined
 def result():
 start = request.vars['start']
 end = request.vars['end']
 filename = os.path.join(request.folder,'private',str(uuid4()))
 create_pdf(filename, db, start, end)
 response.headers['Content-Type']='application/pdf'
 data = open(filename,rb).read()
 os.unlink(filename)
 return data

 (The code I'm using is more complex than this.)

 Maybe it is not the cleanest way to do this, but when I click on the 
 button the temporary PDF opens on the same tab in the browser.

 In my app I would like to get a different behaviour: when I click on the 
 submit button the PDF should open on a new tab. The PDF should be temporary 
 as it is in my current code.
 How can I achieve the behaviour I want?

 Thanks

 Carlo


-- 
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: REF: Bare Ajax Login

2014-04-23 Thread select
Was fighting with the problem in 2011 and still do, how to log in with ajax?
The problem is that I have a one pager app with client site js code that 
needs to register if the user is logged in
when I login with e.g. 
index.html:
div id=i-login-form/div


js code:
web2py_component(localconfig.baseurl + '/default/user.load/login', 
'i-login-form')

default.py unchanged from welcome app

user.load
{{=form}}

I have not found a way to register in the js code if the login was a 
success or fail

I modified web2py_component so that it has a callback that is executed 
every time the ajax call in web2py_ajax_page (via web2py_component) is 
completed

web2py_component(localconfig.baseurl + '/default/user.load/login', 
'i-login-form', undefined, undefined, function() {
// do some other ajax call if the login was a success
});


But this is far from ideal. The callback code must check if this is the 
first call and if the login was a success. Also if the login failed (e.g. 
an email was provided but no password) no form is returned :(

Do I really have to write my own server side login methods to make this 
work? Any news on this?


On Friday, May 24, 2013 6:14:06 AM UTC+2, software.ted wrote:

 In addition, auth.login_bare() seems to check only with auth_user table, 
 if my authentication is based on LDAP it may not work. Any progress that 
 has been made  on auth.ajax_login()?
 On 24 May 2013 05:58, Teddy Nyambe softwa...@gmail.com javascript: 
 wrote:

 Why I asked cause a 2 months or so Massimo contributed to a similar 
 thread and this is what he wrote:

 Should we offer something like {{=auth.ajax_login()}} helper which 
 submits to /user/login? If would not be difficult to write. 
 How should it work?

 The guy who hd asked a question on pure Ajax login had used 
 auth.login_bare() and from my assessment he seemed to hv challenges with it.
 On 24 May 2013 05:46, Teddy Nyambe softwa...@gmail.com javascript: 
 wrote:

 Of course read the book, auth.login_bare() manages my sessions 
 automatically? Will check it out thanx
 On 23 May 2013 20:09, Anthony abas...@gmail.com javascript: wrote:

 Basic authentication won't do anything with the session -- it requires 
 sending the credentials on every request -- probably not what's desired 
 here. Instead, the very next section in the book may help: 
 http://www.web2py.com/book/default/chapter/09#Manual-Authentication. 
 You can post the login credentials via Ajax and then use auth.login_bare() 
 to handle the login.

 Anthony

 On Thursday, May 23, 2013 1:39:13 PM UTC-4, Derek wrote:

 You did read the book before you asked, yes?

 http://www.web2py.com/book/default/chapter/09#Access-
 Control-and-Basic-Authentication

 On Thursday, May 23, 2013 9:49:21 AM UTC-7, software.ted wrote:

 Is there a way of using a pure Ajax request to web2py authentication 
 and create a session for a successfully logged in user?

 -- 
 
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools 
 he is all - Thomas Carlyle 1795-1881

 /~ 

  -- 
  
 --- 
 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 javascript:.
 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/d/optout.


Re: [web2py] Re: REF: Bare Ajax Login

2014-04-23 Thread select
I just wanted to mention that a similar problem exist for 
request_reset_password,
the call works, passoword is restet the email is send but there is just a 
blank return and I have no idea how to react on that on the client side 
without rewriting the web2py_ajax... routines

On Thursday, April 24, 2014 12:05:10 AM UTC+2, select wrote:

 Was fighting with the problem in 2011 and still do, how to log in with 
 ajax?
 The problem is that I have a one pager app with client site js code that 
 needs to register if the user is logged in
 when I login with e.g. 
 index.html:
 div id=i-login-form/div


 js code:
 web2py_component(localconfig.baseurl + '/default/user.load/login', 
 'i-login-form')

 default.py unchanged from welcome app

 user.load
 {{=form}}

 I have not found a way to register in the js code if the login was a 
 success or fail

 I modified web2py_component so that it has a callback that is executed 
 every time the ajax call in web2py_ajax_page (via web2py_component) is 
 completed

 web2py_component(localconfig.baseurl + '/default/user.load/login', 
 'i-login-form', undefined, undefined, function() {
 // do some other ajax call if the login was a success
 });


 But this is far from ideal. The callback code must check if this is the 
 first call and if the login was a success. Also if the login failed (e.g. 
 an email was provided but no password) no form is returned :(

 Do I really have to write my own server side login methods to make this 
 work? Any news on this?


 On Friday, May 24, 2013 6:14:06 AM UTC+2, software.ted wrote:

 In addition, auth.login_bare() seems to check only with auth_user table, 
 if my authentication is based on LDAP it may not work. Any progress that 
 has been made  on auth.ajax_login()?
 On 24 May 2013 05:58, Teddy Nyambe softwa...@gmail.com wrote:

 Why I asked cause a 2 months or so Massimo contributed to a similar 
 thread and this is what he wrote:

 Should we offer something like {{=auth.ajax_login()}} helper which 
 submits to /user/login? If would not be difficult to write. 
 How should it work?

 The guy who hd asked a question on pure Ajax login had used 
 auth.login_bare() and from my assessment he seemed to hv challenges with it.
 On 24 May 2013 05:46, Teddy Nyambe softwa...@gmail.com wrote:

 Of course read the book, auth.login_bare() manages my sessions 
 automatically? Will check it out thanx
 On 23 May 2013 20:09, Anthony abas...@gmail.com wrote:

 Basic authentication won't do anything with the session -- it requires 
 sending the credentials on every request -- probably not what's desired 
 here. Instead, the very next section in the book may help: 
 http://www.web2py.com/book/default/chapter/09#Manual-Authentication. 
 You can post the login credentials via Ajax and then use 
 auth.login_bare() 
 to handle the login.

 Anthony

 On Thursday, May 23, 2013 1:39:13 PM UTC-4, Derek wrote:

 You did read the book before you asked, yes?

 http://www.web2py.com/book/default/chapter/09#Access-
 Control-and-Basic-Authentication

 On Thursday, May 23, 2013 9:49:21 AM UTC-7, software.ted wrote:

 Is there a way of using a pure Ajax request to web2py authentication 
 and create a session for a successfully logged in user?

 -- 
 
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools 
 he is all - Thomas Carlyle 1795-1881

 /~ 

  -- 
  
 --- 
 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/d/optout.


[web2py] How to hide buttons from form

2014-04-23 Thread Fabiano Almeida
Hi,

How to hide buttons  from form?

designrequestresponsesessiondb tablesdb stats

Thanks,

Fabiano

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

2014-04-23 Thread Frank
Hi Niphold,

many thanks for your reply and valuable tips.
On 23 Apr 2014 at 20:59:52, Niphlod (niph...@gmail.com) wrote:

you're doing all wrong. Stop copy/pasting for a sec and take a look to 
docs.it'll save you from multiple headaches.
Despite my error, isn’t it normal doing some copy-past while giving  first 
steps?



in this case, you're doing wrong form processing.

It's either

form = SQLFORM(...)
if form.accepts(request.vars, session):
    things to do when form is valid
elif form.errors:
    things to do when form has errors
else:
    things to do when page is loaded the first time
return dict(form=form)



or (newer)

form = SQLFORM(...)
if form.process().accepted:
    things to do when form is valid
elif form.errors:
    things to do when form has errors
else:
    things to do when page is loaded the first time
return dict(form=form)



I’ve changed the code to this last newer form and it is working fine.
Yes It makes sense but I think what confuses me most is the ‘so many ways to do 
it’.

Meanwhile, looking here 
http://web2py.com/books/default/chapter/29/07/forms-and-validators I can’t 
figure where is the newer or ‘older’ version.

regards,
Frank



On Tuesday, April 22, 2014 7:32:03 PM UTC+2, ureal frank wrote:
Hi,

/newbie here/

I’ve up and running a very very simple task scheduler but I think it’s not well 
designed :/

under models/scheduler.py I have:


from gluon.scheduler import Scheduler

def task_add(name, target):
    sum = 'hello ' + name + ' ' + target + '\n'
    with open('/tmp/tasks', 'w') as f:
        f.write(sum)

scheduler = Scheduler(db, dict(task_add=task_add))
“

and in controller:

“
def new():

    form = SQLFORM(db.scan)
 
    name = “”
    target = “

    if form.process().accepts(request.vars, session):

        name = form.vars.name
        target = form.vars.target

        response.flash = ‘Great scan'

    elif form.errors:
        response.flash = 'Error, try again'

    scheduler.queue_task('task_add’,
pargs=[],
        pvars={'name': name, 'target': target},
        start_time=request.now,     #datetime
        stop_time = None,           #datetime
        timeout = 60,               #seconds
        prevent_drift=False,
        period=60,                  #seconds
        immediate=False,
        repeats = 1)

    return dict(scans=scans, form=form)
“

This snippet is working but I think this “scheduler.queue_task(…)” should be 
processed inside “if form.process().accepts()”. But if I change the scheduler 
snipper into that code section, the task wont run and I don’t know why.

two: questions
1) what I am  doing wrong?
1.1) Maybe I should db.commit when the task is over. Should I code this under 
scheduler.py? 
2) where can I learn more about debugging?

Many many thanks in advance :)

Cheers,
-- 
Frank
--
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.

-- 
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] Insert given in the table auth_group

2014-04-23 Thread Flavio Santos
Olá friends. I am starting to give my first steps with web2py. 
Pra to start: in the local bank using sqlite the problem below does not 
occur. (in localhost functions everything) 

My problem: when initiating the bank would like already inserting some 
groups predefined in the table auth_group and in the server I receive the 
error:

class '_mysql_exceptions.OperationalError' (1701, 'Cannot truncate a 
table referenced in a foreign key constraint 
(`meusistema`.`auth_permission`, CONSTRAINT `auth_permission_ibfk_1` 
FOREIGN KEY (`group_id`) REFERENCES `meusistema`.`auth_group` (`id`))')

- I incapacitated the automatic creation of groups: 
auth.settings.create_user_groups = None 
- All new I register in cadastre will be of group 1: 
auth.settings.everybody_group_id = 1

In model db.py I placed soon below of the configurations of tables: 
if not db(db.auth_group).count():
db.auth_group.truncate()
db.auth_group.insert(role='Usuário Comum', description='Usuário Comum')
db.auth_group.insert(role='Nível 2', description='Nível 2')
db.auth_group.insert(role='Nível 3', description='Nível 3')
db.auth_group.insert(role='Nível 4', description='Nível 4')
db.auth_group.insert(role='Nível 5', description='Nível 5')
db.auth_group.insert(role='Admin Gerente', description='Gerente')
db.auth_group.insert(role='Admin Master', description='Administrador 
Master do Sistema')

If I take this part of the insertion system on the server works right.

Thanks for the help,
Flávio Santos


-- 
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: i am trying send email using web2py with gmail and using smtp setting i have attached all code

2014-04-23 Thread Jessica Le

I've been getting the following error: 

***WARNING:web2py:Mail.send failure:[Errno 11004] getaddrinfo failed***

for the following code: 

mail = Mail()
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'em...@gmail.com'
mail.settings.login = 'em...@gmail.com:password'

mail.send(to=[email],subject= 'TEST',message='helloWorld')

Can someone please assist me? I can't seem to find any documentation on 
what getaddrinfo is and where in the code the error is happening. 

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] Form Master detail

2014-04-23 Thread Fabiano Almeida
Hi,

I'm trying to do a master detail form. It is possible that the details form
is grid style? How?

Thanks,

Fabiano.

-- 
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: Issue 1865 code sample as requested

2014-04-23 Thread Massimo Di Pierro
We can have a discussion here is you like. I think the most appropriate 
place is web2py developers.

cache.disk currently locks the entire disk cache, not a single key.

Massimo

On Wednesday, 23 April 2014 09:35:24 UTC-5, Remco Boerma wrote:

 Massimo, 

 Thanks for responding in the comment. I've responded to yours but don't 
 know if you'd prefer bringing that over to the mailing list or not. 
 What's the rule of thumb for that - when to file a bug and keep on posting 
 there and when to write to the mailinglist?

 Regards, 
 Remco 

 Op dinsdag 15 april 2014 14:48:43 UTC+2 schreef Remco Boerma:

 Hi, 

 I've finally had the time to play a little with the code sample that was 
 requested on issue 1865. It's in the comment there. 

 https://code.google.com/p/web2py/issues/detail?id=1865

 -- 
 Cheers / Met vr. gr. 
 Remco Boerma 



-- 
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 hide buttons from form

2014-04-23 Thread Massimo Di Pierro
You only have the buttons because you did not create a view for the action.

On Wednesday, 23 April 2014 14:22:20 UTC-5, Fabiano Almeida wrote:

 Hi,

 How to hide buttons  from form? 

 designrequestresponsesessiondb tablesdb stats

 Thanks,

 Fabiano


-- 
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: REF: Bare Ajax Login

2014-04-23 Thread Teddy Nyambe
Web2py has excellent backend processing. I think the way Massimo made
web2py to work supports less pure Ajax calls. I would recommend and request
that core functions are made to support pure Ajax say a one page website,
cause users now want to experience web apps as if they are desktop apps. On
the  other hand I have also been developing an app with dhtmlx framework
client based and using web2py calls. Works well but don't use inbuilt cool
features of web2py to process foreinstance forms. It would be cool to see
how a Ajax call can be handled by say form.procesd().

Teddy
On 24 Apr 2014 00:22, select falko.kra...@gmail.com wrote:

 I just wanted to mention that a similar problem exist for
 request_reset_password,
 the call works, passoword is restet the email is send but there is just a
 blank return and I have no idea how to react on that on the client side
 without rewriting the web2py_ajax... routines

 On Thursday, April 24, 2014 12:05:10 AM UTC+2, select wrote:

 Was fighting with the problem in 2011 and still do, how to log in with
 ajax?
 The problem is that I have a one pager app with client site js code that
 needs to register if the user is logged in
 when I login with e.g.
 index.html:
 div id=i-login-form/div


 js code:
 web2py_component(localconfig.baseurl + '/default/user.load/login',
 'i-login-form')

 default.py unchanged from welcome app

 user.load
 {{=form}}

 I have not found a way to register in the js code if the login was a
 success or fail

 I modified web2py_component so that it has a callback that is executed
 every time the ajax call in web2py_ajax_page (via web2py_component) is
 completed

 web2py_component(localconfig.baseurl + '/default/user.load/login',
 'i-login-form', undefined, undefined, function() {
 // do some other ajax call if the login was a success
 });


 But this is far from ideal. The callback code must check if this is the
 first call and if the login was a success. Also if the login failed (e.g.
 an email was provided but no password) no form is returned :(

 Do I really have to write my own server side login methods to make this
 work? Any news on this?


 On Friday, May 24, 2013 6:14:06 AM UTC+2, software.ted wrote:

 In addition, auth.login_bare() seems to check only with auth_user table,
 if my authentication is based on LDAP it may not work. Any progress that
 has been made  on auth.ajax_login()?
 On 24 May 2013 05:58, Teddy Nyambe softwa...@gmail.com wrote:

 Why I asked cause a 2 months or so Massimo contributed to a similar
 thread and this is what he wrote:

 Should we offer something like {{=auth.ajax_login()}} helper which
 submits to /user/login? If would not be difficult to write.
 How should it work?

 The guy who hd asked a question on pure Ajax login had used
 auth.login_bare() and from my assessment he seemed to hv challenges with 
 it.
 On 24 May 2013 05:46, Teddy Nyambe softwa...@gmail.com wrote:

 Of course read the book, auth.login_bare() manages my sessions
 automatically? Will check it out thanx
 On 23 May 2013 20:09, Anthony abas...@gmail.com wrote:

 Basic authentication won't do anything with the session -- it
 requires sending the credentials on every request -- probably not what's
 desired here. Instead, the very next section in the book may help:
 http://www.web2py.com/book/default/chapter/09#Manual-Authentication.
 You can post the login credentials via Ajax and then use 
 auth.login_bare()
 to handle the login.

 Anthony

 On Thursday, May 23, 2013 1:39:13 PM UTC-4, Derek wrote:

 You did read the book before you asked, yes?

 http://www.web2py.com/book/default/chapter/09#Access-Control
 -and-Basic-Authentication

 On Thursday, May 23, 2013 9:49:21 AM UTC-7, software.ted wrote:

 Is there a way of using a pure Ajax request to web2py
 authentication and create a session for a successfully logged in user?

 --
 
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools
 he is all - Thomas Carlyle 1795-1881

 /~

  --

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