[web2py] Is web2py incompatible with 2nd generation Google Cloud SQL ?

2017-04-24 Thread Karoly Kantor
Dear Sirs,

I can connect my Google App Engine web2p app to a first generation GAE SQL 
instance, but not to a second generation one. I was talking to a cloud SQL 
support person on another forum and he said, I quote:

"Your first generation CloudSQL instance has the app name as an authorized 
user, the second generation doesn’t. Your logs show connection errors to 
the instance from a user without password. "

So my question is: Where do I set a database user name and password in 
web2p to connect to a 2nd Gen Google SQL instance, if it is possible at 
all? I see this option with other connection strings in the doc, but not 
for Google.

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.


[web2py] Open uploaded files in some editor.

2017-04-24 Thread akshay055kumar
Hello,

I am creating an SQLFORM which asks user to upload their files.

this is the table defination:
db.define_table('scripts',
 Field('script', 'upload',requires=IS_NOT_EMPTY(error_message='Upload some 
file'),
 Field('category',requires=IS_IN_SET(['Ruby', 'Python', 'Linux'])),
 format='%(name)s')

and this is the controller function:
def upload_script():
form = SQLFORM(db.scripts)
if form.process().accepted:
redirect(URL('upload_script'))
return locals()

Now i want users to give an option that they should be able to open 
uploaded files in some editor and should be able to make changes in the 
content of file and those changes should be reflected on original file 
after saving the file.

How can we do that??

Let me make it clear again that i am not talking about editing the form, i 
want to edit the file data and that also in some webpage.

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] SQLFORM.grid question

2017-04-24 Thread Jim Russell
Hi all.

I'm having an issue with an SQLFORM.gird query. I have a table where one of 
the columns references another table. Here are the table definitions:

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='reference osrwlpooltype'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

db.define_table('osrwlpooltype',
Field('id', type='id'),
Field('wtype', type='string', length=32, unique=True))

So osrwhitelistpool field wltype references osrwlpooltype field wtype.

When I run a simple query, just requesting the whole table I get an error Query 
Not Supported: invalid literal for long() with base 10: 'ALL'

I'm not sure why it thinks that field should be a long.

Here are the table definitions directly from the DB:

osrtest=# \d osrwlpooltype
Table "osrtest.osrwlpooltype"
 Column | Type  |Modifiers
+---+--
 id | integer   | not null default 
nextval('osrwlpooltypeseqpk'::regclass)
 wtype  | character varying(32) | not null
Indexes:
"osrwlpooltype_pkey" PRIMARY KEY, btree (id)
"osrwlpooltype_wtype_key" UNIQUE CONSTRAINT, btree (wtype)
Referenced by:
TABLE "osrwhitelistpool" CONSTRAINT "osrwhitelistpool_wltype_fkey" 
FOREIGN KEY (wltype) REFERENCES osrwlpooltype(wtype)

osrtest=# \d osrwhitelistpool
Table "osrtest.osrwhitelistpool"
  Column  |Type |  Modifiers
--+-+-
 id   | integer | not null default 
nextval('osrwhitelistpoolseqpk'::regclass)
 pool | character varying(255)  | not null
 wltype   | character varying   |
 comments | character varying(255)  |
 ctime| timestamp without time zone | default now()
Indexes:
"osrwhitelistpool_pkey" PRIMARY KEY, btree (id)
"osrwhitelistpool_pool_key" UNIQUE CONSTRAINT, btree (pool)
Foreign-key constraints:
"osrwhitelistpool_wltype_fkey" FOREIGN KEY (wltype) REFERENCES 
osrwlpooltype(wtype)



I changed the table definition in db.py to 

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='string'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

and it worked to display it. But then when I edit a record it is just a 
free form text field instead of a dropdown with the wtype field from 
osrwlpooltype.

Any ideas what I'm doing wrong?

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


[web2py] Re: Forms with readonly fields

2017-04-24 Thread Anthony
Right. I think I didn't run into that issue because the original values in 
the updated record already satisfied the validation criteria.

Note, there was another problem with the solution allowing a malicious user 
to pass back altered values for the readonly fields, so I updated the code 
to an an onvalidation function that removes the readonly field from 
form.vars to prevent them from being written to the database.

Anthony

On Sunday, April 23, 2017 at 7:49:43 PM UTC-4, Joe Barnhart wrote:
>
> Hi Anthony --
>
> After some digging, I think I understand the flow and why this is required.
>
> When the form is built, one of the byproducts is to create a widget for 
> each field and preset that widget with the information it needs to do 
> validation (i.e. the 'requires' of the field is copied to the widget).  By 
> the time the "form = SQLFORM(...)" is executed, the widgets are built and 
> they contain the requirements of the fields.
>
> The selector fields using the IS_IN_SET() validator will fail if the field 
> doesn't contain a valid selection -- irrespective of whether that field is 
> "read only" or not.  This check is done at the XML level and does not care 
> about any of the settings of the Field objects at the time the check is 
> done.  So nothing done to the fields with respect to making them writable 
> of not can have any effect at this level.
>
> By putting the "requires=[]" or even "requires=None" in the custom widgets 
> AFTER they are built by SQLFORM, we turn off this unwanted behavior and 
> ensure that readonly fields cannot cause a validation failure.  I've 
> stepped through it both with and without this change, and the change is 
> definitely essential for SELECT objects.  Now, it could be limited to only 
> SELECT objects, but there is no harm in broadening it to all widgets.
>
> Warm regards,
>
> Joe
>
>
> On Saturday, April 1, 2017 at 12:51:55 PM UTC-7, Anthony wrote:
>>
>> On Friday, March 31, 2017 at 5:41:49 PM UTC-4, Joe Barnhart wrote:
>>>
>>> Anthony --
>>>
>>> One more tiny but not insignificant detail...
>>>
>>> I found I had to add "requires=[]" to the custom.widget:
>>>
>>> [form.custom.widget[f.name].update(_readonly=True, requires=[]) for 
>>> f in readonly_fields]
>>>
>>> Otherwise, the field keeps the 'requires' of the original Field and the 
>>> check fails.  The above solution is working very well!
>>>
>>
>> Hmm, I didn't have that problem. Do you have an example model that 
>> exhibited that behavior?
>>
>> 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] Re: btw: great job

2017-04-24 Thread Carlos Kitu
Yeah! 
Awesome product and support. So good that I seldom need to make questions 
in this forum.
Thank you and best regards.

El domingo, 23 de abril de 2017, 5:35:29 (UTC+2), lucas escribió:
>
> hey everyone,
>
> I think we should recognize and congratulate Massimo and the developers of 
> web2py.  its been nearly a year since the last production update and the 
> whole platform is just excellent.  
>
> it is the most stable platform I've ever coded in.  I can literally dream 
> it and code it like whisping magic off my fingers.  its like programming on 
> a cloud.  I've been programming in web2py since 2009 and it really has been 
> wonderful.  my end users love it too, not in the same way I do though.
>
> so lets tip our hats to web2py and appreciate its greatness, its 
> stability, its power, and scalability.
>
> sincerely, lucas
>

-- 
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: conditional block insert

2017-04-24 Thread Pierre
found the bogue.a nasty supernumerary {{pass}}  in the sidebar.html

thank you  guys for your patience and perseverence...



-- 
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: table already exists; 'Rows' object has no attribute 'fields'

2017-04-24 Thread Dave S


On Saturday, April 22, 2017 at 9:49:26 PM UTC-7, pbreit wrote:
>
> I reinstalled Mac OS Sierra which appears to have fixed the problems.
>

That seems like a rather drastic solution.  Perhaps there were issues with 
paths variables pointing in various directions as new replaced old (FSVO 
"replace").

/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: Field date error

2017-04-24 Thread Dave S


On Sunday, April 23, 2017 at 9:04:09 PM UTC-7, Winter Kryz wrote:
>
> Hello everybody,
>
> I have a table
> db.define_table('Person',
> Field('last_name', 'string'),
> Field('first_name', 'string'),
> Field('nationality','string'),
> Field('birth_date', 'date', requires = 
> IS_NOT_EMPTY(error_message="select a date")),
> )
>
>
> and when I try to put that into that table I get this error. I tried to 
> drop the table, clean the past data but no luck
>
>  ValueError: invalid literal for int() with base 10: '06/04/2017'
>
>
> Any ideas would be appreciated?
>
>
A mis-match between the locale date format and the default format expected 
by the date widget?  You don't specifiy a date format in your field 
definition.  (One sometimes has issues also with the client and server 
locales differing.)

/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 do I run the web2py scheduler under the models directory

2017-04-24 Thread Dave S


On Monday, April 24, 2017 at 12:40:00 PM UTC-7, Anthony wrote:
>
> Yeah, don't put the queue_task code in the model, as it will get executed 
> every time the model is executed. If you just need to set up the task once, 
> you can do so by directly inserting a record in the scheduler_task table 
> via appadmin or by calling queue_task() in a web2py shell. Or you could 
> create a special restricted-access controller function and visit its URL 
> just once to schedule the task.
>


An example of the latter approach is at 


The pull request has been merged, and should be visible on the web2py 
website when the next release is out of the gate.

/dps

 

> On Monday, April 24, 2017 at 3:36:53 PM UTC-4, Kenneth Ban wrote:
>>
>> Hi,
>>
>> I'm trying to set up the web2py scheduler to run an hourly task and put 
>> the following code as scheduler.py in the models directory:
>>
>> from gluon.scheduler import Scheduler
>>
>>
>> def log():
>> 
>> logging.warning('is when this event was logged.')
>>
>>
>> import logging
>>
>>
>> logger = logging.getLogger("web2py.app.welcome")
>>
>> logger.setLevel(logging.DEBUG)
>> 
>> myscheduler = Scheduler(db,tasks=dict(log=log))
>>
>> myscheduler.queue_task('log',period=3600,repeats=0,immediate=True)
>>
>> However I find that each time I visit the website, it schedules a new 
>> task, resulting in multiple tasks of the same nature (i.e. period=3600, 
>> repeats=0).
>>
>> How do I run the set up once so that I will only get a single repeating 
>> task queued in the web2py scheduler.
>>
>> Thanks in advance for any help!
>>
>> Cheers,
>> Kenneth
>>  
>>
>>
>>

-- 
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: force redirect after expiration login session expiration time

2017-04-24 Thread Dave S


On Monday, April 24, 2017 at 12:49:56 PM UTC-7, Anthony wrote:
>
> On Monday, April 24, 2017 at 6:52:16 AM UTC-4, A3 wrote:
>>
>> Thanks, I thought there was a standard solution.
>>
>
> This is not a very common pattern except on highly secure websites (e.g., 
> banking).
>

Indeed, a common use of a webpage is as a reference while you're working on 
a relevant task in another window,
and having it wiped out because of a timer would be annoying.  Tradeoffs 
are everywhere.

 
>
>> Unfortunately it doesn't work:  
>> I hoped it worked but it seems that the ajax call keeps the user logged 
>> in.
>>
>>
That's also why an html refresh header wouldn't work :-)

Is it possible to read the time left from auth.settings.expiration  ?
>>
>
> Why not just use the value of auth.settings.expiration directly in your 
> Javascript? When the page first loads, you want to force the user to log 
> out if that much time expires with no activity, right?
>

Sounds good.  There's just that little  matter that some of us need to be 
reminded of the ways to pass python values to Javascript.

/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: force redirect after expiration login session expiration time

2017-04-24 Thread Anthony
On Monday, April 24, 2017 at 6:52:16 AM UTC-4, A3 wrote:
>
> Thanks, I thought there was a standard solution.
>

This is not a very common pattern except on highly secure websites (e.g., 
banking).
 

> Unfortunately it doesn't work:  
> I hoped it worked but it seems that the ajax call keeps the user logged in.
>
> Is it possible to read the time left from auth.settings.expiration  ?
>

Why not just use the value of auth.settings.expiration directly in your 
Javascript? When the page first loads, you want to force the user to log 
out if that much time expires with no activity, right?

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] Re: How do I run the web2py scheduler under the models directory

2017-04-24 Thread Anthony
Yeah, don't put the queue_task code in the model, as it will get executed 
every time the model is executed. If you just need to set up the task once, 
you can do so by directly inserting a record in the scheduler_task table 
via appadmin or by calling queue_task() in a web2py shell. Or you could 
create a special restricted-access control function and visit its URL just 
once to schedule the task.

Anthony

On Monday, April 24, 2017 at 3:36:53 PM UTC-4, Kenneth Ban wrote:
>
> Hi,
>
> I'm trying to set up the web2py scheduler to run an hourly task and put 
> the following code as scheduler.py in the models directory:
>
> from gluon.scheduler import Scheduler
>
>
> def log():
> 
> logging.warning('is when this event was logged.')
>
>
> import logging
>
>
> logger = logging.getLogger("web2py.app.welcome")
>
> logger.setLevel(logging.DEBUG)
> 
> myscheduler = Scheduler(db,tasks=dict(log=log))
>
> myscheduler.queue_task('log',period=3600,repeats=0,immediate=True)
>
> However I find that each time I visit the website, it schedules a new 
> task, resulting in multiple tasks of the same nature (i.e. period=3600, 
> repeats=0).
>
> How do I run the set up once so that I will only get a single repeating 
> task queued in the web2py scheduler.
>
> Thanks in advance for any help!
>
> Cheers,
> Kenneth
>  
>
>
>

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


[web2py] How do I run the web2py scheduler under the models directory

2017-04-24 Thread Kenneth Ban
Hi,

I'm trying to set up the web2py scheduler to run an hourly task and put the 
following code as scheduler.py in the models directory:

from gluon.scheduler import Scheduler


def log():

logging.warning('is when this event was logged.')


import logging


logger = logging.getLogger("web2py.app.welcome")

logger.setLevel(logging.DEBUG)

myscheduler = Scheduler(db,tasks=dict(log=log))

myscheduler.queue_task('log',period=3600,repeats=0,immediate=True)

However I find that each time I visit the website, it schedules a new task, 
resulting in multiple tasks of the same nature (i.e. period=3600, 
repeats=0).

How do I run the set up once so that I will only get a single repeating 
task queued in the web2py scheduler.

Thanks in advance for any help!

Cheers,
Kenneth
 


-- 
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: GET queries other than ID

2017-04-24 Thread David Shavers
Sweet, 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: GET queries other than ID

2017-04-24 Thread Anthony
On Monday, April 24, 2017 at 3:15:48 PM UTC-4, David Shavers wrote:
>
> Hey Anthony, 
>
> Thanks for replying. So what you're saying is that the auto generated 
> value for cost_per_night is trying to get me to put in two integers and 
> that the resulting json will be a range withing those two? For example: the 
> link you posted would give me all of the values between 25 and 30?
>

Yes, that is the default set of patterns for numeric fields.

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] Re: conditional block insert

2017-04-24 Thread Anthony
In general, that approach should work, so you'll have to show your code for 
further diagnosis.

Anthony

On Monday, April 24, 2017 at 9:49:04 AM UTC-4, Pierre wrote:
>
> hello everyone,
>
> {{block left_sidebar}}
> {{if auth.has_membership('manager'):}}
>{{include 'manager_sidebar.html'}}
> {{else:}}
>{{include 'sidebar.html'}}
> {{pass}}
> {{end}}
>
> for some reason this doesn't work. It inserts a mixture of the two 
> sidebars. If i move blocks inside of the if same problem?? there seems 
> to be a conflict between the two includes ?
>

-- 
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] conditional block insert

2017-04-24 Thread Anthony
On Monday, April 24, 2017 at 10:27:55 AM UTC-4, Áureo Dias Neto wrote:
>
> is all python code, you can use one '{{' at the begin of code and '}}' at 
> end
>
> {{block left_sidebar
> if auth.has_membership('manager'):
>   include 'manager_sidebar.html'
> else:
>include 'sidebar.html'
> pass
> end}}
>

No, {{block}} and {{include}} are not Python code but special template 
directives, so you cannot write the code as you have above.

In general, it's a good idea if you try things out yourself before 
suggesting them as solutions.

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] Re: GET queries other than ID

2017-04-24 Thread David Shavers
Hey Anthony, 

Thanks for replying. So what you're saying is that the auto generated value for 
cost_per_night is trying to get me to put in two integers and that the 
resulting json will be a range withing those two? For example: the link you 
posted would give me all of the values between 25 and 30?

-- 
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: GET queries other than ID

2017-04-24 Thread Anthony
On Friday, April 21, 2017 at 3:12:00 PM UTC-4, David Shavers wrote:
>
> /room-owner/cost-per-night/{room_owner.cost_per_night.ge}/{
> room_owner.cost_per_night.lt}
> /room-owner/cost-per-night/{room_owner.cost_per_night.ge}/{
> room_owner.cost_per_night.lt}/:field
>

Notice the pattern for cost-per-night (which presumably is a float or 
decimal field) includes placeholders for the lower and upper bounds of a 
range -- so the url must be something like 
/room-owner/cost-per-night/25/30.json.

If you want to specify an exact cost and test for equality, you can create 
your own pattern instead of using the auto-generated patterns:

/room-owner/cost-per-night/{room_owner.cost_per_night.eq}

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] Re: more on @auth.requires

2017-04-24 Thread Anthony
The main issue is not to do the database hit to generate the 
list_of_roles_manger_site until you actually need to check the roles. You 
code below is not ideal because the expensive operation is generating the 
list, and you are generating the list every time the controller file is 
accessed. You should move the code that generates the list inside the 
function that gets called by auth.requires. For example, in a model file, 
module, or even in the controller file, you could have:

def verifica_manager_site():
roles = [query to get roles from the database]
...

(If the above is in a controller, name it __verifica_manager_site, so it 
won't be exposed as an action.)

Then:

@auth.requires(verifica_manager_site)
def myaction():
...

Anthony

On Monday, April 24, 2017 at 11:20:26 AM UTC-4, Andrea Fae' wrote:
>
> As Anthony suggested me (and thank you for his help), I use for example 
> these function to control authorization
>
> @auth.requires(lambda: verifica_manager_site(list_of_roles_manager_site))
>
> At the starting of default.py, where I have the other function that needs 
> authotiation, I putted code to populate "list_of_roles_manager_site" and 
> the function "verifica_manager_site".
> The list is retrieved from database.
>
> Is it the correct place? OR I have to put in another place or create 
> another file..I don't know...
> thanks
>
>

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


Re: {Disarmed} Re: {Disarmed} Re: [web2py] Re: lack of documentation

2017-04-24 Thread Anthony
On Monday, April 24, 2017 at 7:07:29 AM UTC-4, Andrea Fae' wrote:
>
> Yes you are right, but there is something in the book, something in the 
> codeno complete full documentation...managed in only one site. It's 
> like it is...I have to accept this. thanks
>

You don't have to accept it -- you could make some pull requests to the 
book repo. ;-)

-- 
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: Open Sourced dating website

2017-04-24 Thread David Shavers
I've been trying to keep spam accounts to a minimum, but I do agree that I 
should provide a test account for other developers to browse.

Username: alex101
Password: alex101 

-- 
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] IMPORTANT - WEB2PY CONSULTING

2017-04-24 Thread David Shavers
Hey Richard, 

I've been trying to keep spam accounts to a minimum, but I do agree that I 
should provide a test account for other developers to browse.

Username: alex101
Password: alex101 

-- 
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] IMPORTANT - WEB2PY CONSULTING

2017-04-24 Thread Richard Vézina
No offense David, but if I want to see your site I am not going to register
for it... I suggest you allow a lending page without @auth.requires_login()

On Mon, Apr 24, 2017 at 10:55 AM, David Shavers 
wrote:

> Hi, I have a dating website that uses a lot of web2py features. I know
> android and web2py and can help bring people up to speed if they need.
>
> www.jbtus.com
>
> Contact - www.facebook.com/shaversapps
>
> --
> 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: UPDATE BOOTSTRAP VERSION FROM 3 TO 4

2017-04-24 Thread Donald McClymont
I think there are use cases for both sqlform and client side frameworks.  In 
terms of bs4 there seem to be sites that will do a conversion so I would think 
it must be possible to make new form styles for bs4 as was done for bs3?  
Albeit I imagine this is not a particularly fun job it can't be that hard?

Donald

-- 
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: Google SQL Database user and password - where to set?

2017-04-24 Thread Karoly Kantor
More info: This in the log:

DEBUG: connect attempt 4, connection error: Traceback (most recent call 
last): File 
"/base/data/home/apps/e~unidb-project/2.400786701713097994/gluon/packages/dal/pydal/base.py",
 
line 446 
,
 
in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File 
"/base/data/home/apps/e~unidb-project/2.400786701713097994/gluon/packages/dal/pydal/adapters/base.py",
 
line 60 
,
 
in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File 
"/base/data/home/apps/e~unidb-project/2.400786701713097994/gluon/packages/dal/pydal/adapters/google_adapters.py",
 
line 59 
,
 
in __init__ if do_connect: self.reconnect() File 
"/base/data/home/apps/e~unidb-project/2.400786701713097994/gluon/packages/dal/pydal/connection.py",
 
line 104 
,
 
in reconnect self.connection = f() File 
"/base/data/home/apps/e~unidb-project/2.400786701713097994/gluon/packages/dal/pydal/adapters/google_adapters.py",
 
line 57 
,
 
in connector return rdbms.connect(**driver_args) File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/rdbms.py",
 
line 70, in connect password=password) File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 813, in __init__ self.OpenConnection() File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 836, in OpenConnection response = self.MakeRequest('OpenConnection', 
request) File 
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/storage/speckle/python/api/rdbms.py",
 
line 947, in MakeRequest raise _ToDbApiException(response.sql_exception) 
InternalError: (0, u'Not authorized to access instance: 
my-project:europe-west1:sql-instance-1') 

-- 
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: {Disarmed} Re: [web2py] Re: lack of documentation

2017-04-24 Thread Andrea Fae'
I completely agree with you about the book. It's very good written.

Il giorno lunedì 24 aprile 2017 15:05:35 UTC+2, Ramos ha scritto:
>
> After a while you will go back to the book and say, aha here it is... and 
> then you realize that the "ONES" that made the book did a great job...
>
> That is my story :)
>
>
> 
>  Sem 
> vírus. www.avast.com 
> 
>  
> <#CAEM0BxOYdGUBiF5vsQGZpfrH6cV3_t2RuThgUQGcahYF=9fXfQ@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> 2017-04-24 12:07 GMT+01:00 Andrea Fae' :
>
>> Yes you are right, but there is something in the book, something in the 
>> codeno complete full documentation...managed in only one site. It's 
>> like it is...I have to accept this. thanks
>>
>>
>> Il giorno martedì 11 aprile 2017 15:07:00 UTC+2, Anthony ha scritto:
>>>
>>> On Tuesday, April 11, 2017 at 9:01:09 AM UTC-4, Anthony wrote:

 On Tuesday, April 11, 2017 at 8:55:20 AM UTC-4, Carlos Cesar Caballero 
 wrote:
>
> Hi guys, I think he is talking about the web2py api, and there are 
> some undocumented features, by example, when you authenticate against an 
> ldap you can map ldap groups against web2py groups, but this is not 
> documented, and there are some undocumented features like that.
>

 Yes, a few more advanced features are not documented, but that is far 
 from being "no documentation".

>>>
>>> And to be fair, ldap is a contrib module, and there is quite a bit of 
>>> documentation in the module itself. For example:
>>>
>>> If you need group control from ldap to web2py app's database feel 
>>> free
>>> to set:
>>>
>>> auth.settings.login_methods.append(ldap_auth(...as usual...,
>>> manage_groups=True,
>>> db=db,
>>> group_dn='ou=Groups,dc=domain,dc=com',
>>> group_name_attrib='cn',
>>> group_member_attrib='memberUid',
>>> group_filterstr='objectClass=*'
>>>))
>>>
>>> Where:
>>> manage_group - let web2py handle the groups from ldap
>>> db - is the database object (need to have auth_user, auth_group,
>>> auth_membership)
>>> group_dn - the ldap branch of the groups
>>> group_name_attrib - the attribute where the group name is stored
>>> group_member_attrib - the attribute containing the group members 
>>> name
>>> group_filterstr - as the filterstr but for group select
>>>
>>> In fact, the book even explicitly directs the reader to the 
>>> documentation within the module:
>>>
>>> *See the documentation of ldap_auth in 
>>> web2py/gluon/contrib/login_methods/ldap_auth.py*
>>>
>>> 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+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] more on @auth.requires

2017-04-24 Thread Andrea Fae'
As Anthony suggested me (and thank you for his help), I use for example 
these function to control authorization

@auth.requires(lambda: verifica_manager_site(list_of_roles_manager_site))

At the starting of default.py, where I have the other function that needs 
authotiation, I putted code to populate "list_of_roles_manager_site" and 
the function "verifica_manager_site".
The list is retrieved from database.

Is it the correct place? OR I have to put in another place or create 
another file..I don't know...
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] IMPORTANT - WEB2PY CONSULTING

2017-04-24 Thread David Shavers
Hi, I have a dating website that uses a lot of web2py features. I know android 
and web2py and can help bring people up to speed if they need. 

www.jbtus.com 

Contact - www.facebook.com/shaversapps

-- 
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] GET queries other than ID

2017-04-24 Thread David Shavers
Bump

-- 
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] conditional block insert

2017-04-24 Thread Áureo Dias Neto
is all python code, you can use one '{{' at the begin of code and '}}' at
end

{{block left_sidebar
if auth.has_membership('manager'):
  include 'manager_sidebar.html'
else:
   include 'sidebar.html'
pass
end}}

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


Re: [web2py] conditional block insert

2017-04-24 Thread Richard Vézina
Hello Pierre,

Simplify your code... Remove the if and try one side bar at a time first...
You may find that they are not properly constructed... I mean, the code
above seems fine... So I suspect that it is the way you construct your side
bar that are causing your issue. There is maybe another issue, as I am not
so familiar with web2py view "block" instruction... I suggest you reading
here :
http://web2py.com/books/default/chapter/29/05/the-views#Blocks-in-views

If your side bar are correct in there original view ("manager_sidebard" and
"sidebar"), I would suspect that if inside block can't be properly treated
for some reason...

But you could probalby simplified your code and have only once sidebar view
which already containt the proper side bar stuff as you only display one or
the other base on user membership, you surely don't need 2 views for that
if you move your if inside sidebar.html controller or view and filter
things out there...

Good luck

Richard

On Mon, Apr 24, 2017 at 9:49 AM, Pierre  wrote:

> hello everyone,
>
> {{block left_sidebar}}
> {{if auth.has_membership('manager'):}}
>{{include 'manager_sidebar.html'}}
> {{else:}}
>{{include 'sidebar.html'}}
> {{pass}}
> {{end}}
>
> for some reason this doesn't work. It inserts a mixture of the two
> sidebars. If i move blocks inside of the if same problem?? there seems
> to be a conflict between the two includes ?
>
> --
> 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: Could I use SQLFORM.factory to update 2 tables in a single form

2017-04-24 Thread Rudy
Hi Massimo,

I tried below, it could populate database values into the UPDATE FORM and 
updated the 2 tables correctly, not sure if it's the best way to do it. Any 
comment is appreciated, thanks again!

item_id = request.args(0)
item_row = db.item(item_id)
quote_row = db.quotation(item_row.quotation)

subscription_row=db(db.subscription_item.item==item_id).select().first()
item_form = SQLFORM.factory(
Field('category', 
default=item_row.category),
Field('description', 
default=item_row.description),
Field('amount', 'double', 
default=item_row.amount),
Field('start_date', 'date', 
default=subscription_row.start_date),
Field('renew_date', 'date', 
default=subscription_row.renew_date),
   ).process()
if item_form.accepted:
item_row.update_record(category=item_form.vars.category)
item_row.update_record(description=item_form.vars.description)
item_row.update_record(amount=item_form.vars.amount)

subscription_row.update_record(start_date=item_form.vars.start_date)

subscription_row.update_record(renew_date=item_form.vars.renew_date)

On Monday, April 24, 2017 at 1:34:41 PM UTC+8, Rudy wrote:
>
> Hi Massimo,
>
> Thanks for your help, i indeed used 
> db.item.insert(**db.item._filter_fields(form.vars)) and 
> db.subscription_item.insert(**db.subscription_item._filter_fields(form.vars)) 
> to generate a CREATE FORM in a separate action. Now I want to create 
> another action with an UPDATE FORM for user to modify the values, with a 
> single table, I can use item_form=SQLFORM(db.item, item_row).process(), but 
> with 2 tables in the same form using SQLFORM.factory, can SQLFORM.factory() 
> take the item_row and subscription_item_row to populate the values in the 
> UPDATE FORM from database? I tried, but didn't work. What's the best way to 
> create an UPDATE FORM for 2 tables?
>
> assumption above. subscription_item_row=db(db.subscription_item.item==
> item.id).select().first()
>
> On Friday, April 21, 2017 at 11:23:27 PM UTC+8, Massimo Di Pierro wrote:
>>
>> You can do form = SQLFORM.factory(db.item, db.subscription_item) as long 
>> the two tables do not have fields with the same name. Then after
>>
>> if form.process().accepted:
>> db.item.insert()
>> db.subscription_item.insert()
>>
>> where ... should be replaced by the proper fields in form.vars
>>
>> On Monday, 17 April 2017 12:09:58 UTC-5, Rudy wrote:
>>>
>>> Hi there,
>>>
>>> I am building an accounting system. When I create a quotation, if the 
>>> item is in 'subscription' category, i want to use SQLFORM.factory(db.item, 
>>> db.subscription_item) to generate a create form for submitting the 
>>> necessary values. Now i want to edit these 2 tables(item and 
>>> subscription_item have 1-1 relationship), does SQLFORM.factory() takes any 
>>> constraint or query to specify which item I want to edit?  If not, what's 
>>> the best way to do it? Thanks in advance!
>>>
>>> Below is the simplified database tables:
>>> db.define_table('company',
>>> Field('company_name', requires=IS_NOT_EMPTY()), # 
>>> unique=True
>>> format='%(company_name)s')
>>>
>>> db.define_table('quotation',
>>> Field('company', 'reference company'),
>>> Field('project_name', requires=IS_NOT_EMPTY()),
>>> Field('quote_amount', 'double', default=0, 
>>> writable=False),
>>> auth.signature)
>>>
>>> db.define_table('category',
>>> Field('category_name', ondelete='NO ACTION'), # eg. 
>>> project or subscription
>>> format='%(category_name)s')
>>>
>>> db.define_table('item',
>>> Field('quotation', 'reference quotation', 
>>>  writable=False, label='Quote Id'),
>>> Field('category', 'reference category', 
>>> requires=IS_IN_DB(db, 'category.id', '%(category_name)s')),
>>> Field('description'),
>>> Field('amount', 'double', default=0),
>>> auth.signature)
>>>
>>> db.define_table('subscription_item',
>>> Field('item', 'reference item',  writable=False, 
>>> label='Item Id'),
>>> Field('start_date', 'date'),
>>> Field('end_date', 'date'),
>>> auth.signature)
>>>
>>>

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

[web2py] conditional block insert

2017-04-24 Thread Pierre
hello everyone,

{{block left_sidebar}}
{{if auth.has_membership('manager'):}}
   {{include 'manager_sidebar.html'}}
{{else:}}
   {{include 'sidebar.html'}}
{{pass}}
{{end}}

for some reason this doesn't work. It inserts a mixture of the two 
sidebars. If i move blocks inside of the if same problem?? there seems 
to be a conflict between the two includes ?

-- 
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] SQLFfor,.grid export query

2017-04-24 Thread Yebach
Hello

I would like to use a different query to export data from table when using 
SQLform.grid, compared to the one i use to represent data in the grid. Also 
I would like to export more columns than I show in the grid.

I tried with this instructions but I am getting different types of errors. 
I might be because I do not place the class file into the right folder or 
smth similar. http://rootpy.com/Export-in-SQLFORM-grid/

What would be the best way to do it?

thank you for suggestions 


-- 
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: GAE Datastore performance / potential index issue

2017-04-24 Thread Áureo Dias Neto
Hello,

i have the same problem with sqlite/mysql.. when i fetch some 1000 row,
with one column only, its takes about 15/20 seconds to load a 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: GAE Datastore performance / potential index issue

2017-04-24 Thread Karoly Kantor
More info again, still hoping someone can help:

I tried to replace the DAL query with native app engine code.

Original DAL:

query=(
(mydb[record].application == application_id) &
(mydb[record].entity == entity_id) &
(mydb[record].is_deleted == False))

result = mydb(query).select()

Native:

 from google.appengine.ext import ndb
class record(ndb.Expando):
pass
result = 
record.query().filter(ndb.GenericProperty('application') == application_id, 
ndb.GenericProperty('entity') == entity.id, 
ndb.GenericProperty('is_deleted') == False)
 
I was hoping this will speed things up, but it did not. It was the same 
slowness on the local dev env. On the server, the situation became even 
worse:

"While handling this request, the process that handled this request was 
found to be using too much memory and was terminated. "

Anyway, I still find it unreal that a query of 800 rows can last more than 
20 seconds. 

Ideas are continue to be most welcome.
  

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


Re: {Disarmed} Re: {Disarmed} Re: [web2py] Re: lack of documentation

2017-04-24 Thread António Ramos
After a while you will go back to the book and say, aha here it is... and
then you realize that the "ONES" that made the book did a great job...

That is my story :)


Sem
vírus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

2017-04-24 12:07 GMT+01:00 Andrea Fae' :

> Yes you are right, but there is something in the book, something in the
> codeno complete full documentation...managed in only one site. It's
> like it is...I have to accept this. thanks
>
>
> Il giorno martedì 11 aprile 2017 15:07:00 UTC+2, Anthony ha scritto:
>>
>> On Tuesday, April 11, 2017 at 9:01:09 AM UTC-4, Anthony wrote:
>>>
>>> On Tuesday, April 11, 2017 at 8:55:20 AM UTC-4, Carlos Cesar Caballero
>>> wrote:

 Hi guys, I think he is talking about the web2py api, and there are some
 undocumented features, by example, when you authenticate against an ldap
 you can map ldap groups against web2py groups, but this is not documented,
 and there are some undocumented features like that.

>>>
>>> Yes, a few more advanced features are not documented, but that is far
>>> from being "no documentation".
>>>
>>
>> And to be fair, ldap is a contrib module, and there is quite a bit of
>> documentation in the module itself. For example:
>>
>> If you need group control from ldap to web2py app's database feel
>> free
>> to set:
>>
>> auth.settings.login_methods.append(ldap_auth(...as usual...,
>> manage_groups=True,
>> db=db,
>> group_dn='ou=Groups,dc=domain,dc=com',
>> group_name_attrib='cn',
>> group_member_attrib='memberUid',
>> group_filterstr='objectClass=*'
>>))
>>
>> Where:
>> manage_group - let web2py handle the groups from ldap
>> db - is the database object (need to have auth_user, auth_group,
>> auth_membership)
>> group_dn - the ldap branch of the groups
>> group_name_attrib - the attribute where the group name is stored
>> group_member_attrib - the attribute containing the group members
>> name
>> group_filterstr - as the filterstr but for group select
>>
>> In fact, the book even explicitly directs the reader to the documentation
>> within the module:
>>
>> *See the documentation of ldap_auth in
>> web2py/gluon/contrib/login_methods/ldap_auth.py*
>>
>> 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.
>

-- 
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: {Disarmed} Re: [web2py] Re: lack of documentation

2017-04-24 Thread Andrea Fae'
Yes you are right, but there is something in the book, something in the 
codeno complete full documentation...managed in only one site. It's 
like it is...I have to accept this. thanks

Il giorno martedì 11 aprile 2017 15:07:00 UTC+2, Anthony ha scritto:
>
> On Tuesday, April 11, 2017 at 9:01:09 AM UTC-4, Anthony wrote:
>>
>> On Tuesday, April 11, 2017 at 8:55:20 AM UTC-4, Carlos Cesar Caballero 
>> wrote:
>>>
>>> Hi guys, I think he is talking about the web2py api, and there are some 
>>> undocumented features, by example, when you authenticate against an ldap 
>>> you can map ldap groups against web2py groups, but this is not documented, 
>>> and there are some undocumented features like that.
>>>
>>
>> Yes, a few more advanced features are not documented, but that is far 
>> from being "no documentation".
>>
>
> And to be fair, ldap is a contrib module, and there is quite a bit of 
> documentation in the module itself. For example:
>
> If you need group control from ldap to web2py app's database feel free
> to set:
>
> auth.settings.login_methods.append(ldap_auth(...as usual...,
> manage_groups=True,
> db=db,
> group_dn='ou=Groups,dc=domain,dc=com',
> group_name_attrib='cn',
> group_member_attrib='memberUid',
> group_filterstr='objectClass=*'
>))
>
> Where:
> manage_group - let web2py handle the groups from ldap
> db - is the database object (need to have auth_user, auth_group,
> auth_membership)
> group_dn - the ldap branch of the groups
> group_name_attrib - the attribute where the group name is stored
> group_member_attrib - the attribute containing the group members 
> name
> group_filterstr - as the filterstr but for group select
>
> In fact, the book even explicitly directs the reader to the documentation 
> within the module:
>
> *See the documentation of ldap_auth in 
> web2py/gluon/contrib/login_methods/ldap_auth.py*
>
> 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] Re: force redirect after expiration login session expiration time

2017-04-24 Thread A3
Thanks, I thought there was a standard solution. 

I tried this:  

add this scrip to layout:
  

 var time = new Date().getTime();
 $(document.body).bind("mousemove keypress", function(e) {
 time = new Date().getTime();
 });

 function refresh() { 
 if(new Date().getTime() - time >= 6) 
 ajax("{{=URL('default', 'login_status')}}", [], ':eval')
 else 
 setTimeout(refresh, 1);
 }

 setTimeout(refresh, 1);


and this function to the default controller.

def login_status():
if auth.user:
return ''  # user is still logged in
else:
redirect(URL('default', 'index'), client_side=True)


The java script checks every 10 second for mouse activity:  if there is 60 
seconds no activity it will make an ajax call to see if the user is still 
logged in. 
if not logged in it will redirect.

http://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity

http://stackoverflow.com/questions/10323714/how-to-dynamically-check-logged-in-state-from-view-in-web2py

Unfortunately it doesn't work:  
I hoped it worked but it seems that the ajax call keeps the user logged in.

Is it possible to read the time left from auth.settings.expiration  ? 

 

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


[web2py] SQLFORM.grid without advanced search

2017-04-24 Thread Gael Princivalle
Hello.

Is it possible to customize a SQLFORM.grid for having only the global 
search field?
In other words by default when the user click in the global search field 
another area is displayed that give the possibility to the user to choose 
in which field he would like to search. I would like to not display this 
area.

Thanks in advance.

-- 
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: GAE Datastore performance / potential index issue

2017-04-24 Thread Karoly Kantor
Sorry for commenting on my own issue, but i have more information:

The following query takes 20 seconds for only 800 items:

query=(
(mydb[record].application == application_id) &
(mydb[record].entity == entity_id) &
(mydb[record].is_deleted == False))

result = db(query).select()

I don't think this is normal. I really would like to know what web2py might 
be really doing in terms of raw GAE query, but unfortunately _lastsql still 
does not give any info.

Any idea / insight would be greatly appreciated!

The index seems to exist and serve in GAE Datastore as follows:

 record  application 
 entity 
 is_deleted 


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