[web2py] Re: Best way to validate individual conditional Smartgrid Forms

2017-01-17 Thread LoveWeb2py
Hi Sitfan,

I wasn't sure if I could use show_if because I want to evaluate a value 
IS_IN_SET(['choice_a','choice_b')

I'd like to show a file upload field if choice_a is selected and a text 
field if choice_b is selected. 

On Wednesday, January 18, 2017 at 2:23:44 AM UTC-5, 黄祥 wrote:
>
> had you tried conditional fields show_if?
> ref:
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Conditional-fields
>
> best regards,
> stifan
>

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


[web2py] Re: Best way to validate individual conditional Smartgrid Forms

2017-01-17 Thread 黄祥
had you tried conditional fields show_if?
ref:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Conditional-fields

best regards,
stifan

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


[web2py] Re: welcome app in 2.9.5 , 2.11.2 , 2.14.6

2017-01-17 Thread 黄祥
perhaps it's related with css, bootstrap 3 in 2.14.6 doesn't support sub 
sub menu

best regards,
stifan

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


[web2py] welcome app in 2.9.5 , 2.11.2 , 2.14.6

2017-01-17 Thread webpypy
Hi ,

I am trying to add sub sub menu items, as follows:

response.menu += [
(SPAN('web2py', _class='highlighted'), False, 'http://web2py.com', [
(T('My Sites'), False, URL('admin', 'default', 'site')),
(T('This App'), False, URL('admin', 'default', 'design/%s' % app), [

(T('This App'), False, URL('admin', 'default', 'design/%s' % app), [
(T('Controller'), False,
 URL(
 'admin', 'default', 'edit/%s/controllers/%s.py' % (app, ctr))),
(T('View'), False,
 URL(
 'admin', 'default', 'edit/%s/views/%s' % (app, response.view))),]),


(T('Controller'), False,
 URL(
 'admin', 'default', 'edit/%s/controllers/%s.py' % (app, ctr))),

It is working fine in 2.9.5 welcome app

not working in 2.11.2 and 2.14.6 welcome apps

your help is highly appreciated.

webpypy

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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] Best way to validate individual conditional Smartgrid Forms

2017-01-17 Thread LoveWeb2py
Hello,

I've been trying to string together pieces from the book and multiple 
forums for working with the SmartGrid edit forms and I'm not sure the best 
way to validate certain fields...


I am currently using jQuery to hide fieldA if fieldB is selected, but I am 
running into an error with web2py...

Let's say FieldC is required and Field A are required...

If FieldA is shown, and I submit the form then I get an error because 
fieldC is empty.

I was looking at the onvalidation method for sqlform.smartgrid, but I'm not 
quite sure how to apply it or if it's necessary here.

Here is my code:


$(document).ready(function(){
$("select").change(function(){
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="value1"){
$("#table_fieldA__row").hide();
$("#table_fieldB__row").hide();
$("#table_fieldC__row").show();
}
else if($(this).attr("value")=="value2"){
$("#table_fieldA__row").show();
$("#table_fieldB__row").show();
$("#table_fieldC__row").hide();


}
else{
$("#table_fieldA__row").hide();
$("#table_fieldB__row").hide();
$("#table_fieldC__row").hide();

}
});
}).change();
});


Is there something I could be doing better inside the controller or 
smartgrid?

grid = SQLFORM.smartgrid(table.field, onvalidation=source_validate, 
maxtextlength=100)
if grid.create_form:
if grid.create_form.errors:
response.flash = "Error... please check form"
elif grid.update_form:
if grid.update_form.errors:
response.flash= "Error... 3"
else:
return dict(grid=grid)
return dict(grid=grid)

def source_validate(form):
#print "In onvalidation callback"
#print form.vars
form.errors = True  # this prevents the submission from completing

# ...or to add messages to specific elements on the form
form.errors.fielda = "Must specify a value!"
form.errors.fieldb = "Please select a value2"
form.errors.fieldc = "Must not be empty!"

Thank you for your help

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


[web2py] Advice on structuring my app

2017-01-17 Thread Ramkrishan Bhatt
each organization to become a group, then what I use groups for right now will 
be permissions, this is probably the best route. 

This Idea will work now about data access also we need maintain Controller 
function which will filter out the data based on organization before serving to 
user.

We can also put filter function on model so before serving data we can validate 
appropriate data for the user.

Let me know if you better solution , I may need in near future.

One more thing we can do that is use sapratly manage role based access control 
rest based applications where we can maintain each user as single identity and 
common role for multiple user. 

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


[web2py] Re: Web2PY MySQL DB connection and data retrieval

2017-01-17 Thread 黄祥
perhaps you can put delete() or truncate() function to delete data in 
database table in form accepts() or form accepted() function

best regards,
stifan

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


[web2py] Re: Web2PY MySQL DB connection and data retrieval

2017-01-17 Thread Sankhajit Das

how can we delete data automatically from a table in database after 
clicking submit button of a form in web2py

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


[web2py] Re: Advice on structuring my app

2017-01-17 Thread Leonel Câmara
Yes a user can be a member of several organizations which needs to approve 
him and decide on what permissions the user will have, each organization is 
managed by users with admin powers within that organization. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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: PDF WITH FPDF - TWO PAGES WITH DIFFERENTE HEADER

2017-01-17 Thread Dave S
On Tuesday, January 17, 2017 at 4:05:28 PM UTC-8, Dave S wrote:
>
> On Tuesday, January 17, 2017 at 5:45:48 AM UTC-8, Áureo Dias Neto wrote:
>>
>> Guys, i have two pages on a report, generated by FPDF, but i want
>> that pages, have differente Header, thats is defined in the Class Header..
>>
>
> Sorry, I've only done very simple stuff in FPDF so far (for demonstration, 
> only).  I've done a simple table to dump query results, but that's all. 
>  I'd poke at it, but at the moment I'm poking at other stuff.
>

BTW, I found the examples on the FPDF github site to be useful; have you 
peeked at those?

/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: PDF WITH FPDF - TWO PAGES WITH DIFFERENTE HEADER

2017-01-17 Thread Dave S
On Tuesday, January 17, 2017 at 5:45:48 AM UTC-8, Áureo Dias Neto wrote:
>
> Guys, i have two pages on a report, generated by FPDF, but i want
> that pages, have differente Header, thats is defined in the Class Header..
>

Sorry, I've only done very simple stuff in FPDF so far (for demonstration, 
only).  I've done a simple table to dump query results, but that's all. 
 I'd poke at it, but at the moment I'm poking at other stuff.

/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: Advice on structuring my app

2017-01-17 Thread icodk
Can a user be a member of several organizations ?
Who  is managing organizations?
How somebody get to be a member of an organization ?
With very little information available I would have an organization table 
and each newly registered user will get his own organization and will be 
his organization's admin. Each organization will have an invitation table 
 in which the admin can invite other users by sending them an invitation 
mail.
Invited user will get a mail with a link to join the organization. Clicking 
the link will activate a controller that add the user to a organization 
membership table.
In the invitation table the admin can also set permissions for each invited 
user. This way the admin can also revoke an invited user. All 
organization's data will be protected by common filter but shared data will 
not.
Hope it is helpful to some



If yes then you should have 

On Tuesday, January 17, 2017 at 8:21:08 PM UTC+1, Jim S wrote:
>
> I think you could accomplish that with the _common_filter.  That is what I 
> did on the app where I used it and it worked well.
>
> -Jim
>
> On Tuesday, January 17, 2017 at 11:33:02 AM UTC-6, Leonel Câmara wrote:
>>
>> I'm not sure I want to restrict each organization to a single domain yet. 
>> But yes it's a possibility, I don't need to necessarily use the domain name 
>> to do the filtering. Although I would also like them to be able to 
>> optionally share some data among them so I would also need to solve that 
>> problem.  
>>   
>> So basically, be able to do multitenancy within a single domain or with 
>> organizations being able to have more than one domain and sharing.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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: Multiple connections/ databases with same app

2017-01-17 Thread Dave S

On Tuesday, January 17, 2017 at 7:29:44 AM UTC-8, Sankhajit Das wrote:
>
> hey. I have created a mysql database in my web2py app.
>>
> now i want to create another sqlite database such that whatever data i 
> enter 
> in sqlite database. it automatically gets copied in mysql database.
> Pls somebody help me do ds with full code.
>   
>

Assignment due soon?  See my comments in the other thread.

/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: Web2PY MySQL DB connection and data retrieval

2017-01-17 Thread Dave S


On Tuesday, January 17, 2017 at 6:44:01 AM UTC-8, Sankhajit Das wrote:
>
> hey. I have created a mysql database in my web2py app.
>>
> now i want to create another sqlite database such that whatever data i 
> enter 
> in sqlite database. it automatically gets copied in mysql database.
> Pls somebody help me do ds with full code.
>   
>

To do it with web2py,  you open a connection to both databases, select from 
one and add to the other.  See
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Inserting-and-updating-from-a-dictionary>

If the data is coming from a form, you can trigger the copy by using an 
after-insert callback.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update>

If you don't need to do the copying ASAP, but prefer to batch the job, then 
the scheduler and export as CSV might be more convenient.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--one-Table-at-a-time->
http://web2py.com/books/default/chapter/29/04/the-core#web2py-Scheduler>

Good luck!

/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: Web2py app on Android/IOS with notifications

2017-01-17 Thread Anthony
On Tuesday, January 17, 2017 at 2:01:28 PM UTC-5, Gael Princivalle wrote:
>
> I mean:
> https://www.mtbconnection.com/OneSignalSDKWorker.js
> It's required to have this file on the root level.
> I use a parametric router, do you know how I can do it?
>
> routers = dict(
> BASE = dict(
> domains = {
> "www.mtbconnection.com" : "mtbconnection",
> }
> ),
> mtbconnection = dict(languages=['en', 'it'], default_language='it'),
> )
>
>
Trying adding the root_static option (see 
https://github.com/web2py/web2py/blob/b2e03c9dee935d46cb9512f0595dc2dacddb5166/examples/routes.parametric.example.py#L56).

Or better yet, configure your web server to serve those files directly, 
without hitting web2py at all.

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: Advice on structuring my app

2017-01-17 Thread Jim S
I think you could accomplish that with the _common_filter.  That is what I 
did on the app where I used it and it worked well.

-Jim

On Tuesday, January 17, 2017 at 11:33:02 AM UTC-6, Leonel Câmara wrote:
>
> I'm not sure I want to restrict each organization to a single domain yet. 
> But yes it's a possibility, I don't need to necessarily use the domain name 
> to do the filtering. Although I would also like them to be able to 
> optionally share some data among them so I would also need to solve that 
> problem.  
>   
> So basically, be able to do multitenancy within a single domain or with 
> organizations being able to have more than one domain and sharing.
>

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


[web2py] Re: Web2py app on Android/IOS with notifications

2017-01-17 Thread Gael Princivalle
I mean:
https://www.mtbconnection.com/OneSignalSDKWorker.js
It's required to have this file on the root level.
I use a parametric router, do you know how I can do it?

routers = dict(
BASE = dict(
domains = {
"www.mtbconnection.com" : "mtbconnection",
}
),
mtbconnection = dict(languages=['en', 'it'], default_language='it'),
)

I've saw in the manual that it's possible but only with the pattern-based 
system:
routes_in = (
  ('/favicon.ico', '/examples/static/favicon.ico'),
  ('/robots.txt', '/examples/static/robots.txt'),
)
routes_out = ()
And with this system I don't know how I can manage translate the actual 
functions of my parametric routes.py.

Il giorno martedì 17 gennaio 2017 17:54:39 UTC+1, Anthony ha scritto:
>
> On Tuesday, January 17, 2017 at 9:50:53 AM UTC-5, Gael Princivalle wrote:
>>
>> It's required to have the 3 SDK file accessible from the top level root.
>> See here at 2.3:
>> https://documentation.onesignal.com/docs/web-push-sdk-setup-https
>>
>> For an html file I know how to do it, but for json or js files how can I 
>> do it?
>>
>
> I'm not sure what you mean. In order to set up web push notifications for 
> a given user, that user must load an HTML page from your site, including 
> the head content described in those instructions. Once that page has loaded 
> and the user has consented, a background service worker will be started, 
> and you will be able to push notifications to the user's device (even if 
> they are not currently viewing your website in the browser).
>
> 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: Advice on structuring my app

2017-01-17 Thread Leonel Câmara
I'm not sure I want to restrict each organization to a single domain yet. 
But yes it's a possibility, I don't need to necessarily use the domain name 
to do the filtering. Although I would also like them to be able to 
optionally share some data among them so I would also need to solve that 
problem.  
  
So basically, be able to do multitenancy within a single domain or with 
organizations being able to have more than one domain and sharing.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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: Advice on structuring my app

2017-01-17 Thread Jim S
Is there a reason why the Multi-tenancy or Common Filters wouldn't work?

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Common-fields-and-multi-tenancy

I've used common filters in the past with success.

-Jim

On Tuesday, January 17, 2017 at 10:59:27 AM UTC-6, Leonel Câmara wrote:
>
> I'm in the process of turning an application that was used by a single 
> organization into one that will be used by many, I'm using regular Auth and 
> auth groups to manage which users can do what according to what groups they 
> have memberships on.  
>   
> The first problem I'm facing is that the users that belong to a given 
> auth_group will now only belong to that group in a given organization, 
> which I guess would also be a problem with regular auth functions. 
>
> Another problem is that I want the organizations to be able to share some 
> of their data with another organization.  
>   
> So, right now, I'm considering what would be the best architecture for the 
> application.  
>   
> One idea would be to store the organization the user is currently browsing 
> with (no reason to limit that one user can only belong to one organization) 
> in session, then I would have to check in each controller if the user has 
> the right group and organization for what he wants to do, this would 
> pollute my code somehow.  
>   
> Another idea is for each organization to become a group, then what I use 
> groups for right now will be permissions, this is probably the best route. 
> This would still leave the problem of making the user see the right data 
> depending on which organization he is currently browsing with.   
>   
> Any advice on how to do this as cleanly as possible in terms of code?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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] Advice on structuring my app

2017-01-17 Thread Leonel Câmara
I'm in the process of turning an application that was used by a single 
organization into one that will be used by many, I'm using regular Auth and 
auth groups to manage which users can do what according to what groups they 
have memberships on.  
  
The first problem I'm facing is that the users that belong to a given 
auth_group will now only belong to that group in a given organization, 
which I guess would also be a problem with regular auth functions. 

Another problem is that I want the organizations to be able to share some 
of their data with another organization.  
  
So, right now, I'm considering what would be the best architecture for the 
application.  
  
One idea would be to store the organization the user is currently browsing 
with (no reason to limit that one user can only belong to one organization) 
in session, then I would have to check in each controller if the user has 
the right group and organization for what he wants to do, this would 
pollute my code somehow.  
  
Another idea is for each organization to become a group, then what I use 
groups for right now will be permissions, this is probably the best route. 
This would still leave the problem of making the user see the right data 
depending on which organization he is currently browsing with.   
  
Any advice on how to do this as cleanly as possible in terms of code?

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


[web2py] Re: Web2py app on Android/IOS with notifications

2017-01-17 Thread Anthony
On Tuesday, January 17, 2017 at 9:50:53 AM UTC-5, Gael Princivalle wrote:
>
> It's required to have the 3 SDK file accessible from the top level root.
> See here at 2.3:
> https://documentation.onesignal.com/docs/web-push-sdk-setup-https
>
> For an html file I know how to do it, but for json or js files how can I 
> do it?
>

I'm not sure what you mean. In order to set up web push notifications for a 
given user, that user must load an HTML page from your site, including the 
head content described in those instructions. Once that page has loaded and 
the user has consented, a background service worker will be started, and 
you will be able to push notifications to the user's device (even if they 
are not currently viewing your website in the browser).

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: Multiple connections/ databases with same app

2017-01-17 Thread Sankhajit Das

>
> hey. I have created a mysql database in my web2py app.
>
now i want to create another sqlite database such that whatever data i 
enter 
in sqlite database. it automatically gets copied in mysql database.
Pls somebody help me do ds with full code.
  

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


[web2py] Re: Web2py app on Android/IOS with notifications

2017-01-17 Thread Gael Princivalle
Thanks Anthony, OneSignal seems a good solution.
I took a look to the API.
https://documentation.onesignal.com/reference
Some examples:
https://documentation.onesignal.com/reference#create-notification

I'll try to use it also because it could be a simple all-around solution, 
when web push notifications gone be available also on IOS (normally in 
2017).

It's required to have the 3 SDK file accessible from the top level root.
See here at 2.3:
https://documentation.onesignal.com/docs/web-push-sdk-setup-https

For an html file I know how to do it, but for json or js files how can I do 
it?

Thanks.

Il giorno domenica 15 gennaio 2017 18:45:05 UTC+1, Anthony ha scritto:
>
> You might consider a service like OneSignal  
> (it's free). It's all client-side Javascript, so doesn't interact with 
> web2py (there is an API that you can use to send notifications, which of 
> course can be used from web2py -- but there's nothing web2py specific).
>
> Anthony
>
> On Sunday, January 15, 2017 at 9:15:29 AM UTC-5, Gael Princivalle wrote:
>>
>> Hello.
>>
>> There is a really interesting post about Web2py integration in Android or 
>> IOS platforms:
>>
>> https://groups.google.com/forum/#!searchin/web2py/web2py$20mobile$20app|sort:relevance/web2py/1ZxFEB5j4XA/-v7_FvsKFQAJ
>>
>> Someone knows if there's a way to send to the mobile phone some 
>> notifications like "New message from myapp" ?
>>
>> 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: Web2PY MySQL DB connection and data retrieval

2017-01-17 Thread Sankhajit Das

>
> hey. I have created a mysql database in my web2py app.
>
now i want to create another sqlite database such that whatever data i 
enter 
in sqlite database. it automatically gets copied in mysql database.
Pls somebody help me do ds with full code.
  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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] PDF WITH FPDF - TWO PAGES WITH DIFFERENTE HEADER

2017-01-17 Thread Áureo Dias Neto
Guys, i have two pages on a report, generated by FPDF, but i want
that pages, have differente Header, thats is defined in the Class Header..

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.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: Issues with record versioning

2017-01-17 Thread Ricardo Oliveira
Hi,
Just so it's clear for anyone having the same issue, Anthony's tip was 
right on target. All is working now.
Conclusion: you must use the update_record(field=new_value) format if 
you're using authentication, and not the update_record() format.

Thanks again to all that chipped in and Anthony for the solution.

Ricardo.

On Tuesday, January 10, 2017 at 11:43:27 AM UTC, Ricardo Oliveira wrote:
>
> Ah.. that should explain it then. In that case I'll have to do an update 
> call with each of the update fields named individually.
> That would be something nice to have in the book, I agree :)
>
> Thanks Anthony, I'm going to test it now.
>
> On Monday, January 9, 2017 at 10:10:23 PM UTC, Anthony wrote:
>>
>> record = db(db.table_x.id == row_id).select().first()
>>> record['name'] = 'something else'
>>> record.update_record()
>>>
>>> That's the one way you cannot do it. The problem is when you call 
>> .update_record() with no arguments, it takes all the existing fields in the 
>> record and uses them in the database update. It will therefore use the 
>> existing values of modified_by and modified_on. Typically, modified_by and 
>> modified_on get updated because they are excluded from the update call, 
>> which prompts the DAL to fill their values in automatically. But this 
>> mechanism breaks down when calling .update_record() with no arguments. We 
>> should probably add a note about this in the book.
>>
>> 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: Help at counting comments of a post and restrict access to certain categories

2017-01-17 Thread Dave S


On Monday, January 16, 2017 at 8:01:56 PM UTC-8, N. Fischer wrote:
>
> Hi all,
> I am currently working with a friend on a web2py project. This is our 
> first time, we do anything with web2py and we managed to build the reddit 
> clone and do little improvements, Massimo Di Pierro did in his video 
> tutorials, thank you at this point for your great videos.
> Now we want to add some other features and have some problems to implement 
> 2 specific things.
>
> 1. We want to display how many comments a post has in the overview of the 
> category. But we dont really know how we can access the comments of a post 
> and count them.
>
> in our database we have the both tables, post and comment. comment has a 
> reference to the post it is connected to. 
>

For any one post, you'd take its ID and use that in the select statement 
for the comments. 
Something like
post_id = something-previously-determined
query = db(db.comment.post == post_id)



and then use the count() function to get the count.
com_count = query.count();



http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#count--isempty--delete--update>

 If you want the counts for ALL posts, you may be doing a join to be able 
to use all post ids.

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#One-to-many-relation>


> 2. We have a category called "Updates" and we want that only users in the 
> group "admin" can create new posts. Other users shall only be able to 
> comment on these posts.
>
> @auth.requires_login()
> def create_post():
> category = get_category()
> db.post.category.default = category.id
> form = SQLFORM(db.post).process(next='view_post/[id]');
> return locals()
>
> @auth.requires_membership("admin")
>
> We tried to use an if-statement that it requires an admin membership.
>
>
I'd give a shot at moving the "requires_membership" line to right after the 
"requires_login" line,
so that both auth wrappers are decorating the create_post() procedure
 
Actually, looking at line 23 of
http://web2py.com/books/default/chapter/29/09/access-control#Decorators>
it appears you want to use one decorator (.requires) with both conditions 
in it (requires_login, requires_membership("admin").


Hopefully, there is anyone out there who can help. Thank you for reading 
> this.
>
> Best regards
> N. Fischer
>

Good luck!

/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: run web2y scheduler instances on 2 or more servers

2017-01-17 Thread Dave S


On Monday, January 16, 2017 at 8:01:56 PM UTC-8, Manjinder Sandhu wrote:
>
> Hi Andrey/Niphlod,
>
> *Is there a way I can connect servers via SQLite?*
>
> *Regards,*
>
> *Manjinder*
>

If you mean for the scheduler , sure. The connection string handles that 
(although I've only connected to sqlite3 from the local machine)..   But 
sqlite3 has limitations regarding simultaneous access, due to how it 
handles locking; that's done at file level rather than record level.  If 
your environment has a light load on all the servers involved, this might 
not be a problem, and certainly would work for development, but as your 
load increases the limitations will be more apparent.

/dps


 

> On Tuesday, 4 March 2014 20:52:31 UTC-8, Andrey K wrote:
>>
>> Thanks Niphlod, as usual very detail and great answer. Thank you a lot!
>> After you answer I have check the web and have found several tools that 
>> do specifically cluster management: StarCluster, Elasticluster. I am really 
>> keen to try the later one. It looks good specifically for GCE and EC2 work. 
>> However now I know better how I can utilize w2p scheduler. After figuring 
>> out how Elasticluster works - might blend work of w2p scheduler and EC.
>>
>> Thanks again! Really appreciate your help!
>>
>> On Monday, March 3, 2014 11:33:17 PM UTC+3, Niphlod wrote:
>>>
>>>
>>>
>>> On Monday, March 3, 2014 1:10:08 PM UTC+1, Andrey K wrote:

 Wow, what an answer! Niphlod, thanks a lot for such a detailed info 
 with examples - now it is crystal clear for me. Very great help, really 
 appreciate it!!!

 You answer make me clarify the future architecture for my app. Before I 
 thought to use amazon internal tools for  task distribution now I think I 
 can use w2p scheduler at least for the first stage or maybe permanently.

 I have several additional question if you allow me. Hope it helps to 
 other members of the w2p club.
 The plan is to start amazon servers (with web2py preinstalled) 
  programmatically when I need it with the purpose to run  w2p scheduler on 
 it.
 Could you give me your point of your on the following  questions that 
 I need to address in order to build such a service:
 1)Can I set up and cancel workers under web2py programmatically  which 
 equivalent 
 to' python web2py.py -K myapp:fast,myapp:fast,myapp:fast'?

>>>
>>> you can put them to sleep, terminate or kill them (read the book or use 
>>> w2p_scheduler_tests to get comfortable with the terms) but there's no 
>>> "included" way to start them on demand. That job is left to various pieces 
>>> of software that are built from the ground-up to manage external 
>>> processesupstart, systemd, circus, gaffer, supervisord, foreman, etc 
>>> are all good matches but each one with a particular design in mind and 
>>> totally outside the scope of web2py. Coordinating processes among a set of 
>>> servers just needs a more complicated solution than web2py itself.
>>>  
>>>
 2) What is the best way to monitor load of the server to make a 
 decision to start new worker or new server depends on the resources left?

>>>
>>> depends of what you mean by load. Just looking at your question, I see 
>>> that you never had to manage such architecture :-P..usually you don't 
>>> want to monitor the load "of the server" to ADD additional workers... you 
>>> want to monitor the load "of the server" to KILL additional workers or ADD 
>>> servers to process the jobs, watching at the load "of the infrastructure". 
>>> Again usually - because basically every app has its own priorities - you'd 
>>> want to set an estimate (KPI) on how much the queue can grow before jobs 
>>> are actually processed, and if the queue is growing faster than the 
>>> processed items, start either a new worker or a new virtual machine. 
>>>  
>>>
 3)Is it possible to set up folder on dedicated server for web2py file 
 upload and make it accessible to all web2py instances = job workers

 linux has all kinds of support for that: either an smb share or an nfs 
>>> share is the simplest thing to do. a Ceph cluster is probably more 
>>> complicated, but again we're outside of the scope of web2py 
>>>
>>

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


[web2py] Re: Conditional fields

2017-01-17 Thread Dave S
On Monday, January 16, 2017 at 8:01:52 PM UTC-8, Bishal Saha wrote:
>
> I am trying to create a form which will have multiple forms and where the 
> first form will have two radio buttons and one of them will work like - if 
> it is selected then all the other fields of the other forms wont show and 
> directly we can submit the whole form with null values to the other fields 
> of the other forms and with just one value to the one table for that one 
> form in the data base whereas when the other radio button is selected we 
> can fill in the others fields of the other forms in that form . Any 
> suggestions please , I am stuck here for days now.
>

That sounds like a job for client-side javascript.  That would involve 
event handlers.  It's easy enough to add a script section to a view; I've 
done that with one of my forms to make the next input field be based on the 
value of the first input field.  (I've used the jquery environment to do 
that, but if you don't know javascript at all, a good basic course should 
cover the "native" event handlers.  I don't have a recommendation for 
self-study of js, though; I learned that part in a community college 
course, and have a text book I can re-read between Google searches.) 

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