[web2py] Re: new experimental feature in trunk - rows.join(...)

2017-03-09 Thread Jurgis Pralgauskis
What is more efficient on relational DB (for ex., postgre):  join(..)  or 
 group_by_val(..)  

rows = db(db.person).select().join(db.thing.owner, name="owns", fields=[
db.thing.id, db.thing.name])  

vs

rows = db(db.person).select( db.person.All, db.thing.id, db.thing.name, 
 join=[ ..on.db.thing.owner=...,) ).group_by_val( db.person.id ) 
# 1 db request, but more duplicating info in fetched rows

ps.: maybe join(..) could be named "join_grouped" for less confusion with 
select's arg "join" (and better hint what it does)

-- 
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: Unpickling error

2017-03-09 Thread Dave S


On Thursday, March 9, 2017 at 4:59:03 AM UTC-8, Maurice Waka wrote:
>
> Sorry. I discovered that my database was corrupted 
>
>

That's too bad, but if the data is backed up it's at least a relatively 
straightforward recovery.  Good luck!

/dps
 

> On Mar 6, 2017 23:20, "Jordan Myers"  
> wrote:
>
>> It would help if you gave us some more context. Where does this error 
>> occur? What are you trying to do? The error seems to be when you are 
>> creating tables in the file db2.py, what are the contents of this file?
>>
>> On Monday, March 6, 2017 at 10:08:04 AM UTC-6, Maurice Waka wrote:
>>>
>>> Am getting this web2py error in Ubuntu: 
>>>
>>> Traceback (most recent call last):
>>>   File "/home/mwk/web2py/gluon/restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File "/home/mwk/web2py/applications/britamintell/models/db2.py", line 15, 
>>> in 
>>> auth.signature)
>>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/base.py", line 834, in 
>>> define_table
>>> table = self.lazy_define_table(tablename,*fields,**args)
>>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/base.py", line 873, in 
>>> lazy_define_table
>>> polymodel=polymodel)
>>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
>>> 500, in create_table
>>> sql_fields_old = pickle.load(tfile)UnpicklingError: invalid load key, 
>>> '�'.
>>>
>>> what is this and how do i resolve 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/FyHFlywmRdg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[web2py] Re: KeyError ticket when I request a CSV/TSV in a grid with a Virtual Field

2017-03-09 Thread Dave S


On Tuesday, March 7, 2017 at 6:10:01 PM UTC-8, Marcelo Huerta wrote:
>
> Running 2.14.6-stable+timestamp.2016.05.10.00.21.47 on Ubuntu and Windows 
> 7, python 2.7
>
> When I try to generate a CSV or TSV from a grid with a Virtual Field, I 
> get a ticket with a KeyError.
>
>
Can you show us your table definition?

Others will have to answer whether the CSV code knows whether a field is 
virtual or actual.  Looking at gluon/tools.py, server_csv() calls  
universal_caller(), which appears to pass along as many positional and 
named arguments as it can, and for the csv case the named args come from 
request.vars.

/dps

 

> Traceback (most recent call last):
>   File "F:\Prog\web2py\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File "F:\Prog\web2py\applications\axxoneval\controllers/default.py", line 
> 447, in 
>   File "F:\Prog\web2py\gluon\globals.py", line 417, in 
> self._caller = lambda f: f()
>   File "F:\Prog\web2py\gluon\tools.py", line 4250, in f
> return action(*a, **b)
>   File "F:\Prog\web2py\applications\axxoneval\controllers/default.py", line 
> 199, in listar_evaluaciones
> csv = True, create = False, editable = False, deletable = True, 
> searchable=True, details=False,
>   File "F:\Prog\web2py\gluon\sqlhtml.py", line 2752, in grid
> value = row[str(field)]
>   File "F:\Prog\web2py\gluon\packages\dal\pydal\objects.py", line 76, in 
> __getitem__
> raise KeyError
> KeyError
>
> Is this a known problem?
>
>

-- 
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 display field names and values within for loop?

2017-03-09 Thread Alex Glaros
Will your example provide both field name and field value?

am reveiving error

CONTROLLER: supRows = db(db.Organization.id == 1).select()  {{#returns 
locals}}

VIEW:
{{for record in supRows:}}
{{=record.field}} 
{{pass}}

Error ticket for "ES3"Ticket ID

127.0.0.1.2017-03-09.16-54-06.fc1316c6-4ce4-4041-81fc-4f3ab11ce557
Version
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python Python 2.7.9: C:\alex\alt_web2py_7\web2py\web2py.exe (prefix: 
C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.

Traceback (most recent call last):
  File "C:\alex\alt_web2py_7\web2py\gluon\restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"C:\alex\alt_web2py_7\web2py\applications\ES3\views\default/manage_super_object_options.html",
 line 95, in 

  File "C:\alex\alt_web2py_7\web2py\gluon\packages\dal\pydal\objects.py", line 
90, in __getattr__
raise AttributeError
AttributeError

Error snapshot [image: help] 


()

inspect attributes
Frames
   
   - 
   
   *File C:\alex\alt_web2py_7\web2py\gluon\restricted.py in restricted at 
   line 227* code arguments variables
   - 
   
   *File 
   
C:\alex\alt_web2py_7\web2py\applications\ES3\views\default\manage_super_object_options.html
 
   in  at line 95* code arguments variables
   - 
   
   *File C:\alex\alt_web2py_7\web2py\gluon\packages\dal\pydal\objects.py in 
   __getattr__ at line 90* code arguments variables
   Function argument list
   
   (self=}>, k='field')
   Code listing
   
   85.
   86.
   87.
   88.
   89.
   90.
   
   91.
   92.
   93.
   94.
   
   
   def __getattr__(self, k):
   try:
   return self.__getitem__(k)
   except KeyError:
   raise AttributeError
   
   
   def __copy__(self):
   return Row(self)
   
   

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Jim Steil
That is possible.

Jim


On Mar 9, 2017 6:39 PM, "Anthony"  wrote:

> On Thursday, March 9, 2017 at 5:08:56 PM UTC-5, Jim S wrote:
>>
>> queries = [db.auth_user.id > 0]
>> queries.append("%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', '
>> ', 'last_name'), searchText)
>>
>
> I guess you must have pulled a more recent version version of web2py from
> Github (i.e., after the last stable release) -- looks like pydal was
> refactored and CONCAT is no longer there.
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/3RnGSoUbxxY/unsubscribe.
> To unsubscribe from this group and all its topics, 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: how to display field names and values within for loop?

2017-03-09 Thread Dave S


On Thursday, March 9, 2017 at 4:09:46 PM UTC-8, Alex Glaros wrote:
>
> I'd like to display column names and values vertically
>
> is there any way to write as expressed in this psudo code?
>
> {{for f in db.someTableRecord:}}
> {{=f}} {{=value_of_the_field}}
> {{pass}}
>
> (To save programming time, I don't want to specify the field name; just 
> use "f")
>
>
You should do the database access in a controller, and return the results 
as an array or dict.  Then it's pretty straightforward Python.

in controller, for dict:

def getrecords():
results = db().select( )
return dict(records=results)




in view, for dict:
{{for record in records:}}
{{   =record.field}}  {{ # or =record["field"] }}
{{ pass}}


Also easy to make your own table in the loop, with
{{ =record.field}} 




thanks
>
> Alex Glaros
>

HTH
/dps

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


[web2py] Re: how to display field names and values within for loop?

2017-03-09 Thread Alex Glaros
also, is there a way to

1. leave out the table name and just display field name
2. use the field label name instead of the raw/real field name?

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Anthony
On Thursday, March 9, 2017 at 5:08:56 PM UTC-5, Jim S wrote:
>
> queries = [db.auth_user.id > 0]
> queries.append("%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', ' ', 
> 'last_name'), searchText)
>

I guess you must have pulled a more recent version version of web2py from 
Github (i.e., after the last stable release) -- looks like pydal was 
refactored and CONCAT is no longer there.

Anthony

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


[web2py] how to display field names and values within for loop?

2017-03-09 Thread Alex Glaros
I'd like to display column names and values vertically

is there any way to write as expressed in this psudo code?

{{for f in db.someTableRecord:}}
{{=f}} {{=value_of_the_field}}
{{pass}}

thanks

Alex Glaros

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread isi_jca
Jim:

In the next expression

query = db((db.auth_user == name) or (db.auth_user == lastname)).select()

Replace "or" by "|" (pipe)

query = db((db.auth_user == name) | (db.auth_user == lastname)).select()

Regards.

El miércoles, 8 de marzo de 2017, 1:00:04 (UTC-3), Jim S escribió:
>
> Hi
>
> I have a search form where the user types in generic search text.  I want 
> to be able to return to them a list of matching users.
>
> Sample Data
>
>   First   Last
> - --  --
> 1 Jim Sanders
> 2 BillVan Der Wall
> 3 JohnSt James
> 4 Peter   Williams
> 5 Jim Hensen
> 6 JohnAdams
> 7 William Tell
> 8 AdamJohnson
>  
>
> Based on the data entered in the search box, these records should be 
> returned
>
>   
>   Search Text  Rows Returned
> -  --
> 1 Jim  1, 5
> 2 John 3, 6, 8
> 3 Adam 6, 8
> 4 Bill 2
> 5 Jim Sanders  1
> 6 Adam John8
> 7 John St James3
>  
>
> I can't seem to come up with a query or anything to make this happen. 
>  With SQL I might to this:
>
> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name LIKE 
> \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' % (search_text, 
> search_text, search_text)
>
> But, I want to build this as a query for SQLFORM.grid.  
>
> Anyone have any ideas?
>
> -Jim
>
>

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Jim Steil
queries = [db.auth_user.id > 0]
queries.append("%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', ' ',
'last_name'), searchText)
query = reduce(lambda a, b: (a & b), queries)

-Jim


On Thu, Mar 9, 2017 at 4:03 PM, Anthony  wrote:

> I meant what was the code that produced that CONCAT exception?
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/3RnGSoUbxxY/unsubscribe.
> To unsubscribe from this group and all its topics, 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] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Anthony
I meant what was the code that produced that CONCAT exception?

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Richard Vézina
You may need also to make some cleansing for multiple white spaces with
replace before your final split and add some logic for middle name and add
further where clause condition...

where_clauses = []
where_clauses.append((db[request.args(0)].fieldname <=
request.vars.input_entry))

query = reduce(lambda a, b: a | b, where_clauses)
rows = db(query).select(*output_columns)

But your contains() solution may be simpler...

Richard

On Thu, Mar 9, 2017 at 4:17 PM, Richard Vézina 
wrote:

> single_input_first_last_name.split(' ')[0] 
> single_input_first_last_name.split('
> ')[1] can workin case your user input first and last name in a proper order
> or you search both first and last name 4 times if you don't know in which
> order you get them with OR ('|') you will get everythings out you have in
> the database
>
> Richard
>
> On Thu, Mar 9, 2017 at 3:46 PM, Jim Steil  wrote:
>
>> Here is my version info:
>>
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2017
>> Version 2.14.6-stable+timestamp.2016.05.09.19.18.48
>> Database drivers available: pymysql, imaplib, MySQLdb, sqlite3, pg8000,
>> pyodbc
>>
>> Code used to be:
>>
>> queries = [db.auth_user.id > 0]
>> queries.append((db.auth_user.firstLast.contains(searchText)) |
>> (db.auth_user.lastFirst.contains(searchText)))
>> query = reduce(lambda a, b: (a & b), queries)
>>
>> I'd hadn't figured out that I could pass text like that to my sub-query.
>>
>>
>>
>>
>> On Thu, Mar 9, 2017 at 2:27 PM, Anthony  wrote:
>>
>>> What did your code look like, and are you using an older version of
>>> web2py?
>>>
>>> On Thursday, March 9, 2017 at 12:08:10 PM UTC-5, Jim S wrote:

 Holy Cow!  I got it working.

 Not exactly what you specified Anthony, but got me on the right track

 With your method I got this traceback:

 Traceback (most recent call last):
   File "C:\dev\web2py\gluon\restricted.py", line 216, in restricted
 exec(ccode, environment)
   File "C:\dev\web2py\applications\connect\controllers/user.py:index", 
 line 281, in 
   File "C:\dev\web2py\gluon\globals.py", line 405, in 
 self._caller = lambda f: f()
   File "C:\dev\web2py\gluon\tools.py", line 4299, in f
 return action(*a, **b)
   File "C:\dev\web2py\applications\connect\controllers/user.py:index", 
 line 72, in index
 AttributeError: 'MySQL' object has no attribute 'CONCAT'


 However, I then tried this:

 queries = [db.auth_user.id > 0]
 queries.append((db.auth_user.firstLast.contains(searchText)) |
   (db.auth_user.lastFirst.contains(searchText)) |
   ("CONCAT(first_name, \' \', last_Name) LIKE '%%%s%%'" % (searchText)))
 query = reduce(lambda a, b: (a & b), queries)

 ...and passed the query and it worked.

 Much appreciated!

 -Jim




 On Thu, Mar 9, 2017 at 10:37 AM, Anthony wrote:

> I haven't tried it, but maybe something like this:
>
> def search(sfields, keywords):
> keywords = keywords.strip().replace("'", "''")
> return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" %
> keywords
>
> grid = SQLFORM.grid(db.mytable, searchable=search)
>
> Actually, although not documented as part of the public API, each
> adapter has a CONCAT method, which produces the correct syntax for each
> database. So, the last line of the search function above could be:
>
> return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', '
> ', 'last_name'), keywords)
>
> Anthony
>
> On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:
>>
>> Hi
>>
>> I have a search form where the user types in generic search text.  I
>> want to be able to return to them a list of matching users.
>>
>> Sample Data
>>
>>   First   Last
>> - --  --
>> 1 Jim Sanders
>> 2 BillVan Der Wall
>> 3 JohnSt James
>> 4 Peter   Williams
>> 5 Jim Hensen
>> 6 JohnAdams
>> 7 William Tell
>> 8 AdamJohnson
>>
>>
>> Based on the data entered in the search box, these records should be
>> returned
>>
>>
>>   Search Text  Rows Returned
>> -  --
>> 1 Jim  1, 5
>> 2 John 3, 6, 8
>> 3 Adam 6, 8
>> 4 Bill 2
>> 5 Jim Sanders  1
>> 6 Adam John8
>> 7 John St James3
>>
>>
>> I can't seem to come up with a query or anything to make this
>> happen.  With SQL I might to this:
>>
>> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name
>> LIKE \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' %
>> (search_text, search_text, 

Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Richard Vézina
single_input_first_last_name.split(' ')[0]
single_input_first_last_name.split(' ')[1] can workin case your user input
first and last name in a proper order or you search both first and last
name 4 times if you don't know in which order you get them with OR ('|')
you will get everythings out you have in the database

Richard

On Thu, Mar 9, 2017 at 3:46 PM, Jim Steil  wrote:

> Here is my version info:
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2017
> Version 2.14.6-stable+timestamp.2016.05.09.19.18.48
> Database drivers available: pymysql, imaplib, MySQLdb, sqlite3, pg8000,
> pyodbc
>
> Code used to be:
>
> queries = [db.auth_user.id > 0]
> queries.append((db.auth_user.firstLast.contains(searchText)) |
> (db.auth_user.lastFirst.contains(searchText)))
> query = reduce(lambda a, b: (a & b), queries)
>
> I'd hadn't figured out that I could pass text like that to my sub-query.
>
>
>
>
> On Thu, Mar 9, 2017 at 2:27 PM, Anthony  wrote:
>
>> What did your code look like, and are you using an older version of
>> web2py?
>>
>> On Thursday, March 9, 2017 at 12:08:10 PM UTC-5, Jim S wrote:
>>>
>>> Holy Cow!  I got it working.
>>>
>>> Not exactly what you specified Anthony, but got me on the right track
>>>
>>> With your method I got this traceback:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\dev\web2py\gluon\restricted.py", line 216, in restricted
>>> exec(ccode, environment)
>>>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
>>> 281, in 
>>>   File "C:\dev\web2py\gluon\globals.py", line 405, in 
>>> self._caller = lambda f: f()
>>>   File "C:\dev\web2py\gluon\tools.py", line 4299, in f
>>> return action(*a, **b)
>>>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
>>> 72, in index
>>> AttributeError: 'MySQL' object has no attribute 'CONCAT'
>>>
>>>
>>> However, I then tried this:
>>>
>>> queries = [db.auth_user.id > 0]
>>> queries.append((db.auth_user.firstLast.contains(searchText)) |
>>>   (db.auth_user.lastFirst.contains(searchText)) |
>>>   ("CONCAT(first_name, \' \', last_Name) LIKE '%%%s%%'" % (searchText)))
>>> query = reduce(lambda a, b: (a & b), queries)
>>>
>>> ...and passed the query and it worked.
>>>
>>> Much appreciated!
>>>
>>> -Jim
>>>
>>>
>>>
>>>
>>> On Thu, Mar 9, 2017 at 10:37 AM, Anthony wrote:
>>>
 I haven't tried it, but maybe something like this:

 def search(sfields, keywords):
 keywords = keywords.strip().replace("'", "''")
 return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" %
 keywords

 grid = SQLFORM.grid(db.mytable, searchable=search)

 Actually, although not documented as part of the public API, each
 adapter has a CONCAT method, which produces the correct syntax for each
 database. So, the last line of the search function above could be:

 return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', '
 ', 'last_name'), keywords)

 Anthony

 On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:
>
> Hi
>
> I have a search form where the user types in generic search text.  I
> want to be able to return to them a list of matching users.
>
> Sample Data
>
>   First   Last
> - --  --
> 1 Jim Sanders
> 2 BillVan Der Wall
> 3 JohnSt James
> 4 Peter   Williams
> 5 Jim Hensen
> 6 JohnAdams
> 7 William Tell
> 8 AdamJohnson
>
>
> Based on the data entered in the search box, these records should be
> returned
>
>
>   Search Text  Rows Returned
> -  --
> 1 Jim  1, 5
> 2 John 3, 6, 8
> 3 Adam 6, 8
> 4 Bill 2
> 5 Jim Sanders  1
> 6 Adam John8
> 7 John St James3
>
>
> I can't seem to come up with a query or anything to make this happen.
> With SQL I might to this:
>
> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name
> LIKE \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' %
> (search_text, search_text, search_text)
>
> But, I want to build this as a query for SQLFORM.grid.
>
> Anyone have any ideas?
>
> -Jim
>
> --
 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 a topic in the
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit https://groups.google.com/d/to
 pic/web2py/3RnGSoUbxxY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 

Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Jim Steil
Here is my version info:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2017
Version 2.14.6-stable+timestamp.2016.05.09.19.18.48
Database drivers available: pymysql, imaplib, MySQLdb, sqlite3, pg8000,
pyodbc

Code used to be:

queries = [db.auth_user.id > 0]
queries.append((db.auth_user.firstLast.contains(searchText)) |
(db.auth_user.lastFirst.contains(searchText)))
query = reduce(lambda a, b: (a & b), queries)

I'd hadn't figured out that I could pass text like that to my sub-query.




On Thu, Mar 9, 2017 at 2:27 PM, Anthony  wrote:

> What did your code look like, and are you using an older version of web2py?
>
> On Thursday, March 9, 2017 at 12:08:10 PM UTC-5, Jim S wrote:
>>
>> Holy Cow!  I got it working.
>>
>> Not exactly what you specified Anthony, but got me on the right track
>>
>> With your method I got this traceback:
>>
>> Traceback (most recent call last):
>>   File "C:\dev\web2py\gluon\restricted.py", line 216, in restricted
>> exec(ccode, environment)
>>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
>> 281, in 
>>   File "C:\dev\web2py\gluon\globals.py", line 405, in 
>> self._caller = lambda f: f()
>>   File "C:\dev\web2py\gluon\tools.py", line 4299, in f
>> return action(*a, **b)
>>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
>> 72, in index
>> AttributeError: 'MySQL' object has no attribute 'CONCAT'
>>
>>
>> However, I then tried this:
>>
>> queries = [db.auth_user.id > 0]
>> queries.append((db.auth_user.firstLast.contains(searchText)) |
>>   (db.auth_user.lastFirst.contains(searchText)) |
>>   ("CONCAT(first_name, \' \', last_Name) LIKE '%%%s%%'" % (searchText)))
>> query = reduce(lambda a, b: (a & b), queries)
>>
>> ...and passed the query and it worked.
>>
>> Much appreciated!
>>
>> -Jim
>>
>>
>>
>>
>> On Thu, Mar 9, 2017 at 10:37 AM, Anthony wrote:
>>
>>> I haven't tried it, but maybe something like this:
>>>
>>> def search(sfields, keywords):
>>> keywords = keywords.strip().replace("'", "''")
>>> return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" %
>>> keywords
>>>
>>> grid = SQLFORM.grid(db.mytable, searchable=search)
>>>
>>> Actually, although not documented as part of the public API, each
>>> adapter has a CONCAT method, which produces the correct syntax for each
>>> database. So, the last line of the search function above could be:
>>>
>>> return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', '
>>> ', 'last_name'), keywords)
>>>
>>> Anthony
>>>
>>> On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:

 Hi

 I have a search form where the user types in generic search text.  I
 want to be able to return to them a list of matching users.

 Sample Data

   First   Last
 - --  --
 1 Jim Sanders
 2 BillVan Der Wall
 3 JohnSt James
 4 Peter   Williams
 5 Jim Hensen
 6 JohnAdams
 7 William Tell
 8 AdamJohnson


 Based on the data entered in the search box, these records should be
 returned


   Search Text  Rows Returned
 -  --
 1 Jim  1, 5
 2 John 3, 6, 8
 3 Adam 6, 8
 4 Bill 2
 5 Jim Sanders  1
 6 Adam John8
 7 John St James3


 I can't seem to come up with a query or anything to make this happen.
 With SQL I might to this:

 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name
 LIKE \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' %
 (search_text, search_text, search_text)

 But, I want to build this as a query for SQLFORM.grid.

 Anyone have any ideas?

 -Jim

 --
>>> 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 a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/web2py/3RnGSoUbxxY/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/3RnGSoUbxxY/unsubscribe.
> To unsubscribe from this 

Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Anthony
What did your code look like, and are you using an older version of web2py?

On Thursday, March 9, 2017 at 12:08:10 PM UTC-5, Jim S wrote:
>
> Holy Cow!  I got it working.
>
> Not exactly what you specified Anthony, but got me on the right track
>
> With your method I got this traceback:
>
> Traceback (most recent call last):
>   File "C:\dev\web2py\gluon\restricted.py", line 216, in restricted
> exec(ccode, environment)
>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
> 281, in 
>   File "C:\dev\web2py\gluon\globals.py", line 405, in 
> self._caller = lambda f: f()
>   File "C:\dev\web2py\gluon\tools.py", line 4299, in f
> return action(*a, **b)
>   File "C:\dev\web2py\applications\connect\controllers/user.py:index", line 
> 72, in index
> AttributeError: 'MySQL' object has no attribute 'CONCAT'
>
>
> However, I then tried this:
>
> queries = [db.auth_user.id > 0]
> queries.append((db.auth_user.firstLast.contains(searchText)) |
>   (db.auth_user.lastFirst.contains(searchText)) |
>   ("CONCAT(first_name, \' \', last_Name) LIKE '%%%s%%'" % (searchText)))
> query = reduce(lambda a, b: (a & b), queries)
>
> ...and passed the query and it worked.
>
> Much appreciated!
>
> -Jim
>
>
>
>
> On Thu, Mar 9, 2017 at 10:37 AM, Anthony wrote:
>
>> I haven't tried it, but maybe something like this:
>>
>> def search(sfields, keywords):
>> keywords = keywords.strip().replace("'", "''")
>> return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" % 
>> keywords
>>
>> grid = SQLFORM.grid(db.mytable, searchable=search)
>>
>> Actually, although not documented as part of the public API, each adapter 
>> has a CONCAT method, which produces the correct syntax for each database. 
>> So, the last line of the search function above could be:
>>
>> return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', ' '
>> , 'last_name'), keywords)
>>
>> Anthony
>>
>> On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:
>>>
>>> Hi
>>>
>>> I have a search form where the user types in generic search text.  I 
>>> want to be able to return to them a list of matching users.
>>>
>>> Sample Data
>>>
>>>   First   Last
>>> - --  --
>>> 1 Jim Sanders
>>> 2 BillVan Der Wall
>>> 3 JohnSt James
>>> 4 Peter   Williams
>>> 5 Jim Hensen
>>> 6 JohnAdams
>>> 7 William Tell
>>> 8 AdamJohnson
>>>  
>>>
>>> Based on the data entered in the search box, these records should be 
>>> returned
>>>
>>>   
>>>   Search Text  Rows Returned
>>> -  --
>>> 1 Jim  1, 5
>>> 2 John 3, 6, 8
>>> 3 Adam 6, 8
>>> 4 Bill 2
>>> 5 Jim Sanders  1
>>> 6 Adam John8
>>> 7 John St James3
>>>  
>>>
>>> I can't seem to come up with a query or anything to make this happen.  
>>> With SQL I might to this:
>>>
>>> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name LIKE 
>>> \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' % (search_text, 
>>> search_text, search_text)
>>>
>>> But, I want to build this as a query for SQLFORM.grid.  
>>>
>>> Anyone have any ideas?
>>>
>>> -Jim
>>>
>>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/3RnGSoUbxxY/unsubscribe.
>> To unsubscribe from this group and all its topics, 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] bootstrap modal and conditional fields

2017-03-09 Thread Andrea Fae'
I'm using a modal bootstrap to show a form from a table, this is the 
funntion called from JS webcomponent

$.web2py.component("{{=URL('default', 'nuovo_evento.load')}}"+ "?titolo=" + 
title +"=" + risorsa + "=" +start + "=" + 
end,"modulo-evento");


Function of the controller:
def nuovo_evento():
db.evento.fine.default = datetime.strptime(request.vars.end, "%Y-%m-%d 
%H:%M:%S")
db.evento.risorsa.default = request.vars.risorsa
db.evento.risorsa.default=request.vars.risorsa
db.evento.inizio.default=datetime.strptime(request.vars.start, 
"%Y-%m-%d %H:%M:%S")
db.evento.fine.default=datetime.strptime(request.vars.end, "%Y-%m-%d 
%H:%M:%S")

db.evento.inizio.writable=db.evento.fine.writable=db.evento.risorsa.writable=False
form=SQLFORM(db.evento)
if form.process().accepted:
session.flash = 'form accepted'
response.js = 'hide_modal("#myModal");'
redirect(URL('sched.html',args='3'),client_side=True)
return locals()

I have 1 drop down in the modal depending on another drop down. I can I 
manage in the modal? 
I explain better: if I select one value of the first drop down the second 
drop down has to have different values depending on the item selected in 
the first modal...
Thank you



-- 
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] how to override "select" method?

2017-03-09 Thread Jurgis Pralgauskis
One more feature:
 - I want to get  result of select()   .compact=False by default

On Thu, Mar 9, 2017 at 8:33 PM, Jurgis Pralgauskis <
jurgis.pralgaus...@gmail.com> wrote:

> Hi,
>
> I want to have extra features for select(..)
> And the codebase is already quite big -- imo best would be to implement
> the features transparently...
>
> I guess I could make derivative of Set class
> and override __call__ and select (and maybe _select) If I need this only
> for reading information?
>
> or should I think of making/deriving Adapter (in my case Postgre and maybe
> Sqlite)?
>
>
> ps.:
> The features I want to have:
>  - our system stores translations for names of different items from
> different tables...  And I  decorate query and args for select(..) on the
> fly  (src
> 
> )
>  - virtual fields would know what extra  fields/Expressions they need (src
> 
> )
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/c_BMpcUu8Vg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jurgis Pralgauskis
tel: 8-616 77613;
Don't worry, be happy and make things better ;)
http://galvosukykla.lt

-- 
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: {Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Richard Vézina
port=636,
secure=True,
self_signed_certificate=True,

You should look at auth_ldap code if they all apply depends of your LDAP
server... Things is I don't recall if I contribute all the change I made
over my own auth_ldap, but the code is your source of truth...

:)

Richard

On Thu, Mar 9, 2017 at 1:35 PM, Richard Vézina 
wrote:

> Associate parameters :
>
>
> On Thu, Mar 9, 2017 at 1:32 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> You may try the SSL port 636 (http://www.openldap.org/faq/d
>> ata/cache/185.html)
>>
>>
>> You may realise that it actually available...
>>
>> Richard
>>
>> On Thu, Mar 9, 2017 at 12:53 PM, Carlos Cesar Caballero Díaz <
>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>
>>> I completely agree, and I have warned to the sysadmin, but is not my
>>> network, so...
>>>
>>> Greetings.
>>>
>>> El 09/03/17 a las 12:26, Richard Vézina escribió:
>>>
>>> Hello Carlos,
>>>
>>> auth_ldap is difficult to put in place because as you mention it doesn't
>>> provide proper feedback when something goes wrong...
>>>
>>> Note: If you access localhost instance of LDAP it may be ok to not use
>>> SSL protected service, but other than that you want to use 636 port (if I
>>> recall) and SSL protected connection, or the username and password can be
>>> access in clear text by sniffing the network...
>>>
>>> Richard
>>>
>>> On Thu, Mar 9, 2017 at 12:02 PM, Carlos Cesar Caballero Díaz <
>>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>>
 Hi Richard,

 I am connecting against an OpenLDAP server, and here is a lot of
 services running against it (proxy, email, nextcloud, dolibarr, a few dozen
 of Ubuntu PCs and others).

 After a more accurate debugging I release that simple_bind_s() was
 throwing an invalid credentials error (will be good to add a a warning or
 something in logs).

 I start trying with different options and this works (it seems that the
 ldap server was not using a standard OpenLdap structure, but i don't known
 too much about that):

 auth.settings.login_methods.append(ldap_auth(
 mode='custom', server='10.6.xx.xx',
 base_dn='dc=comp',
 username_attrib='uid',
 custom_scope='subtree',
 ))

 So, the problem is solved and is working without problems. Many thanks.


 Greetings.

 El 07/03/17 a las 13:40, Richard Vézina escribió:

 Hello Carlos,

 You can try to make simple bind with python ldap lib first, make sure
 user, base_dn is good, you will get more feedback then with ldap_auth

 Depending of the ldap server implementation that you try to reach you
 may fall on ldap_auth issue as not all part of the ldap_auth is well
 testing I guess, there is comment in the code saying that, so...

 Do you connect to Active Directory? open_ldap... Is the LDAP server
 properly configure if you use to put open_ldap in place by yourself for
 instance, are you able to use LDAP for authentication with other software
 solution??

 Richard

 On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz <
 carlos.caball...@cfg.jovenclub.cu> wrote:

> No, the ldap server is not protected by ssl.
>
> Greetings.
>
>
> El 07/03/17 a las 11:42, Richard Vézina escribió:
>
> Is your ldap server protected by ssl? If so you have to think to
> change port...
>
> Richard
>
> On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz <
> carlos.caball...@cfg.jovenclub.cu> wrote:
>
>> Hi, I am trying to include ldap authentication to my app, and for
>> this, i am using this code:
>>
>> auth.settings.login_methods.append(ldap_auth(
>> mode='uid',
>> server='10.6.xx.xx',
>> base_dn='dc=comp',
>> filterstr='&(objectClass=inetOrgPerson)',
>> logging_level='debug'))
>>
>> (note: The Original server and base_dn values are changed in this
>> example. I also have tried with and without the filterstr option)
>>
>> But I can't login with any ldap user, and the logs only say:
>>
>> DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False]
>> custom_scope: [subtree] manage_groups: [False]
>> INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap connection
>>
>> I Debug the ladp_auth module, and for some reason it hangs on the
>> line 314 ( con.simple_bind_s(dn, password)) without throw any error.
>>
>> If it helps, I also have tried this code and works as expected
>> returning the ldap user data:
>>
>> import ldap
>> ldap_server="10.6.xx.xx"
>> username = "auser"
>> base_dn = "dc=comp"
>>
>> query = "(uid=%s)" % username
>> con = ldap.initialize('ldap://'+ldap_server)
>>
>> result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
>> 

Re: {Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Richard Vézina
Associate parameters :


On Thu, Mar 9, 2017 at 1:32 PM, Richard Vézina 
wrote:

> You may try the SSL port 636 (http://www.openldap.org/faq/
> data/cache/185.html)
>
>
> You may realise that it actually available...
>
> Richard
>
> On Thu, Mar 9, 2017 at 12:53 PM, Carlos Cesar Caballero Díaz <
> carlos.caball...@cfg.jovenclub.cu> wrote:
>
>> I completely agree, and I have warned to the sysadmin, but is not my
>> network, so...
>>
>> Greetings.
>>
>> El 09/03/17 a las 12:26, Richard Vézina escribió:
>>
>> Hello Carlos,
>>
>> auth_ldap is difficult to put in place because as you mention it doesn't
>> provide proper feedback when something goes wrong...
>>
>> Note: If you access localhost instance of LDAP it may be ok to not use
>> SSL protected service, but other than that you want to use 636 port (if I
>> recall) and SSL protected connection, or the username and password can be
>> access in clear text by sniffing the network...
>>
>> Richard
>>
>> On Thu, Mar 9, 2017 at 12:02 PM, Carlos Cesar Caballero Díaz <
>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>
>>> Hi Richard,
>>>
>>> I am connecting against an OpenLDAP server, and here is a lot of
>>> services running against it (proxy, email, nextcloud, dolibarr, a few dozen
>>> of Ubuntu PCs and others).
>>>
>>> After a more accurate debugging I release that simple_bind_s() was
>>> throwing an invalid credentials error (will be good to add a a warning or
>>> something in logs).
>>>
>>> I start trying with different options and this works (it seems that the
>>> ldap server was not using a standard OpenLdap structure, but i don't known
>>> too much about that):
>>>
>>> auth.settings.login_methods.append(ldap_auth(
>>> mode='custom', server='10.6.xx.xx',
>>> base_dn='dc=comp',
>>> username_attrib='uid',
>>> custom_scope='subtree',
>>> ))
>>>
>>> So, the problem is solved and is working without problems. Many thanks.
>>>
>>>
>>> Greetings.
>>>
>>> El 07/03/17 a las 13:40, Richard Vézina escribió:
>>>
>>> Hello Carlos,
>>>
>>> You can try to make simple bind with python ldap lib first, make sure
>>> user, base_dn is good, you will get more feedback then with ldap_auth
>>>
>>> Depending of the ldap server implementation that you try to reach you
>>> may fall on ldap_auth issue as not all part of the ldap_auth is well
>>> testing I guess, there is comment in the code saying that, so...
>>>
>>> Do you connect to Active Directory? open_ldap... Is the LDAP server
>>> properly configure if you use to put open_ldap in place by yourself for
>>> instance, are you able to use LDAP for authentication with other software
>>> solution??
>>>
>>> Richard
>>>
>>> On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz <
>>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>>
 No, the ldap server is not protected by ssl.

 Greetings.


 El 07/03/17 a las 11:42, Richard Vézina escribió:

 Is your ldap server protected by ssl? If so you have to think to change
 port...

 Richard

 On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz <
 carlos.caball...@cfg.jovenclub.cu> wrote:

> Hi, I am trying to include ldap authentication to my app, and for
> this, i am using this code:
>
> auth.settings.login_methods.append(ldap_auth(
> mode='uid',
> server='10.6.xx.xx',
> base_dn='dc=comp',
> filterstr='&(objectClass=inetOrgPerson)',
> logging_level='debug'))
>
> (note: The Original server and base_dn values are changed in this
> example. I also have tried with and without the filterstr option)
>
> But I can't login with any ldap user, and the logs only say:
>
> DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False]
> custom_scope: [subtree] manage_groups: [False]
> INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap connection
>
> I Debug the ladp_auth module, and for some reason it hangs on the line
> 314 ( con.simple_bind_s(dn, password)) without throw any error.
>
> If it helps, I also have tried this code and works as expected
> returning the ldap user data:
>
> import ldap
> ldap_server="10.6.xx.xx"
> username = "auser"
> base_dn = "dc=comp"
>
> query = "(uid=%s)" % username
> con = ldap.initialize('ldap://'+ldap_server)
>
> result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
> print result
>
>
> Any help or idea?
>
> Greetings.
>
>
> --
> 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

[web2py] how to override "select" method?

2017-03-09 Thread Jurgis Pralgauskis
Hi, 

I want to have extra features for select(..)
And the codebase is already quite big -- imo best would be to implement the 
features transparently...

I guess I could make derivative of Set class
and override __call__ and select (and maybe _select) If I need this only 
for reading information?

or should I think of making/deriving Adapter (in my case Postgre and maybe 
Sqlite)?


ps.:
The features I want to have:
 - our system stores translations for names of different items from 
different tables...  And I  decorate query and args for select(..) on the 
fly  (src 

)
 - virtual fields would know what extra  fields/Expressions they need (src 

)

-- 
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: {Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Richard Vézina
You may try the SSL port 636 (
http://www.openldap.org/faq/data/cache/185.html)


You may realise that it actually available...

Richard

On Thu, Mar 9, 2017 at 12:53 PM, Carlos Cesar Caballero Díaz <
carlos.caball...@cfg.jovenclub.cu> wrote:

> I completely agree, and I have warned to the sysadmin, but is not my
> network, so...
>
> Greetings.
>
> El 09/03/17 a las 12:26, Richard Vézina escribió:
>
> Hello Carlos,
>
> auth_ldap is difficult to put in place because as you mention it doesn't
> provide proper feedback when something goes wrong...
>
> Note: If you access localhost instance of LDAP it may be ok to not use SSL
> protected service, but other than that you want to use 636 port (if I
> recall) and SSL protected connection, or the username and password can be
> access in clear text by sniffing the network...
>
> Richard
>
> On Thu, Mar 9, 2017 at 12:02 PM, Carlos Cesar Caballero Díaz <
> carlos.caball...@cfg.jovenclub.cu> wrote:
>
>> Hi Richard,
>>
>> I am connecting against an OpenLDAP server, and here is a lot of services
>> running against it (proxy, email, nextcloud, dolibarr, a few dozen of
>> Ubuntu PCs and others).
>>
>> After a more accurate debugging I release that simple_bind_s() was
>> throwing an invalid credentials error (will be good to add a a warning or
>> something in logs).
>>
>> I start trying with different options and this works (it seems that the
>> ldap server was not using a standard OpenLdap structure, but i don't known
>> too much about that):
>>
>> auth.settings.login_methods.append(ldap_auth(
>> mode='custom', server='10.6.xx.xx',
>> base_dn='dc=comp',
>> username_attrib='uid',
>> custom_scope='subtree',
>> ))
>>
>> So, the problem is solved and is working without problems. Many thanks.
>>
>>
>> Greetings.
>>
>> El 07/03/17 a las 13:40, Richard Vézina escribió:
>>
>> Hello Carlos,
>>
>> You can try to make simple bind with python ldap lib first, make sure
>> user, base_dn is good, you will get more feedback then with ldap_auth
>>
>> Depending of the ldap server implementation that you try to reach you may
>> fall on ldap_auth issue as not all part of the ldap_auth is well testing I
>> guess, there is comment in the code saying that, so...
>>
>> Do you connect to Active Directory? open_ldap... Is the LDAP server
>> properly configure if you use to put open_ldap in place by yourself for
>> instance, are you able to use LDAP for authentication with other software
>> solution??
>>
>> Richard
>>
>> On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz <
>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>
>>> No, the ldap server is not protected by ssl.
>>>
>>> Greetings.
>>>
>>>
>>> El 07/03/17 a las 11:42, Richard Vézina escribió:
>>>
>>> Is your ldap server protected by ssl? If so you have to think to change
>>> port...
>>>
>>> Richard
>>>
>>> On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz <
>>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>>
 Hi, I am trying to include ldap authentication to my app, and for this,
 i am using this code:

 auth.settings.login_methods.append(ldap_auth(
 mode='uid',
 server='10.6.xx.xx',
 base_dn='dc=comp',
 filterstr='&(objectClass=inetOrgPerson)',
 logging_level='debug'))

 (note: The Original server and base_dn values are changed in this
 example. I also have tried with and without the filterstr option)

 But I can't login with any ldap user, and the logs only say:

 DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False]
 custom_scope: [subtree] manage_groups: [False]
 INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap connection

 I Debug the ladp_auth module, and for some reason it hangs on the line
 314 ( con.simple_bind_s(dn, password)) without throw any error.

 If it helps, I also have tried this code and works as expected
 returning the ldap user data:

 import ldap
 ldap_server="10.6.xx.xx"
 username = "auser"
 base_dn = "dc=comp"

 query = "(uid=%s)" % username
 con = ldap.initialize('ldap://'+ldap_server)

 result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
 print result


 Any help or idea?

 Greetings.


 --
 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 *MailScanner ha detectado un intento de fraude
 en la siguiente página web "groups.google.com". No confíe en esta página
 web:* *MailScanner ha detectado un intento de fraude 

{Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Carlos Cesar Caballero Díaz
I completely agree, and I have warned to the sysadmin, but is not my 
network, so...


Greetings.


El 09/03/17 a las 12:26, Richard Vézina escribió:

Hello Carlos,

auth_ldap is difficult to put in place because as you mention it 
doesn't provide proper feedback when something goes wrong...


Note: If you access localhost instance of LDAP it may be ok to not use 
SSL protected service, but other than that you want to use 636 port 
(if I recall) and SSL protected connection, or the username and 
password can be access in clear text by sniffing the network...


Richard

On Thu, Mar 9, 2017 at 12:02 PM, Carlos Cesar Caballero Díaz 
> wrote:


Hi Richard,

I am connecting against an OpenLDAP server, and here is a lot of
services running against it (proxy, email, nextcloud, dolibarr, a
few dozen of Ubuntu PCs and others).

After a more accurate debugging I release that simple_bind_s() was
throwing an invalid credentials error (will be good to add a a
warning or something in logs).

I start trying with different options and this works (it seems
that the ldap server was not using a standard OpenLdap structure,
but i don't known too much about that):

auth.settings.login_methods.append(ldap_auth(
mode='custom', server='10.6.xx.xx',
base_dn='dc=comp',
username_attrib='uid',
custom_scope='subtree',
))

So, the problem is solved and is working without problems. Many
thanks.


Greetings.


El 07/03/17 a las 13:40, Richard Vézina escribió:

Hello Carlos,

You can try to make simple bind with python ldap lib first, make
sure user, base_dn is good, you will get more feedback then with
ldap_auth

Depending of the ldap server implementation that you try to reach
you may fall on ldap_auth issue as not all part of the ldap_auth
is well testing I guess, there is comment in the code saying
that, so...

Do you connect to Active Directory? open_ldap... Is the LDAP
server properly configure if you use to put open_ldap in place by
yourself for instance, are you able to use LDAP for
authentication with other software solution??

Richard

On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz
> wrote:

No, the ldap server is not protected by ssl.

Greetings.


El 07/03/17 a las 11:42, Richard Vézina escribió:

Is your ldap server protected by ssl? If so you have to
think to change port...

Richard

On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz
> wrote:

Hi, I am trying to include ldap authentication to my
app, and for this, i am using this code:

auth.settings.login_methods.append(ldap_auth(
mode='uid',
server='10.6.xx.xx',
base_dn='dc=comp',
filterstr='&(objectClass=inetOrgPerson)',
logging_level='debug'))

(note: The Original server and base_dn values are
changed in this example. I also have tried with and
without the filterstr option)

But I can't login with any ldap user, and the logs only say:

DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user:
[False] custom_scope: [subtree] manage_groups: [False]
INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap
connection

I Debug the ladp_auth module, and for some reason it
hangs on the line 314 ( con.simple_bind_s(dn, password))
without throw any error.

If it helps, I also have tried this code and works as
expected returning the ldap user data:

import ldap
ldap_server="10.6.xx.xx"
username = "auser"
base_dn = "dc=comp"

query = "(uid=%s)" % username
con = ldap.initialize('ldap://'+ldap_server)

result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
print result


Any help or idea?

Greetings.


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

Re: {Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Richard Vézina
Hello Carlos,

auth_ldap is difficult to put in place because as you mention it doesn't
provide proper feedback when something goes wrong...

Note: If you access localhost instance of LDAP it may be ok to not use SSL
protected service, but other than that you want to use 636 port (if I
recall) and SSL protected connection, or the username and password can be
access in clear text by sniffing the network...

Richard

On Thu, Mar 9, 2017 at 12:02 PM, Carlos Cesar Caballero Díaz <
carlos.caball...@cfg.jovenclub.cu> wrote:

> Hi Richard,
>
> I am connecting against an OpenLDAP server, and here is a lot of services
> running against it (proxy, email, nextcloud, dolibarr, a few dozen of
> Ubuntu PCs and others).
>
> After a more accurate debugging I release that simple_bind_s() was
> throwing an invalid credentials error (will be good to add a a warning or
> something in logs).
>
> I start trying with different options and this works (it seems that the
> ldap server was not using a standard OpenLdap structure, but i don't known
> too much about that):
>
> auth.settings.login_methods.append(ldap_auth(
> mode='custom', server='10.6.xx.xx',
> base_dn='dc=comp',
> username_attrib='uid',
> custom_scope='subtree',
> ))
>
> So, the problem is solved and is working without problems. Many thanks.
>
>
> Greetings.
>
> El 07/03/17 a las 13:40, Richard Vézina escribió:
>
> Hello Carlos,
>
> You can try to make simple bind with python ldap lib first, make sure
> user, base_dn is good, you will get more feedback then with ldap_auth
>
> Depending of the ldap server implementation that you try to reach you may
> fall on ldap_auth issue as not all part of the ldap_auth is well testing I
> guess, there is comment in the code saying that, so...
>
> Do you connect to Active Directory? open_ldap... Is the LDAP server
> properly configure if you use to put open_ldap in place by yourself for
> instance, are you able to use LDAP for authentication with other software
> solution??
>
> Richard
>
> On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz <
> carlos.caball...@cfg.jovenclub.cu> wrote:
>
>> No, the ldap server is not protected by ssl.
>>
>> Greetings.
>>
>>
>> El 07/03/17 a las 11:42, Richard Vézina escribió:
>>
>> Is your ldap server protected by ssl? If so you have to think to change
>> port...
>>
>> Richard
>>
>> On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz <
>> carlos.caball...@cfg.jovenclub.cu> wrote:
>>
>>> Hi, I am trying to include ldap authentication to my app, and for this,
>>> i am using this code:
>>>
>>> auth.settings.login_methods.append(ldap_auth(
>>> mode='uid',
>>> server='10.6.xx.xx',
>>> base_dn='dc=comp',
>>> filterstr='&(objectClass=inetOrgPerson)',
>>> logging_level='debug'))
>>>
>>> (note: The Original server and base_dn values are changed in this
>>> example. I also have tried with and without the filterstr option)
>>>
>>> But I can't login with any ldap user, and the logs only say:
>>>
>>> DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False]
>>> custom_scope: [subtree] manage_groups: [False]
>>> INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap connection
>>>
>>> I Debug the ladp_auth module, and for some reason it hangs on the line
>>> 314 ( con.simple_bind_s(dn, password)) without throw any error.
>>>
>>> If it helps, I also have tried this code and works as expected returning
>>> the ldap user data:
>>>
>>> import ldap
>>> ldap_server="10.6.xx.xx"
>>> username = "auser"
>>> base_dn = "dc=comp"
>>>
>>> query = "(uid=%s)" % username
>>> con = ldap.initialize('ldap://'+ldap_server)
>>>
>>> result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
>>> print result
>>>
>>>
>>> Any help or idea?
>>>
>>> Greetings.
>>>
>>>
>>> --
>>> 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 *MailScanner ha detectado un intento de fraude
>>> en la siguiente página web "groups.google.com". No confíe en esta página
>>> web:* *MailScanner ha detectado un intento de fraude en la siguiente
>>> p�gina web "groups.google.com". No conf�e en esta p�gina web:* *MailScanner
>>> ha detectado un intento de fraude en la siguiente página web
>>> "groups.google.com". No confíe en esta página web:* *MailScanner ha
>>> detectado un intento de fraude en la siguiente p�gina web
>>> "groups.google.com". No conf�e en esta p�gina web:*
>>> https://groups.google.com/d/optout .
>>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - 

Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Jim Steil
Holy Cow!  I got it working.

Not exactly what you specified Anthony, but got me on the right track

With your method I got this traceback:

Traceback (most recent call last):
  File "C:\dev\web2py\gluon\restricted.py", line 216, in restricted
exec(ccode, environment)
  File "C:\dev\web2py\applications\connect\controllers/user.py:index",
line 281, in 
  File "C:\dev\web2py\gluon\globals.py", line 405, in 
self._caller = lambda f: f()
  File "C:\dev\web2py\gluon\tools.py", line 4299, in f
return action(*a, **b)
  File "C:\dev\web2py\applications\connect\controllers/user.py:index",
line 72, in index
AttributeError: 'MySQL' object has no attribute 'CONCAT'


However, I then tried this:

queries = [db.auth_user.id > 0]
queries.append((db.auth_user.firstLast.contains(searchText)) |
  (db.auth_user.lastFirst.contains(searchText)) |
  ("CONCAT(first_name, \' \', last_Name) LIKE '%%%s%%'" % (searchText)))
query = reduce(lambda a, b: (a & b), queries)

...and passed the query and it worked.

Much appreciated!

-Jim




On Thu, Mar 9, 2017 at 10:37 AM, Anthony  wrote:

> I haven't tried it, but maybe something like this:
>
> def search(sfields, keywords):
> keywords = keywords.strip().replace("'", "''")
> return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" %
> keywords
>
> grid = SQLFORM.grid(db.mytable, searchable=search)
>
> Actually, although not documented as part of the public API, each adapter
> has a CONCAT method, which produces the correct syntax for each database.
> So, the last line of the search function above could be:
>
> return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', ' ',
> 'last_name'), keywords)
>
> Anthony
>
> On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:
>>
>> Hi
>>
>> I have a search form where the user types in generic search text.  I want
>> to be able to return to them a list of matching users.
>>
>> Sample Data
>>
>>   First   Last
>> - --  --
>> 1 Jim Sanders
>> 2 BillVan Der Wall
>> 3 JohnSt James
>> 4 Peter   Williams
>> 5 Jim Hensen
>> 6 JohnAdams
>> 7 William Tell
>> 8 AdamJohnson
>>
>>
>> Based on the data entered in the search box, these records should be
>> returned
>>
>>
>>   Search Text  Rows Returned
>> -  --
>> 1 Jim  1, 5
>> 2 John 3, 6, 8
>> 3 Adam 6, 8
>> 4 Bill 2
>> 5 Jim Sanders  1
>> 6 Adam John8
>> 7 John St James3
>>
>>
>> I can't seem to come up with a query or anything to make this happen.
>> With SQL I might to this:
>>
>> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name LIKE
>> \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' % (search_text,
>> search_text, search_text)
>>
>> But, I want to build this as a query for SQLFORM.grid.
>>
>> Anyone have any ideas?
>>
>> -Jim
>>
>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/3RnGSoUbxxY/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


{Disarmed} Re: [web2py] problem with ldap authentication

2017-03-09 Thread Carlos Cesar Caballero Díaz

Hi Richard,

I am connecting against an OpenLDAP server, and here is a lot of 
services running against it (proxy, email, nextcloud, dolibarr, a few 
dozen of Ubuntu PCs and others).


After a more accurate debugging I release that simple_bind_s() was 
throwing an invalid credentials error (will be good to add a a warning 
or something in logs).


I start trying with different options and this works (it seems that the 
ldap server was not using a standard OpenLdap structure, but i don't 
known too much about that):


auth.settings.login_methods.append(ldap_auth(
mode='custom', server='10.6.xx.xx',
base_dn='dc=comp',
username_attrib='uid',
custom_scope='subtree',
))

So, the problem is solved and is working without problems. Many thanks.


Greetings.


El 07/03/17 a las 13:40, Richard Vézina escribió:

Hello Carlos,

You can try to make simple bind with python ldap lib first, make sure 
user, base_dn is good, you will get more feedback then with ldap_auth


Depending of the ldap server implementation that you try to reach you 
may fall on ldap_auth issue as not all part of the ldap_auth is well 
testing I guess, there is comment in the code saying that, so...


Do you connect to Active Directory? open_ldap... Is the LDAP server 
properly configure if you use to put open_ldap in place by yourself 
for instance, are you able to use LDAP for authentication with other 
software solution??


Richard

On Tue, Mar 7, 2017 at 11:50 AM, Carlos Cesar Caballero Díaz 
> wrote:


No, the ldap server is not protected by ssl.

Greetings.


El 07/03/17 a las 11:42, Richard Vézina escribió:

Is your ldap server protected by ssl? If so you have to think to
change port...

Richard

On Tue, Mar 7, 2017 at 10:32 AM, Carlos Cesar Caballero Díaz
> wrote:

Hi, I am trying to include ldap authentication to my app, and
for this, i am using this code:

auth.settings.login_methods.append(ldap_auth(
mode='uid',
server='10.6.xx.xx',
base_dn='dc=comp',
filterstr='&(objectClass=inetOrgPerson)',
logging_level='debug'))

(note: The Original server and base_dn values are changed in
this example. I also have tried with and without the
filterstr option)

But I can't login with any ldap user, and the logs only say:

DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False]
custom_scope: [subtree] manage_groups: [False]
INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap
connection

I Debug the ladp_auth module, and for some reason it hangs on
the line 314 ( con.simple_bind_s(dn, password)) without throw
any error.

If it helps, I also have tried this code and works as
expected returning the ldap user data:

import ldap
ldap_server="10.6.xx.xx"
username = "auser"
base_dn = "dc=comp"

query = "(uid=%s)" % username
con = ldap.initialize('ldap://'+ldap_server)

result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
print result


Any help or idea?

Greetings.


-- 
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 *MailScanner ha detectado un intento
de fraude en la siguiente p�gina web "groups.google.com".
/No/ conf�e en esta p�gina web:* *MailScanner ha detectado un
intento de fraude en la siguiente página web
"groups.google.com". /No/ confíe en esta página web:*
*MailScanner ha detectado un intento de fraude en la
siguiente p�gina web "groups.google.com". /No/ conf�e en esta
p�gina web:* 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" 

[web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Anthony
I haven't tried it, but maybe something like this:

def search(sfields, keywords):
keywords = keywords.strip().replace("'", "''")
return "CONCAT(first_name, ' ', last_name) LIKE '%%%s%%'" % keywords

grid = SQLFORM.grid(db.mytable, searchable=search)

Actually, although not documented as part of the public API, each adapter 
has a CONCAT method, which produces the correct syntax for each database. 
So, the last line of the search function above could be:

return "%s LIKE '%%%s%%'" % (db._adapter.CONCAT('first_name', ' ', 
'last_name'), keywords)

Anthony

On Tuesday, March 7, 2017 at 11:00:04 PM UTC-5, Jim S wrote:
>
> Hi
>
> I have a search form where the user types in generic search text.  I want 
> to be able to return to them a list of matching users.
>
> Sample Data
>
>   First   Last
> - --  --
> 1 Jim Sanders
> 2 BillVan Der Wall
> 3 JohnSt James
> 4 Peter   Williams
> 5 Jim Hensen
> 6 JohnAdams
> 7 William Tell
> 8 AdamJohnson
>  
>
> Based on the data entered in the search box, these records should be 
> returned
>
>   
>   Search Text  Rows Returned
> -  --
> 1 Jim  1, 5
> 2 John 3, 6, 8
> 3 Adam 6, 8
> 4 Bill 2
> 5 Jim Sanders  1
> 6 Adam John8
> 7 John St James3
>  
>
> I can't seem to come up with a query or anything to make this happen. 
>  With SQL I might to this:
>
> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name LIKE 
> \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' % (search_text, 
> search_text, search_text)
>
> But, I want to build this as a query for SQLFORM.grid.  
>
> Anyone have any ideas?
>
> -Jim
>
>

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Anthony
On Thursday, March 9, 2017 at 9:05:27 AM UTC-5, Áureo Dias Neto wrote:
>
> you can use the 'like' condition in w2p, something like this:
>
>
> query = ((db.auth_user.like('%s%' form.var.name) or (db.auth_user.like('%s%' 
> form.var.name
>

You cannot build a query from the table object alone -- you must specify a 
field (e.g., db.auth_user.first_name rather than just db.auth_user).

Anthony

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


Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Jim S
That doesn't work because if I put in 'Tom Jones' into my search it doesn't 
match either first name or last name.  Only matches if I concatenate the 
first and last name fields together.

-Jim

On Thursday, March 9, 2017 at 8:05:27 AM UTC-6, Áureo Dias Neto wrote:
>
> you can use the 'like' condition in w2p, something like this:
>
>
> query = ((db.auth_user.like('%s%' form.var.name) or (db.auth_user.like('%s%' 
> form.var.name
>
> 2017-03-09 10:52 GMT-03:00 Jim S :
>
>> That will work, but I'm only wanting 1 form field.  Basically want to 
>> implement a CONCAT function like in the sample SQL Statement I mentioned 
>> above.
>>
>> -Jim
>>
>>
>> On Thursday, March 9, 2017 at 7:47:16 AM UTC-6, Áureo Dias Neto wrote:
>>>
>>> or this:
>>>
>>> name = form.vars.name
>>> lastname = form.vars.lastname
>>>
>>> query = ((db.auth_user == name) or (db.auth_user == lastname))
>>>
>>> form = SQLFORM.grid(query)
>>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Áureo Dias Neto
you can use the 'like' condition in w2p, something like this:


query = ((db.auth_user.like('%s%' form.var.name) or (db.auth_user.like('%s%'
form.var.name

2017-03-09 10:52 GMT-03:00 Jim S :

> That will work, but I'm only wanting 1 form field.  Basically want to
> implement a CONCAT function like in the sample SQL Statement I mentioned
> above.
>
> -Jim
>
>
> On Thursday, March 9, 2017 at 7:47:16 AM UTC-6, Áureo Dias Neto wrote:
>>
>> or this:
>>
>> name = form.vars.name
>> lastname = form.vars.lastname
>>
>> query = ((db.auth_user == name) or (db.auth_user == lastname))
>>
>> form = SQLFORM.grid(query)
>>
> --
> 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] Re: Query auth_user over first and last names in one query

2017-03-09 Thread Jim S
That will work, but I'm only wanting 1 form field.  Basically want to 
implement a CONCAT function like in the sample SQL Statement I mentioned 
above.

-Jim

On Thursday, March 9, 2017 at 7:47:16 AM UTC-6, Áureo Dias Neto wrote:
>
> or this:
>
> name = form.vars.name
> lastname = form.vars.lastname
>
> query = ((db.auth_user == name) or (db.auth_user == lastname))
>
> form = SQLFORM.grid(query)
>

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Áureo Dias Neto
or this:

name = form.vars.name
lastname = form.vars.lastname

query = ((db.auth_user == name) or (db.auth_user == lastname))

form = SQLFORM.grid(query)

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Áureo Dias Neto
name = form.vars.name
lastname = form.vars.lastname

query = db((db.auth_user == name) or (db.auth_user == lastname)).select()

form = SQLFORM.grid(query)

-- 
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 auth_user over first and last names in one query

2017-03-09 Thread Jim S
Bump - didn't get any takers the first time.   Wondering if anyone has any 
ideas...

-Jim


On Tuesday, March 7, 2017 at 10:00:04 PM UTC-6, Jim S wrote:
>
> Hi
>
> I have a search form where the user types in generic search text.  I want 
> to be able to return to them a list of matching users.
>
> Sample Data
>
>   First   Last
> - --  --
> 1 Jim Sanders
> 2 BillVan Der Wall
> 3 JohnSt James
> 4 Peter   Williams
> 5 Jim Hensen
> 6 JohnAdams
> 7 William Tell
> 8 AdamJohnson
>  
>
> Based on the data entered in the search box, these records should be 
> returned
>
>   
>   Search Text  Rows Returned
> -  --
> 1 Jim  1, 5
> 2 John 3, 6, 8
> 3 Adam 6, 8
> 4 Bill 2
> 5 Jim Sanders  1
> 6 Adam John8
> 7 John St James3
>  
>
> I can't seem to come up with a query or anything to make this happen. 
>  With SQL I might to this:
>
> 'SELECT * FROM auth_user WHERE first_name LIKE \'%s*\' OR last_name LIKE 
> \'%s*\' OR concat(first_name, ' ', last_name) LIKE \'%s*\'' % (search_text, 
> search_text, search_text)
>
> But, I want to build this as a query for SQLFORM.grid.  
>
> Anyone have any ideas?
>
> -Jim
>
>

-- 
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: Unpickling error

2017-03-09 Thread Maurice Waka
Sorry. I discovered that my database was corrupted

On Mar 6, 2017 23:20, "Jordan Myers"  wrote:

> It would help if you gave us some more context. Where does this error
> occur? What are you trying to do? The error seems to be when you are
> creating tables in the file db2.py, what are the contents of this file?
>
> On Monday, March 6, 2017 at 10:08:04 AM UTC-6, Maurice Waka wrote:
>>
>> Am getting this web2py error in Ubuntu:
>>
>> Traceback (most recent call last):
>>   File "/home/mwk/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "/home/mwk/web2py/applications/britamintell/models/db2.py", line 15, 
>> in 
>> auth.signature)
>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/base.py", line 834, in 
>> define_table
>> table = self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/base.py", line 873, in 
>> lazy_define_table
>> polymodel=polymodel)
>>   File "/home/mwk/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
>> 500, in create_table
>> sql_fields_old = pickle.load(tfile)UnpicklingError: invalid load key, 
>> '�'.
>>
>> what is this and how do i resolve 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/FyHFlywmRdg/unsubscribe.
> To unsubscribe from this group and all its topics, 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.