[web2py] Re: Support for MS Access?

2014-11-19 Thread ksotiris
Finally,

everything is working correctly.

-- 
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] Query difference in SQLFORM.GRID

2014-11-19 Thread Prasad Muley
Hi All,
 
 I want to support multiple keywords search as well as web2py's 
built-in-search.

 I've written one module which will check if in_built_search is called 
or not.

* If in_built_search isn't called then search keywords in custom_module*

*def built_in_search(keywords):*
*This module will return True if opertor*
*   in built_in_search is used in keywords*
*search_operators = ['=', '!=', '', '', '=', '=',*
*'starts with', 'contains', 'in', 'not in']*
*return any(operator in keywords for operator in search_operators)*



 Code of SQLFORM.GRID in *controllers/default.py*


 keywords = request.vars.keywords

 if keywords and not built_in_search(keywords):

new_query, usr_company_exist = _custom_search_query(keywords, 
field_dicts)

   #field_dicts contains field_name and table attribute.



 grid = SQLFORM.grid(query, create=allow_create,
orderby=~db.table_name.created_on,
showbuttontext=False, csv=False, 
deletable=False,
maxtextlengths=textlengths, 
searchable=True)


Here  I am building query according to *request.vars.keywords*

I've written a custom module to search keywords on *selected attributes* as 
:
It also searches on reference key (company_name) 



*def _custom_search_query(keywords, field_dicts):*
*This module will build search each keyword in keywords*
*   in predefined table attributes*

*keys = keywords.strip()*
*user_company_exist = False*
*import time*
*start_time = time.time()*
*filters = []*
*print \n Keywords, keys*
*words = keys.split(' ')*

*for field_name, db_table_attr in field_dicts.iteritems():*

*#check for company name*
*if field_name == 'company_name':*
*company = db(db.company.name.contains(keys)).select().first()*
*if company is not None:*
*filters.append(db_table_attr == company.id)*
*continue*
*all_words_filter = []*

*for word in words:*
*all_words_filter.append(db_table_attr.contains(word))*
*filters.append(reduce(lambda a, b: (a  b), all_words_filter))*

*return reduce(lambda a, b: a | b, filters)*



If I tried to search '*XYZ'* (First_name_of_company) in search box, then *it 
gives me* *incorrect records.*
Actually It shows only 3 records.

*I've printed count of query in pdb.*


*(Pdb) db(query).count()139L*
*It is showing exact count as in database.*


If I tried to search '*XYZ Private' *(first and middle name of company) in 
search box, then *It gives me correct records.*

*I've also printed query count in pdb.(Pdb) db(query).count()139L*
It also shows exact count as in database.

Does any one know why is it giving different results?


-- 
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: Migrating only a single auth table ?

2014-11-19 Thread Leonel Câmara
If it fails because it already exists you need to do a fake migration on 
auth_user, I would undo the changes to auth_group and then do a migration 
using fake_migrate as needed for already exists errors. Then you can define 
your auth.settings.extra_fields['auth_group'], put your extra columns 
there, and do a regular migration.


-- 
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: Support for MS Access?

2014-11-19 Thread Leonel Câmara
Good job ksotiris, maybe you could contribute this adapter and document its 
dependencies so the other poor souls having to deal with MSACCESS have a 
way 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] Re: read an excel file stored in session using xlrd

2014-11-19 Thread Anthony
It sounds like you do need the file to persist across multiple requests, so 
the simplest approach might be to create a database table with an upload 
field to store the file. As soon as you're done with the file, then just 
delete the record in the database (the file will be deleted automatically 
as long as you set autodelete=True).

Anthony

On Wednesday, November 19, 2014 12:22:51 AM UTC-5, T.R.Rajkumar wrote:

 @Anthony Thanks for your kind reply. I don't need to save the file. That's 
 why w/o db, session becomes handy. I upload the file in master data page 
 having two forms. One form is the SQLFORM.factory for uploading the excel 
 file and the other form is to enter the key parameters. When the second 
 form is submitted this page redirects to another details page where I would 
 like to read the excel file uploaded in the first page and populate the 
 html table in the details page. Yes I would like to discard the excel file 
 upon reading it. Seeking your valuable guidance.

 On Tuesday, November 18, 2014 12:06:31 PM UTC+5:30, T.R.Rajkumar wrote:

 form_upload = SQLFORM.factory(Field('your_excel_file', 'upload',
 uploadfolder='helloworld/uploads'))
 if form_upload.process().accepted:
 session.your_excel_file = form.vars.your_excel_file

 def import_from_excel():
 workbook = xlrd.open_workbook(session.your_excel_file)


 When import_from_excel() is called gives rise to the below error.
 How to access excel file stored in session? 

 File F:/trr/web2py/web2py/applications/helloworld/controllers/cms_meas.py 
 http://127.0.0.1:8000/admin/default/edit/helloworld/controllers/cms_meas.py,
  line 255, in import_from_excel
 workbook = xlrd.open_workbook(session.your_excel_file)
   File D:\Python\lib\site-packages\xlrd\__init__.py, line 366, in 
 open_workbook
 formatting_info=formatting_info,
   File D:\Python\lib\site-packages\xlrd\__init__.py, line 725, in __init__
 f = open(filename, open_mode)
 TypeError: coercing to Unicode: need string or buffer, NoneType found






-- 
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: Query difference in SQLFORM.GRID

2014-11-19 Thread Anthony
Is this the exact code? I notice that the output of the call to 
_custom_search_query gets assigned to the tuple (new_query, 
user_company_exist), but (a) that function does not return a tuple, and (b) 
you don't use new_query when calling the grid.

Anthony

On Wednesday, November 19, 2014 6:16:19 AM UTC-5, Prasad Muley wrote:

 Hi All,
  
  I want to support multiple keywords search as well as web2py's 
 built-in-search.

  I've written one module which will check if in_built_search is called 
 or not.

 * If in_built_search isn't called then search keywords in 
 custom_module*

 *def built_in_search(keywords):*
 *This module will return True if opertor*
 *   in built_in_search is used in keywords*
 *search_operators = ['=', '!=', '', '', '=', '=',*
 *'starts with', 'contains', 'in', 'not in']*
 *return any(operator in keywords for operator in search_operators)*



  Code of SQLFORM.GRID in *controllers/default.py*


  keywords = request.vars.keywords

  if keywords and not built_in_search(keywords):

 new_query, usr_company_exist = _custom_search_query(keywords, 
 field_dicts)

#field_dicts contains field_name and table attribute.



  grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.table_name.created_on,
 showbuttontext=False, csv=False, 
 deletable=False,
 maxtextlengths=textlengths, 
 searchable=True)


 Here  I am building query according to *request.vars.keywords*

 I've written a custom module to search keywords on *selected attributes* 
 as :
 It also searches on reference key (company_name) 



 *def _custom_search_query(keywords, field_dicts):*
 *This module will build search each keyword in keywords*
 *   in predefined table attributes*

 *keys = keywords.strip()*
 *user_company_exist = False*
 *import time*
 *start_time = time.time()*
 *filters = []*
 *print \n Keywords, keys*
 *words = keys.split(' ')*

 *for field_name, db_table_attr in field_dicts.iteritems():*

 *#check for company name*
 *if field_name == 'company_name':*
 *company = db(db.company.name.contains(keys)).select().first()*
 *if company is not None:*
 *filters.append(db_table_attr == company.id 
 http://company.id)*
 *continue*
 *all_words_filter = []*

 *for word in words:*
 *all_words_filter.append(db_table_attr.contains(word))*
 *filters.append(reduce(lambda a, b: (a  b), all_words_filter))*

 *return reduce(lambda a, b: a | b, filters)*



 If I tried to search '*XYZ'* (First_name_of_company) in search box, then *it 
 gives me* *incorrect records.*
 Actually It shows only 3 records.

 *I've printed count of query in pdb.*


 *(Pdb) db(query).count()139L*
 *It is showing exact count as in database.*


 If I tried to search '*XYZ Private' *(first and middle name of company) 
 in search box, then *It gives me correct records.*

 *I've also printed query count in pdb.(Pdb) db(query).count()139L*
 It also shows exact count as in database.

 Does any one know why is it giving different results?




-- 
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: second page to be accessed only from first page

2014-11-19 Thread Anthony
request.function is always going to be the name of the function that has 
been requested -- that's what it is for.

On each request, why don't you just do something like this in a model:

session.last_page = session.this_page or None
session.this_page = (request.controller, request.function)

def require_last_page(controller, function):
if not (session.last_page == (controller, function) or
session.last_page == session.this_page):
redirect(URL(controller, function))

Then, in any action that requires a specific previous page, just include 
code like this:

def second():
require_last_page('default', 'first')
...

If you want to get fancy, you can make require_last_page a decorator.

Note, the session.last_page == session.this_page condition is there to 
allow users to reload a page without having to go back to the required last 
page -- remove that condition if you don't want to allow page reloads.

Anthony

On Wednesday, November 19, 2014 12:02:04 AM UTC-5, T.R.Rajkumar wrote:

 @Anthony Yes the session var is OK. But I would like to see that the 
 second page can be visited only after the first page. Keeping the session 
 var flags can be troublesome if we have hundreds of pages and the same 
 session var gets set in some other page. Is their a way out? The 
 request.function seems to be perfect if it stores the first page even 
 inside the second action.

 On Saturday, November 15, 2014 3:28:15 PM UTC+5:30, T.R.Rajkumar wrote:

 In book chapter 3 overview the following is given to restrict access to 
 second page. 

 if not request.function=='first' and not session.visitor_name:
 redirect(URL('first'))

 But if I print request.function it says 'second'.
 How to restrict access to second page only from first page?




-- 
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: All request forwarded to https - How to stop this

2014-11-19 Thread Anthony
Do you have request.requires_https() in your code? If not, provide more 
details about your setup (hosting provider, exact setup script used).

Anthony

On Wednesday, November 19, 2014 2:49:44 AM UTC-5, sabbir wrote:

 OS - Ubantu 12.4
 Deployed using deployment script on the book

 While browsing apps all the request are forwarding to *https :( *
 How can i stop this. 

 ideally users who browse with http should be able to browse as it is. 

 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: Migrating only a single auth table ?

2014-11-19 Thread Chris Baron
Then you can define your auth.settings.extra_fields['auth_group'], put 
your extra columns there, and do a regular migration. -- This is the first 
thing I tried to do.  Won't that fail because auth_user already exists?  I 
only want to migrate a single table -- auth_group.

On Wednesday, November 19, 2014 6:21:55 AM UTC-6, Leonel Câmara wrote:

 If it fails because it already exists you need to do a fake migration on 
 auth_user, I would undo the changes to auth_group and then do a migration 
 using fake_migrate as needed for already exists errors. Then you can define 
 your auth.settings.extra_fields['auth_group'], put your extra columns 
 there, and do a regular migration.




-- 
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: Migrating only a single auth table ?

2014-11-19 Thread Leonel Câmara
No it won't fail, it won't try to recreate auth_user unless you deleted 
your .table files, in which case you need to do a fake migration first.

-- 
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] DB Driver Question

2014-11-19 Thread 'Michael Gheith' via web2py-users
I have an application that is using a remote PostgreSQL database with the 
DAL.  It's using the pg8000 driver which is in gluoncontrib.  Now I 
recently installed a psycopg2 driver because I don't want to use pg8000 
anymore.  Is there a convenient way to find out what DB driver my 
application is using?

-- 
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: DB Driver Question

2014-11-19 Thread 'Michael Gheith' via web2py-users
Is there is a way to specify which driver to use in the DAL connections 
string?
DAL('postgres://pw:user@host:port/dbname')

-- 
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: Query difference in SQLFORM.GRID

2014-11-19 Thread Prasad Muley
Hi Anthony,

 Sorry for pasting insufficient code.

Following is code from controllers/xyz.py

def built_in_search(keywords):
This module will return True if opertor
   in built_in_search is used in keywords
search_operators = ['=', '!=', '', '', '=', '=',
'starts with', 'contains', 'in', 'not in']
return any(operator in keywords for operator in search_operators)


def _custom_search_query(user_company_locs, keywords, field_dicts):
This module will build search each keyword in keywords
   in predefined table attributes
keys = keywords.strip()
user_company_exist = False
import time
start_time = time.time()
filters = []
print \n Keywords, keys
words = keys.split(' ')
for field_name, db_table_attr in field_dicts.iteritems():
#check for company name
if field_name == 'company_name':
company = db(db.company.name.contains(keys)).select().first()
if company is not None and company.id in user_company_locs:
filters.append(db_table_attr == company.id)
user_company_exist = True
continue
all_words_filter = []
for word in words:
all_words_filter.append(db_table_attr.contains(word))
filters.append(reduce(lambda a, b: (a  b), all_words_filter))
print Time required custom build query, time.time() - start_time
return reduce(lambda a, b: a | b, filters), user_company_exist


def controller_name():

  #following variable contains a list of all company ids
  user_company_locs = get_user_company_ids()

 query = (db.company.id.belongs(user_company_locs))

status_query = valid_status_query #can't disclose it.

#following dict it contains
# { id:db.company.id,
# name: db.company.name }

field_dicts = { 'valid_table_attr_name' : valid_table_attr,
.
.
   }

   keywords = request.vars.keywords

   if keywords and not built_in_search(keywords):
new_query, usr_company_exist = _custom_search_query(
user_company_locs, keywords, field_dicts)

#entered company_name exist in user_company_locs list then
#display only single record only single.
if usr_company_exist:
query  = new_query  status_query
else:
query = status_query  new_query


 grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.valid_table_name.created_on,
 showbuttontext=False, csv=False, deletable=False,
 maxtextlengths=textlengths, searchable=True)



I've printed query object in pdb.

IF I search XYZ keyword then it shows correct count in pdb -
db(query).count()

*But grid shows only 3 records*

IF I search XYZ Private or XYZ P or any valid word after XYZ
*then it also shows correct count in pdb as well as on grid*.

Why is grid showing different records (count)?
It is showing same record (count) on DAL or PDB.


On Wed, Nov 19, 2014 at 7:47 PM, Anthony abasta...@gmail.com wrote:

 Is this the exact code? I notice that the output of the call to
 _custom_search_query gets assigned to the tuple (new_query,
 user_company_exist), but (a) that function does not return a tuple, and (b)
 you don't use new_query when calling the grid.

 Anthony


 On Wednesday, November 19, 2014 6:16:19 AM UTC-5, Prasad Muley wrote:

 Hi All,

  I want to support multiple keywords search as well as web2py's
 built-in-search.

  I've written one module which will check if in_built_search is
 called or not.

 * If in_built_search isn't called then search keywords in
 custom_module*

 *def built_in_search(keywords):*
 *This module will return True if opertor*
 *   in built_in_search is used in keywords*
 *search_operators = ['=', '!=', '', '', '=', '=',*
 *'starts with', 'contains', 'in', 'not in']*
 *return any(operator in keywords for operator in search_operators)*



  Code of SQLFORM.GRID in *controllers/default.py*


  keywords = request.vars.keywords

  if keywords and not built_in_search(keywords):

 new_query, usr_company_exist = _custom_search_query(keywords,
 field_dicts)

#field_dicts contains field_name and table attribute.



  grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.table_name.created_on,
 showbuttontext=False, csv=False,
 deletable=False,
 maxtextlengths=textlengths,
 searchable=True)


 Here  I am building query according to *request.vars.keywords*

 I've written a custom module to search keywords on *selected attributes*
 as :
 It also searches on reference key (company_name)



 *def _custom_search_query(keywords, field_dicts):*
 *This module will build search each keyword in keywords*
 *   in predefined table 

[web2py] Re: DB Driver Question

2014-11-19 Thread Leonel Câmara
The postgresql adapter will automatically use psycopg2 if it's available, 
so if when you start web2py you see in the console PostgreSQL(psycopg2) in 
the list of available drivers that what it's using.

-- 
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: SQLFORM.grid edit only selects the first record and updates all records.

2014-11-19 Thread Stephen McCamy

   
   - The update_record function is not available for Rows of keyed tables.

That is why i believe.  

On Tuesday, November 18, 2014 11:02:05 PM UTC-5, Stephen McCamy wrote:

 Hello,

 I am having an issue with SQLFORM.grid where when there are more than one 
 records returned the edit button only shows data for the first record.  If 
 I do update it then updates all the records with the new values.  I can't 
 seem to figure out why.

 Here is my db definition:

 db.define_table('Correlation',Field('IncidentID','id',label='Event 
 ID'),Field('Type',represent=lambda r, row: 
 db.CorrelationType[r].CorrelationType),Field('Value'),Field('Context',represent=lambda
  
 r, row:A('View',_href=(r),_target='new') if row.Type==4 else r))

 db.define_table('CorrelationType',Field('P_Id','id'),Field('CorrelationType'))

 Here is the SQLFORM.grid:

 corq=db.Correlation.id==(request.args(0))
 
 cor=SQLFORM.grid(query=corq,fields=[db.Correlation.Type,db.Correlation.Value,db.Correlation.Context],links=urllinks,searchable=True,maxtextlength=100,details=True,
  
 editable=True,deletable=False,user_signature=False,create=True,links_in_grid=True,args=[request.args[0]],csv=True,exportclasses=dict(
 csv_with_hidden_cols=False,
 xml=False,
 html=False,
 json=False,
 tsv_with_hidden_cols=False,
 tsv=False))


-- 
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: Query difference in SQLFORM.GRID

2014-11-19 Thread Anthony
Hard to say what's going on. I would suggest looking at db._timings (which 
is available in response.toolbar()) after running each version of that 
query on the grid. db._timings will show the exact SQL that was executed to 
get the count and then to return the actual records. Perhaps that will 
provide a clue.

Anthony

On Wednesday, November 19, 2014 11:43:45 AM UTC-5, Prasad Muley wrote:

 Hi Anthony,

  Sorry for pasting insufficient code.

 Following is code from controllers/xyz.py

 def built_in_search(keywords):
 This module will return True if opertor
in built_in_search is used in keywords
 search_operators = ['=', '!=', '', '', '=', '=',
 'starts with', 'contains', 'in', 'not in']
 return any(operator in keywords for operator in search_operators)


 def _custom_search_query(user_company_locs, keywords, field_dicts):
 This module will build search each keyword in keywords
in predefined table attributes
 keys = keywords.strip()
 user_company_exist = False
 import time
 start_time = time.time()
 filters = []
 print \n Keywords, keys
 words = keys.split(' ')
 for field_name, db_table_attr in field_dicts.iteritems():
 #check for company name
 if field_name == 'company_name':
 company = db(db.company.name.contains(keys)).select().first()
 if company is not None and company.id in user_company_locs:
 filters.append(db_table_attr == company.id)
 user_company_exist = True
 continue
 all_words_filter = []
 for word in words:
 all_words_filter.append(db_table_attr.contains(word))
 filters.append(reduce(lambda a, b: (a  b), all_words_filter))
 print Time required custom build query, time.time() - start_time
 return reduce(lambda a, b: a | b, filters), user_company_exist


 def controller_name():

   #following variable contains a list of all company ids
   user_company_locs = get_user_company_ids()

  query = (db.company.id.belongs(user_company_locs))
   
 status_query = valid_status_query #can't disclose it.

 #following dict it contains
 # { id:db.company.id,
 # name: db.company.name }
  
 field_dicts = { 'valid_table_attr_name' : valid_table_attr,
 .
 .
}

keywords = request.vars.keywords

if keywords and not built_in_search(keywords):
 new_query, usr_company_exist = _custom_search_query(
 user_company_locs, keywords, field_dicts)

 #entered company_name exist in user_company_locs list then
 #display only single record only single.
 if usr_company_exist:
 query  = new_query  status_query
 else:
 query = status_query  new_query

   
  grid = SQLFORM.grid(query, create=allow_create,
  orderby=~db.valid_table_name.created_on,
  showbuttontext=False, csv=False, deletable=False,
  maxtextlengths=textlengths, searchable=True)



 I've printed query object in pdb. 

 IF I search XYZ keyword then it shows correct count in pdb - 
 db(query).count()

 *But grid shows only 3 records* 

 IF I search XYZ Private or XYZ P or any valid word after XYZ  
 *then it also shows correct count in pdb as well as on grid*.

 Why is grid showing different records (count)? 
 It is showing same record (count) on DAL or PDB.


 On Wed, Nov 19, 2014 at 7:47 PM, Anthony abasta...@gmail.com wrote:

 Is this the exact code? I notice that the output of the call to 
 _custom_search_query gets assigned to the tuple (new_query, 
 user_company_exist), but (a) that function does not return a tuple, and (b) 
 you don't use new_query when calling the grid.

 Anthony


 On Wednesday, November 19, 2014 6:16:19 AM UTC-5, Prasad Muley wrote:

 Hi All,
  
  I want to support multiple keywords search as well as web2py's 
 built-in-search.

  I've written one module which will check if in_built_search is 
 called or not.

 * If in_built_search isn't called then search keywords in 
 custom_module*

 *def built_in_search(keywords):*
 *This module will return True if opertor*
 *   in built_in_search is used in keywords*
 *search_operators = ['=', '!=', '', '', '=', '=',*
 *'starts with', 'contains', 'in', 'not in']*
 *return any(operator in keywords for operator in search_operators)*



  Code of SQLFORM.GRID in *controllers/default.py*


  keywords = request.vars.keywords

  if keywords and not built_in_search(keywords):

 new_query, usr_company_exist = _custom_search_query(keywords, 
 field_dicts)

#field_dicts contains field_name and table attribute.



  grid = SQLFORM.grid(query, create=allow_create,
 orderby=~db.table_name.created_on,
   

[web2py] automate one to many on three tables

2014-11-19 Thread Rodrigo

Hi all!
Well, i need to migrate this pygtk program to web interface, basicaly there is 
a table person and that
handles basic data about a person and another three:
one for adresses, one for phone numbers and another 
for web adresses and a relationship one to many from
person to each one of them(i think i could not explain
very well, so i attached the pygtk program, it needs nothing more tham python 
and gtk to run).
Well, my doubt is: there is a easy way to create the
forms for this program? I'm not very happy writting javascript but i can handle 
that, i'd only preffer to
do the most i can on python.

-- 
Rodrigo rcesar...@gmail.com

-- 
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.
#
#-*-coding:utf-8-*-
#
from gtk import *
from sqlite3.dbapi2 import connect
import time

class AgendaTelefonica(Frame):
def __init__(self,parent):
self.db=parent.db
self.top=parent
Frame.__init__(self)
fr1= Frame()
bbox = VBox(False,0);fr1.add(bbox)
self.lista=TreeView()
frb = Frame(Localizar cliente:)
frb.set_shadow_type(SHADOW_NONE)
self.pad = Entry()
bt1= ToolButton(gtk-find);bt1.connect(clicked,self.busca)
tbx = HBox(False,0)
tbx.pack_start(self.pad,True,True)
tbx.pack_end(bt1,False,False)
frb.add(tbx)
bbox.pack_start(frb,False,True)
scw = ScrolledWindow()
scw.set_policy(POLICY_AUTOMATIC,POLICY_AUTOMATIC)
scw.add(self.lista)
bbox.pack_start(scw,True,True)
tb = Toolbar()
bt1 = ToolButton(gtk-save)
bt2 = ToolButton(gtk-new)
bt3 = ToolButton(gtk-delete)
bt1.connect(clicked,self.salvar_cliente)
bt2.connect(clicked,lambda evt:self.novo_cliente())
bt3.connect(clicked,lambda evt:self.apagar_cliente())
tb.add(bt1)
tb.add(bt2)
tb.add(SeparatorToolItem())
tb.add(bt3)
bbox.pack_end(tb,False,True)
for c in [TreeViewColumn(Código,CellRendererText(),text=0),TreeViewColumn(Nome+20* ,CellRendererText(),text=1)]:self.lista.append_column(c)
self.lista.set_model(ListStore(str,str))
self.lista.connect(row-activated,self.abre_cliente)
#
fr2 = Frame()
self.codigo=Entry()
self.nome=Entry()
plc = Table(3,3,0)
plc.attach(self.put_in_frame(self.codigo,Código:),0,1,0,1,FILL,SHRINK)
plc.attach(self.put_in_frame(self.nome,Nome:),1,4,0,1,EXPAND|FILL,SHRINK)
dsk = Notebook()
dsk.append_page(self.fr_enderecos(),Label(Endereços:))
dsk.append_page(self.fr_telefones(),Label(Telefones:))
dsk.append_page(self.fr_internet(),Label(Internet:))
plc.attach(dsk,0,4,1,2,EXPAND|FILL)
fr2.add(plc)
#
hb = HBox(False,0)
fr1.set_shadow_type(SHADOW_NONE)
fr2.set_shadow_type(SHADOW_NONE)
hb.pack_start(fr1,False,True)
hb.pack_start(fr2,True,True)
self.add(hb)
self.codigo.set_property(editable,False)
self.codigo.set_size_request(12,-1)

def fr_enderecos(self):
self.enderecos = TreeView()
self.enderecos.connect(row-activated,self.abre_endereco)
for c in [TreeViewColumn(Desc.:,CellRendererText(),text=0),
  TreeViewColumn(Valor:,CellRendererText(),text=1)]:self.enderecos.append_column(c)
self.enderecos.set_headers_visible(False)
tb = Toolbar()
vb = VBox(False,0)
bts = [ ToolButton(gtk-new),ToolButton(gtk-delete)]
bts[0].connect(clicked,self.novo_endereco)
bts[1].connect(clicked,self.apaga_endereco)
for bt in bts:tb.add(bt)
scw = ScrolledWindow()
scw.set_policy(POLICY_AUTOMATIC,POLICY_AUTOMATIC)
scw.add(self.enderecos)
vb.pack_start(scw,True,True)
vb.pack_end(tb,False,True)
fr = Frame()
fr.set_shadow_type(SHADOW_NONE)
fr.add(vb)
return(fr)

def fr_telefones(self):
self.telefones = TreeView()
self.telefones.connect(row-activated,self.abre_telefone)
for c in [TreeViewColumn(Desc.:,CellRendererText(),text=0),
  TreeViewColumn(Valor:,CellRendererText(),text=1)]:self.telefones.append_column(c)
self.telefones.set_headers_visible(False)
tb = Toolbar()
vb = VBox(False,0)
bts = [ ToolButton(gtk-new),ToolButton(gtk-delete)]
bts[0].connect(clicked,self.add_telefone)
bts[1].connect(clicked,self.apaga_telefone)
for bt in bts:tb.add(bt)
 

[web2py] IntegrityError: foreign key constraint failed

2014-11-19 Thread Богдан Ефименко
Hello
I do not know much English
I have two tables:

db.define_table('category', Field('name'))

db.define_table('books',
Field('title', requires=IS_NOT_EMPTY('Введите название 
книги'), label='Название*'),
Field('author', requires=IS_NOT_EMPTY('Введите автора'), 
label='Автор*'),
Field('god', 'integer', label='Год выпуска'),
Field('number_of_pages', 'integer', label='Количество 
страниц'),
Field('languages', label='Язык книги*'),
Field('category', 'reference category', label='Категория*'),
Field('description', 'text', label='Описание'),
Field('oblozhka', 'upload', label='Обложка'),
Field('book', 'upload', label='Файл книги*', 
requires=IS_NOT_EMPTY('Загрузите файл книги'))
)
But when i add a record to a table, I get an error:
IntegrityError: foreign key constraint failed
How to fix 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] Unable to pass vars using select form

2014-11-19 Thread Anatoli Hristov
Hello,

I was trying to use this kind of form, but I cannot pass the variables to 
the page!

Any hints?

Thanks


form action=? method=POST
select name=myselect id=myselect onchange=this.form.submit()
{{for item in screen_model:}}
option name=screen 
value={{vars=item.id}}{{=item.model}}/option{{pass}}
/select
/form

-- 
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] Why all traffic forwarded to https and how to stop this ?

2014-11-19 Thread joe black :)

Hi,

Just deployed a new web2py using deployment script on Ubuntu.* Problem is 
all the traffic is forwarded to https. giving certificate error to users.* 
It was not like this before. How to stop this automatic forward to https?

Also where is the routes.py . Is it depreciated ? Then how to achieve 
domain to app mapping ?

Thanks,
sabbir

-- 
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] Validating user input: No SPACES in textbox

2014-11-19 Thread Ruchir Sharma
Hello,
I need validated input from user in a particular field. The input entered 
by user must not contain any SPACES. I can do this in javascript by using 
onkeypress function but how to do this using SQLFORM.

My code in default.py is as under:
 form=SQLFORM(db.complain,fields=['Description','Topic','Email','CurrentTime'])
if form.process().accepted:
response.flash='Complain Registered. ID is: '+ str(form.vars.id)

Database is:
db.define_table('complain',
Field('Description',length=200, required=True,requires=IS_NOT_EMPTY()),
Field('Topic',length=10, required=True,requires=IS_NOT_EMPTY()),
Field('Email', required=True,requires=IS_EMAIL()),
Field('Status',length=10, writable=False,default='In-Process'),
Field('CurrentTime','datetime',default=request.now,writable=False))

-- 
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] git integration application

2014-11-19 Thread Ian Bell
So here's the basic problem.  I have pushed our web2py application 
to https://github.com/CoolProp/Coolprop-Online , and I would like to add 
this application to my web2py instance running on pythonanywhere.com (props 
to them btw, PA is a great solution for getting going with web2py).

I tried to add the app with the URL to the github repo in the box labeled Or 
Get from URL (can be a git repo) by putting  in 
https://github.com/CoolProp/Coolprop-Online and then I got an error that it 
couldn't add this app.  And nothing else in terms of error message. Quite a 
useless error message.

So then I tried the same thing with one of the apps 
from https://github.com/mdipierro/web2py-appliances .  I still can't get it 
to import one of these appliances.  How is that supposed to work?  I don't 
want to point to the .w2p file since that has to be manually exported from 
the admin interface, unless I am understanding something fundamentally 
incorrectly.  The w2p files are not updated (unless manually) if other 
changes are made in the appliance.

The docs are pretty sparse on how this is supposed 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] Keep selection when editing

2014-11-19 Thread Eduard Abramovich
Hi there!

I have developed an SQLFORM.grid from a table. This tables contains the 
users activities, it looks like this:

Task name: Developing with web2py
Description: blah blah blah
Initial Date: 2014-10-10
Due Date: 2012-12-12
Assigned to: User1 | User2 ... (there are various users)

In the Assigned to I have an SQLFORM.widgets.checkboxes.widget with the 
multiple=True parameter. So the problem comes when editing the form, if I 
had selected the User1 and User3 for a task then, when I'm editing the form 
it shows me again the checkboxes empty so I need to select again the User1 
and User3 to keep these values. Sometimes I forget what were the assigned 
users in a task.

Is there any way (in web2py) to show this values selected when editing and 
not selecting them again? or I need something like JS or jQuery?. 

-- 
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: crash - session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL) on 2.9.11

2014-11-19 Thread Edwin van de Ven


Op maandag 13 oktober 2014 19:22:57 UTC+2 schreef Dmitry Ermolaev:

 I del al files in /sessions and update to 2.9.11

 Traceback (most recent call last):
   File C:\web2py-m\gluon\main.py, line 435, in wsgibase
 session.connect(request, response)
   File C:\web2py-m\gluon\globals.py, line 931, in connect
 session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
 TypeError: 'NoneType' object is not callable


I'm getting the exact same error after upgrading to 2.9.11. My sessions 
directory is also empty. Does anyone else experience similar behavior? 

-- 
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: pagination issue redirecting to the current page

2014-11-19 Thread Joe
Thanks Cliff, I've been trying to do that but I didn't succeed. I would 
appreciate if you could send an example on how to put the current page info 
in the request.args dictionary.

On Tuesday, November 18, 2014 12:37:09 PM UTC+8, Cliff Kachinske wrote:

 Put information about the current page in the request.args dictionary. You 
 could use the session, but if your user opens a second browser window it 
 becomes difficult to keep track of which session data corresponds to which 
 browser tab.




-- 
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: is_list_of validator question

2014-11-19 Thread Massimo Di Pierro
I do not remember but please open a ticket and I will look at this asap.

On Tuesday, 18 November 2014 02:02:53 UTC-6, Manuele wrote:

  Il 18/11/14 05:54, Massimo Di Pierro ha scritto:
  
 Problem is that IS_LIST_OF experts to validate a list. Instead you are 
 passing  (not a list) and None (also not a list). 
 I agree that it is odd that interprets '' as [] and None as [None].
 They should either be interpreted as [''] and [None] or both as an empty 
 list.

  Your proposed fix makes sense and I would take a patch.

 Thank you Massimo!

 the problem is that every time you don't insert any value in the field a 
 null string is validated (i.e. ).
 As I can see from code[1] it seams to me the validator expects any kind of 
 value and if it's not a list/tuple it insert into a list and validate it.
 Another problem is that[2] if the result of the operation 
 str(item).strip() is evaluated as False any validation is applied... so 
 there's no way to oblige the user not to pass a null value (i.e. to insert 
 any value).

 Could it be ehough to remove the line 2520[2]? Why it has been introduced?

 Cheers

 Manuele


 [1] https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2508
 [2] https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2520
  

-- 
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] Bug with submit button?

2014-11-19 Thread LoveWeb2py
This only seems to happen when I run a local copy of my appliance, but here 
it goes. 

First the code:
   
controller:
def submit_answer():
session.incorrect = False
points = 0
responsejs=False
tabTracker = False
sound = None
answer=FORM('Answer: ',
  INPUT(_name='answer', requires=IS_NOT_EMPTY()),
  INPUT(_type='submit', _class='btn btn-primary', 
_id=sub_button,_value=submit))
if answer.process(message_onsuccess='').accepted:
answer_comp = 
db(db.questions.id==int(request.vars['chal'])).select(db.questions.ALL).first()
if answer.vars['answer'] == answer_comp['answer']:
response.flash = 'Correct!'
redirect( 
request.env.http_web2py_component_location,client_side=True)
else:
session.incorrect = True
redirect( 
request.env.http_web2py_component_location,client_side=True)
response.flash = 'Incorrect answer'
elif answer.errors:
response.flash = ''
else:
response.flash = ''
return dict(answer=answer)

view:
 {{=LOAD('board','submit_answer.load', 
vars={'chal':question['id']},ajax=True)}}

-end code

When I click submit while using the appliance locally the button does a 
quick flash/glitch and my input vanishes, but when I click on submit again 
the input is submitted properly. In other words, I have to click submit 
twice for my button to work.

The version I have posted on the web works fine (submits on the first try).

Could this have something to do with accessing the server through a local 
ip? (127.0.0.1) That is the only difference I can spot 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] Re: Bug with submit button?

2014-11-19 Thread Anthony
Are you using the same version of web2py.js in both places?

On Wednesday, November 19, 2014 9:50:26 PM UTC-5, LoveWeb2py wrote:

 This only seems to happen when I run a local copy of my appliance, but 
 here it goes. 

 First the code:

 controller:
 def submit_answer():
 session.incorrect = False
 points = 0
 responsejs=False
 tabTracker = False
 sound = None
 answer=FORM('Answer: ',
   INPUT(_name='answer', requires=IS_NOT_EMPTY()),
   INPUT(_type='submit', _class='btn btn-primary', 
 _id=sub_button,_value=submit))
 if answer.process(message_onsuccess='').accepted:
 answer_comp = db(db.questions.id
 ==int(request.vars['chal'])).select(db.questions.ALL).first()
 if answer.vars['answer'] == answer_comp['answer']:
 response.flash = 'Correct!'
 redirect( 
 request.env.http_web2py_component_location,client_side=True)
 else:
 session.incorrect = True
 redirect( 
 request.env.http_web2py_component_location,client_side=True)
 response.flash = 'Incorrect answer'
 elif answer.errors:
 response.flash = ''
 else:
 response.flash = ''
 return dict(answer=answer)

 view:
  {{=LOAD('board','submit_answer.load', 
 vars={'chal':question['id']},ajax=True)}}

 -end code

 When I click submit while using the appliance locally the button does a 
 quick flash/glitch and my input vanishes, but when I click on submit again 
 the input is submitted properly. In other words, I have to click submit 
 twice for my button to work.

 The version I have posted on the web works fine (submits on the first try).

 Could this have something to do with accessing the server through a local 
 ip? (127.0.0.1) That is the only difference I can spot 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] Scheduler misleading DEBUG logging when task reaches timeout

2014-11-19 Thread Francisco Ribeiro
hi,

After some debugging, I noticed that when tasks timeout while using the 
scheduler, I get an output as follows:
DEBUG:web2py.app.myapp:new task report: FAILED
DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call last):
  File /../web2py/gluon/scheduler.py, line 303, in executor
result = dumps(_function(*args, **vars))
  File applications/myapp/models/db.py, line 337, in schedule_call
time.sleep(3600)
  File /.../web2py/gluon/scheduler.py, line 704, in lambda
signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1))
SystemExit: 1

Whilst the timeout behaviour happens just as I expect it to be and things 
get stored correctly on the database (scheduler_run.status = 'TIMEOUT'), 
this debugging output is somewhat misleading since 'FAILED' seems to be an 
alternative state different than 'TIMEOUT' according to documentation 
( http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

Can someone explain to me why this happens? Is it expectable? 

Thank you.
Kind regards,
Francisco

-- 
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: pagination issue redirecting to the current page

2014-11-19 Thread Massimo Di Pierro
URL('index',args=(2)) will give you page #2.


On Monday, 17 November 2014 22:59:16 UTC-6, Joe wrote:

 Thanks Cliff, I've been trying to do that but I didn't succeed. I would 
 appreciate if you could send an example on how to put the current page info 
 in the request.args dictionary.

 On Tuesday, November 18, 2014 12:37:09 PM UTC+8, Cliff Kachinske wrote:

 Put information about the current page in the request.args dictionary. 
 You could use the session, but if your user opens a second browser window 
 it becomes difficult to keep track of which session data corresponds to 
 which browser tab.




-- 
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 you issue a command to the operating system in web2py?

2014-11-19 Thread Massimo Di Pierro
It is not necessarily a bad idea. He is not saying he wants to run an 
arbitrary command.
If the command is, for example, ls -l  mydir you can run it with

import os
os.system(ls -l  mydir)

There are some caveats:
- do not run the commands that can take long time otherwise
- consider using the scheduler 
- it may be a security hazard to run arbitrary commands 



On Tuesday, 18 November 2014 04:06:28 UTC-6, Leonel Câmara wrote:

 This is a very very bad idea, it's also a python question not a web2py one 
 (it's possible btw), what are you trying to accomplish?


-- 
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: Unable to pass vars using select form

2014-11-19 Thread Massimo Di Pierro
we need to see more code, specifically the controller, or explain what you 
want it do. We cannot figure it out from you example.

On Tuesday, 18 November 2014 04:14:00 UTC-6, Anatoli Hristov wrote:

 Hello,

 I was trying to use this kind of form, but I cannot pass the variables to 
 the page!

 Any hints?

 Thanks


 form action=? method=POST
 select name=myselect id=myselect onchange=this.form.submit()
 {{for item in screen_model:}}
 option name=screen value={{vars=item.id
 }}{{=item.model}}/option{{pass}}
 /select
 /form


-- 
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: a proposal for form improvement

2014-11-19 Thread Massimo Di Pierro
They will fight all the time.

On Tuesday, 18 November 2014 09:12:55 UTC-6, Richard wrote:

 I miss this one...

 How does JForm will cohabit with Angularjs or Ractivejs?

 Richard

 On Mon, Nov 17, 2014 at 11:56 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 In my todo list but no great progress yet.


 On Friday, 14 November 2014 05:58:10 UTC-6, Ramos wrote:

 Just checking the status of Jform.
 Any news on it?

 Regards
 António

 2014-09-10 2:02 GMT+01:00 Massimo Di Pierro massimo.dipie...@gmail.com
 :

 I agree. I have not implemented but I was planning to add this feature. 

 On Tuesday, 9 September 2014 03:44:30 UTC-5, Leonel Câmara wrote:

 This is the corresponding JS one optimized for bootstrap 3:

 jform.widgets['text'] = function(field) { return 
 jform.tag('textarea',{'name':field.name,'class':'form-contro
 l'})(field.value); }


 Massimo that looks good, however in SQLFORM I can change the 
 textwidget in a very specific way - I can change it for a single field on 
 a 
 single table on a single controller, changing widgets in jform like this 
 wouldn't work because you would change the text widget for all jforms 
 being 
 rendered in that webpage. 

 Maybe you want to change the widget for just that one form and leave 
 the others unchanged. Sometimes, you do want to change your textwidgets 
 application wide but sometimes you don't. So things get a little more 
 complicated.  

 There needs to be some way to define context for jform where you can 
 customize just one single form. Basically JForm would need to have a 
 dictionary of table or even form specific widgets where you could do 
 something like.

 jform.widgets.forms[myformid]['text'] = function(field) { return 
 jform.tag('textarea',{'name':field.name,'class':'form-contro
 l'})(field.value); }
 jform.widgets.tables[tablename]['text'] = function(field) { return 
 jform.tag('textarea',{'name':field.name,'class':'form-contro
 l'})(field.value); }

 So things do start to get messy. This solution, of course, isn't ideal 
 if you are building a single page app as this context you're creating 
 doesn't get automatically cleaned every call like it happens on the 
 server 
 side with SQLFORM so then you start to get strange interactions and bugs. 
 Hence we have to figure out a smarter way to do it where the context is 
 really available for just that one form and it goes away with 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.


  -- 
 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: Web2py Funding

2014-11-19 Thread Massimo Di Pierro
Honestly I do not understand how Meteor pulled it off. 
I would have been happy to rebuilt something better than meteor for them 
for 1/10th of that amount.
But nobody asked me.




On Tuesday, 18 November 2014 06:40:12 UTC-6, Leonel Câmara wrote:

 I think this would be hard to do. Funding is a lot easier when you're 
 riding some kind of hipster wave like meteor did.


-- 
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: Why all traffic forwarded to https and how to stop this ?

2014-11-19 Thread Massimo Di Pierro
routes.py is not deprecated but the same can be achieved using apache or 
nginx config script. I prefer to use routes anyway.
I am not sure why you get redirect to https. Which install script did you 
use? I do not think any forces you to use https. Perhaps the app redirects 
to https.

On Wednesday, 19 November 2014 00:52:32 UTC-6, joe black :) wrote:


 Hi,

 Just deployed a new web2py using deployment script on Ubuntu.* Problem is 
 all the traffic is forwarded to https. giving certificate error to users.* 
 It was not like this before. How to stop this automatic forward to https?

 Also where is the routes.py . Is it depreciated ? Then how to achieve 
 domain to app mapping ?

 Thanks,
 sabbir


-- 
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 with submit button?

2014-11-19 Thread LoveWeb2py
Hi Anthony,

Yes - I confirmed the byte count and they're exactly the same. 

On Wednesday, November 19, 2014 10:16:39 PM UTC-5, Anthony wrote:

 Are you using the same version of web2py.js in both places?

 On Wednesday, November 19, 2014 9:50:26 PM UTC-5, LoveWeb2py wrote:

 This only seems to happen when I run a local copy of my appliance, but 
 here it goes. 

 First the code:

 controller:
 def submit_answer():
 session.incorrect = False
 points = 0
 responsejs=False
 tabTracker = False
 sound = None
 answer=FORM('Answer: ',
   INPUT(_name='answer', requires=IS_NOT_EMPTY()),
   INPUT(_type='submit', _class='btn btn-primary', 
 _id=sub_button,_value=submit))
 if answer.process(message_onsuccess='').accepted:
 answer_comp = db(db.questions.id
 ==int(request.vars['chal'])).select(db.questions.ALL).first()
 if answer.vars['answer'] == answer_comp['answer']:
 response.flash = 'Correct!'
 redirect( 
 request.env.http_web2py_component_location,client_side=True)
 else:
 session.incorrect = True
 redirect( 
 request.env.http_web2py_component_location,client_side=True)
 response.flash = 'Incorrect answer'
 elif answer.errors:
 response.flash = ''
 else:
 response.flash = ''
 return dict(answer=answer)

 view:
  {{=LOAD('board','submit_answer.load', 
 vars={'chal':question['id']},ajax=True)}}

 -end code

 When I click submit while using the appliance locally the button does a 
 quick flash/glitch and my input vanishes, but when I click on submit again 
 the input is submitted properly. In other words, I have to click submit 
 twice for my button to work.

 The version I have posted on the web works fine (submits on the first 
 try).

 Could this have something to do with accessing the server through a local 
 ip? (127.0.0.1) That is the only difference I can spot 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.