[web2py] Re: How to sort a join by count

2020-11-20 Thread Alex Glaros
Thanks for detailed responses Val, I appreciate it.

On Saturday, November 14, 2020 at 4:51:06 PM UTC-8 valq...@gmail.com wrote:

> I made even CTE+recursive:  
> https://github.com/web2py/pydal/issues/627
>
> But have no time to make a PR
>
> воскресенье, 15 ноября 2020 г. в 03:41:24 UTC+3, valq...@gmail.com: 
>
>> for example,  you can use window function to get  records with count  in 
>> one query:
>> db(...).select( ... ,  'count(id) OVER() AS cnt' )
>>
>>
>> воскресенье, 15 ноября 2020 г. в 03:35:34 UTC+3, valq...@gmail.com: 
>>
>>> It was in 2017
>>> Now you can pass to select raw-sql-strings with any expression, just end 
>>> with  ' ... *AS* some_name'  (*AS* must be in uppercase )
>>>
>>> воскресенье, 15 ноября 2020 г. в 02:54:53 UTC+3, alexg...@gmail.com: 
>>>
 looks like need executeSQL needed for string_agg: 
 Is it possible to do more advanced queries (like using string_agg) with 
 DAL in the meantime?
 Massimo Di Pierro
 Apr 12, 2017, 4:21:36 AM
 to web...@googlegroups.com
 You have to use db.executesql for that. Sorry.

 On Saturday, November 14, 2020 at 3:28:06 PM UTC-8 valq...@gmail.com 
 wrote:

>   just replace *GROUP_CONCAT* with *string_agg * 
>
> воскресенье, 15 ноября 2020 г. в 02:19:52 UTC+3, alexg...@gmail.com: 
>
>> I have postgres. How would it look for that?
>>
>> On Saturday, November 14, 2020 at 9:03:13 AM UTC-8 valq...@gmail.com 
>> wrote:
>>
>>> Just in case : pydal doesnt support backend specific aggregate 
>>> functions
>>>
>>>
>>> суббота, 14 ноября 2020 г. в 19:54:35 UTC+3, valq...@gmail.com: 
>>>
 There is no db.executesql

 суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: 

> sorry, did not mean direct SQL through db.executesql , meant 
> through DAL
>
> On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 
> valq...@gmail.com wrote:
>
>> Assuming sqlite:
>> person_cnt = 
>> db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt')
>>
>>
>> prioritySet = db((db.PERSON.id  == 
>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>> PERSON-PROJECT-PRIORITY.project_fk)).select(
>> ...,
>> person_cnt, 
>> 'GROUP_CONCAT(person.person_name,",") AS person_list'
>> groupby = db.PERSON-PROJECT-PRIORITY.project_fk, 
>> )
>>
>> суббота, 14 ноября 2020 г. в 09:40:17 UTC+3, alexg...@gmail.com: 
>>
>>> How to write a statement that counts which projects are the 
>>> priority of most people
>>>
>>> PROJECT
>>> id
>>> project_name
>>>
>>> PERSON
>>> id
>>> person_name
>>>
>>> PERSON_PROJECT_PRIORITY
>>> person_fk
>>> project_fk
>>>
>>> prioritySet = db((db.PERSON.id == 
>>> PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == 
>>> PERSON-PROJECT-PRIORITY.project_fk)).select()
>>>
>>> How to sort by count of projects which have priority in order of 
>>> the most persons' priority?
>>>
>>> Output looks like this:
>>>
>>> Paint-the-house (10)  [Means is the top priority for 10 people]
>>> Plant-a-garden (5)
>>> Clean-out-garage (2)
>>>
>>> If you have additional time, how to write so output looks like:
>>>
>>> Paint-the-house (10) Tom, Sue, Tony, Ted, Mary, Fred, Sal, 
>>> Chris, Ed, Sally
>>> Plant-a-garden   (5) Harry, George, Joanne, Tony, Janet
>>> Clean-out-garage (2) Clyde, Jane
>>>
>>> Thanks,
>>>
>>> Alex Glaros
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b1bc83f0-f737-4d01-96f5-d5192f496957n%40googlegroups.com.


Re: [web2py] Re: Push Notifications

2020-11-20 Thread António Ramos
Yes you make an app in web2py that subscribes to one or many pusher
notification channels. That channels are created by you in your html of
your web2py app.
 your web2py server sends notifications to pusher.com using python code
,and your webpages subscribes the same notifications using javascript. you
can go crazy and create rooms etc.
The docs from pusher are very informative.
Regards
António

Em sex., 20 de nov. de 2020 às 18:28, Christian Varas <
chriiisti...@gmail.com> escreveu:

> Hi! I need to implement this and receive the notifications in the phone
> android/iOS. For this do I need to make my own app? Or do you use an app
> who can subscribe to push notifications in pusher.com ?
> This is off topic but any recommendation is appreciated
>
> Cheers.
> Chris
>
> El El vie, 20 de nov. de 2020 a la(s) 13:45, mostwanted <
> godirao...@gmail.com> escribió:
>
>> Gratitude
>>
>> On Friday, November 20, 2020 at 10:33:10 AM UTC+2 Ramos wrote:
>>
>>> create a module inside web2py
>>> API_Pusher.py
>>>
>>> import pusher
>>>
>>> def pusher_client():
>>> return pusher.Pusher(
>>>   app_id='yourid',
>>>   key='yourkey',
>>>   secret='yoursecret',
>>>   cluster='eu',
>>>   ssl=True
>>> )
>>>
>>>
>>> Then inside your controllers
>>>
>>> from API_Pusher import pusher_client
>>> ...
>>> pusher_client().trigger('fileit', 'plannerPesos',  {'message':
>>> "PlaySound('ok')"})
>>>
>>> Em sex., 20 de nov. de 2020 às 07:41, mostwanted 
>>> escreveu:
>>>
 Hey Ramos, I was able to successfully register the app on pusher.com.
 towards step 4 its says i should copy this code:
 *CODE:*
 curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer
 9C9232906DFC6C8F8115926CC30D637945EB75F60467DA77977C399C4235E61C" \
  -X POST "
 https://733e2240-aca0-4a12-a5a9-c3b1422b9063.pushnotifications.pusher.com/publish_api/v1/instances/733e2240-aca0-4a12-a5a9-c3b1422b9063/publishes;
 \
  -d
 '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello,
 world!"}}}'

 to my console! Which console is this one? My desktop console? I'm
 hosted with pythonanywhere.com, can i use the Bash console in my
 dashboard?

 On Tuesday, November 17, 2020 at 7:53:20 AM UTC+2 mostwanted wrote:

> Thanks alot Ramos, think this will work, very little work needs to be
> done here, I'll try it out.
>
> On Tuesday, November 17, 2020 at 1:06:10 AM UTC+2 Ramos wrote:
>
>> Why reiventing the wheel ???
>> https://pusher.com/
>>
>> I use it with web2py and works like a charm
>>
>>
>> Em seg., 16 de nov. de 2020 às 08:44, mostwanted 
>> escreveu:
>>
>>> So far all I have been able achieve is asking the user for
>>> permission to send them notifications & if they accept all that happens 
>>> is
>>> that everytime they open the app they get a greetings notification,
>>> achieving that was not complicated because it was straight forward, I
>>> placed the code in my main.js script & it runs everytime the service 
>>> worker
>>> gets registered.
>>>
>>> *CODE:*
>>> Notification.requestPermission(result => {
>>>   if (result === 'granted') {
>>> showNotification('Welcome to My App™', 'Everything Services™')
>>>   }
>>> });
>>>
>>> function showNotification(title, message) {
>>>   if ('Notification' in window) {
>>> navigator.serviceWorker.ready.then(registration => {
>>>   registration.showNotification(title, {
>>> body: message,
>>> tag: 'my-app',
>>> icon:'/init/static/images/icon_192x192.png',
>>> badge:'/init/static/images/icon_128x128.png',
>>> vibrate: [200, 100, 200, 100, 200, 100]
>>>   });
>>> });
>>>   }
>>> }
>>>
>>>
>>> On Monday, November 16, 2020 at 10:31:10 AM UTC+2 mostwanted wrote:
>>>

 Has anyone been able to implement push notifications on their
 web2py apps?

 I need a working application with some examples on how to implement
 this for one of my applications.

 I've been looking at the "web-push-book (
 https://web-push-book.gauntface.com/how-push-works/)" but I cant
 put it together in my head.

 What I wanna achieve is relatively basic, I have an applivcation
 that offers information on services & products sold in my area, so 
 what I
 want is to be able to send notifications everytime a new service or 
 product
 is registered.

 If anyone has any idea on how I can easily implement this please
 help me.

 Regards;

 Mostwanted

>>> --
>>> 

[web2py] Cron instead of Scheduler

2020-11-20 Thread Gaël Princivalle
Hi.

I'm still having troubles to start a worker on Opalstack for my schedulers.
I've this error:
--
[myuser web2pyfolder]$ nohup env/bin/python web2py/web2py.py -K myapp &
[1] 21916
[ myuser web2pyfolder ]$ nohup: ignoring input and appending output to 
‘nohup.out’

[1]+  Exit 1  nohup env/bin/python web2py/web2py.py -K myapp
-

If I don't put the & at the end it sometimes runs, sometimes not.

I've tried to use the older Web2py version that I was using on Webfaction 
and the error still the same.

Is there another way to start a worker?

Or can I run some functions of my application with cron?

Thanks, regards.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/bff7c13e-7766-4d78-973a-1a075352c61cn%40googlegroups.com.


Re: [web2py] Re: Push Notifications

2020-11-20 Thread Christian Varas
Hi! I need to implement this and receive the notifications in the phone
android/iOS. For this do I need to make my own app? Or do you use an app
who can subscribe to push notifications in pusher.com ?
This is off topic but any recommendation is appreciated

Cheers.
Chris

El El vie, 20 de nov. de 2020 a la(s) 13:45, mostwanted <
godirao...@gmail.com> escribió:

> Gratitude
>
> On Friday, November 20, 2020 at 10:33:10 AM UTC+2 Ramos wrote:
>
>> create a module inside web2py
>> API_Pusher.py
>>
>> import pusher
>>
>> def pusher_client():
>> return pusher.Pusher(
>>   app_id='yourid',
>>   key='yourkey',
>>   secret='yoursecret',
>>   cluster='eu',
>>   ssl=True
>> )
>>
>>
>> Then inside your controllers
>>
>> from API_Pusher import pusher_client
>> ...
>> pusher_client().trigger('fileit', 'plannerPesos',  {'message':
>> "PlaySound('ok')"})
>>
>> Em sex., 20 de nov. de 2020 às 07:41, mostwanted 
>> escreveu:
>>
>>> Hey Ramos, I was able to successfully register the app on pusher.com.
>>> towards step 4 its says i should copy this code:
>>> *CODE:*
>>> curl -H "Content-Type: application/json" \
>>>  -H "Authorization: Bearer
>>> 9C9232906DFC6C8F8115926CC30D637945EB75F60467DA77977C399C4235E61C" \
>>>  -X POST "
>>> https://733e2240-aca0-4a12-a5a9-c3b1422b9063.pushnotifications.pusher.com/publish_api/v1/instances/733e2240-aca0-4a12-a5a9-c3b1422b9063/publishes;
>>> \
>>>  -d
>>> '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello,
>>> world!"}}}'
>>>
>>> to my console! Which console is this one? My desktop console? I'm hosted
>>> with pythonanywhere.com, can i use the Bash console in my dashboard?
>>>
>>> On Tuesday, November 17, 2020 at 7:53:20 AM UTC+2 mostwanted wrote:
>>>
 Thanks alot Ramos, think this will work, very little work needs to be
 done here, I'll try it out.

 On Tuesday, November 17, 2020 at 1:06:10 AM UTC+2 Ramos wrote:

> Why reiventing the wheel ???
> https://pusher.com/
>
> I use it with web2py and works like a charm
>
>
> Em seg., 16 de nov. de 2020 às 08:44, mostwanted 
> escreveu:
>
>> So far all I have been able achieve is asking the user for permission
>> to send them notifications & if they accept all that happens is that
>> everytime they open the app they get a greetings notification, achieving
>> that was not complicated because it was straight forward, I placed the 
>> code
>> in my main.js script & it runs everytime the service worker gets 
>> registered.
>>
>> *CODE:*
>> Notification.requestPermission(result => {
>>   if (result === 'granted') {
>> showNotification('Welcome to My App™', 'Everything Services™')
>>   }
>> });
>>
>> function showNotification(title, message) {
>>   if ('Notification' in window) {
>> navigator.serviceWorker.ready.then(registration => {
>>   registration.showNotification(title, {
>> body: message,
>> tag: 'my-app',
>> icon:'/init/static/images/icon_192x192.png',
>> badge:'/init/static/images/icon_128x128.png',
>> vibrate: [200, 100, 200, 100, 200, 100]
>>   });
>> });
>>   }
>> }
>>
>>
>> On Monday, November 16, 2020 at 10:31:10 AM UTC+2 mostwanted wrote:
>>
>>>
>>> Has anyone been able to implement push notifications on their web2py
>>> apps?
>>>
>>> I need a working application with some examples on how to implement
>>> this for one of my applications.
>>>
>>> I've been looking at the "web-push-book (
>>> https://web-push-book.gauntface.com/how-push-works/)" but I cant
>>> put it together in my head.
>>>
>>> What I wanna achieve is relatively basic, I have an applivcation
>>> that offers information on services & products sold in my area, so what 
>>> I
>>> want is to be able to send notifications everytime a new service or 
>>> product
>>> is registered.
>>>
>>> If anyone has any idea on how I can easily implement this please
>>> help me.
>>>
>>> Regards;
>>>
>>> Mostwanted
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/01da1065-f7d3-4394-9014-a424639bef03n%40googlegroups.com
>> 

Re: [web2py] Re: Push Notifications

2020-11-20 Thread mostwanted
Gratitude

On Friday, November 20, 2020 at 10:33:10 AM UTC+2 Ramos wrote:

> create a module inside web2py
> API_Pusher.py
>
> import pusher
>
> def pusher_client():
> return pusher.Pusher(
>   app_id='yourid',
>   key='yourkey',
>   secret='yoursecret',
>   cluster='eu',
>   ssl=True
> )
>
>
> Then inside your controllers
>
> from API_Pusher import pusher_client
> ...
> pusher_client().trigger('fileit', 'plannerPesos',  {'message': 
> "PlaySound('ok')"})
>
> Em sex., 20 de nov. de 2020 às 07:41, mostwanted  
> escreveu:
>
>> Hey Ramos, I was able to successfully register the app on pusher.com. 
>> towards step 4 its says i should copy this code:
>> *CODE:*
>> curl -H "Content-Type: application/json" \
>>  -H "Authorization: Bearer 
>> 9C9232906DFC6C8F8115926CC30D637945EB75F60467DA77977C399C4235E61C" \
>>  -X POST "
>> https://733e2240-aca0-4a12-a5a9-c3b1422b9063.pushnotifications.pusher.com/publish_api/v1/instances/733e2240-aca0-4a12-a5a9-c3b1422b9063/publishes;
>>  
>> \
>>  -d 
>> '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello,
>>  
>> world!"}}}'
>>
>> to my console! Which console is this one? My desktop console? I'm hosted 
>> with pythonanywhere.com, can i use the Bash console in my dashboard?
>>
>> On Tuesday, November 17, 2020 at 7:53:20 AM UTC+2 mostwanted wrote:
>>
>>> Thanks alot Ramos, think this will work, very little work needs to be 
>>> done here, I'll try it out.
>>>
>>> On Tuesday, November 17, 2020 at 1:06:10 AM UTC+2 Ramos wrote:
>>>
 Why reiventing the wheel ??? 
 https://pusher.com/

 I use it with web2py and works like a charm


 Em seg., 16 de nov. de 2020 às 08:44, mostwanted  
 escreveu:

> So far all I have been able achieve is asking the user for permission 
> to send them notifications & if they accept all that happens is that 
> everytime they open the app they get a greetings notification, achieving 
> that was not complicated because it was straight forward, I placed the 
> code 
> in my main.js script & it runs everytime the service worker gets 
> registered.
>
> *CODE:*
> Notification.requestPermission(result => {
>   if (result === 'granted') {
> showNotification('Welcome to My App™', 'Everything Services™')
>   }
> });
>
> function showNotification(title, message) {
>   if ('Notification' in window) {
> navigator.serviceWorker.ready.then(registration => {
>   registration.showNotification(title, {
> body: message,
> tag: 'my-app',
> icon:'/init/static/images/icon_192x192.png',
> badge:'/init/static/images/icon_128x128.png',
> vibrate: [200, 100, 200, 100, 200, 100]
>   });
> });
>   }
> }
>
>
> On Monday, November 16, 2020 at 10:31:10 AM UTC+2 mostwanted wrote:
>
>>
>> Has anyone been able to implement push notifications on their web2py 
>> apps? 
>>
>> I need a working application with some examples on how to implement 
>> this for one of my applications.
>>
>> I've been looking at the "web-push-book (
>> https://web-push-book.gauntface.com/how-push-works/)" but I cant put 
>> it together in my head.
>>
>> What I wanna achieve is relatively basic, I have an applivcation that 
>> offers information on services & products sold in my area, so what I 
>> want 
>> is to be able to send notifications everytime a new service or product 
>> is 
>> registered.
>>
>> If anyone has any idea on how I can easily implement this please help 
>> me.
>>
>> Regards;
>>
>> Mostwanted
>>
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/01da1065-f7d3-4394-9014-a424639bef03n%40googlegroups.com
>  
> 
> .
>
 -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe 

Re: [web2py] How to pass variables to db.executesql?

2020-11-20 Thread Carlos Correia

On 20/11/20 04:56, Alex Glaros wrote:

for example

    where mytable.id = someWeb2PyVariable

thanks,

Alex Glaros
--
Resources:
- http://web2py.com 
- http://web2py.com/book  (Documentation)
- http://github.com/web2py/web2py  (Source 
code)
- https://code.google.com/p/web2py/issues/list 
 (Report Issues)

---
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to web2py+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/fa1cf04c-a01c-40fa-8e00-20295fa46113n%40googlegroups.com 
.


The recomended way is to use parameter 'placeholders', which is a dictionary 
with key-value pairs.


Example:

rows = db.executesql( 'select * from mytable where id = %(id)s', 
placeholders=dict( id=someWeb2PyVariable ) )


Regards,

Carlos Correia
=
MEMÓRIA PERSISTENTE
GSM:  917 157 146 (Signal, WhatsApp)
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt
GnuPG: wwwkeys.eu.pgp.net

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a0c8eec5-6de9-441c-33bc-ba259b831c28%40memoriapersistente.pt.


[web2py] Re: How to pass variables to db.executesql?

2020-11-20 Thread Alex Beskopilny
myid = 10L
sql_str = "xxx  where id=%s;" % (str(myid))
db.executesql( sql_str )

examples:  https://web2py.wordpress.com/tag/db-executesql/

On Friday, November 20, 2020 at 7:56:07 AM UTC+3 alexg...@gmail.com wrote:

> for example 
>
> where mytable.id = someWeb2PyVariable
>
> thanks,
>
> Alex Glaros 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1888eac3-dab9-4182-97a6-dc5bb3caa84fn%40googlegroups.com.


[web2py] Re: Update dropdown list in SQLFORM.grid based on selection in another dropdown list

2020-11-20 Thread Tom Clerckx
OK, I was able to do it with SQLFORM.grid(), using jQuery by:
* registering a change function on the #shelves_genre field
* execute an XMLHttpRequest upon a change of #shelves_genre that updates 
the innerHTML of #shelves_shelve_items

It would be nice however if something similar (registering form-events 
onchange/onselect/...) could be achieved when e.g. creating the form, so 
that you can do it in python instead of having to add the javascript 
functions.



On Friday, November 13, 2020 at 3:53:23 PM UTC+1 Tom Clerckx wrote:

> Hi,
>
> Considering the sample code below.
> I have manually populated the books table with a number of books for 
> different genres.
> Now I can create an entry in the shelves table, using the SQLFORM.grid
> The shelve_items will be shown as a dropdown list with the books that I've 
> added
>
> What I would like is to update the contents of the shelve_items dropdown 
> list in the form, based on the selected genre in that same form.
>
> In the past I did something similar, using a SELECT() box and adding an 
> onchange=ajax(...) call to update a DIV elsewhere in the page.
>
> I was wondering however, if there is a better way to do this directly in 
> the SQLFORM.grid()
>
>
> ===
> index.html
> ===
> {{extend 'layout.html'}}
> {{=form}}
>
> ===
> default.py
> ===
>
> def index():
> form = SQLFORM.grid(db.shelves, user_signature=False)
> return dict(form=form)
>
> ==
> db.py
> ==
> genres = ['thriller', 'sf', 'roman', 'fantasy']
> db.define_table('books',
>   Field('name', 'string'),
>   Field('author', 'string'),
>   Field('genre', 'string', requires=IS_IN_SET(genres)),
>   format='%(name)s'
>   )
> db.define_table('shelves',
>   Field('genre', 'string', requires=IS_IN_SET(genres)),
>   Field('shelve_items', 'reference books'),
>   )
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/61c5b124-cf09-4df5-aa58-dd6589bc63b8n%40googlegroups.com.


Re: [web2py] Re: Push Notifications

2020-11-20 Thread António Ramos
create a module inside web2py
API_Pusher.py

import pusher

def pusher_client():
return pusher.Pusher(
  app_id='yourid',
  key='yourkey',
  secret='yoursecret',
  cluster='eu',
  ssl=True
)


Then inside your controllers

from API_Pusher import pusher_client
...
pusher_client().trigger('fileit', 'plannerPesos',  {'message':
"PlaySound('ok')"})

Em sex., 20 de nov. de 2020 às 07:41, mostwanted 
escreveu:

> Hey Ramos, I was able to successfully register the app on pusher.com.
> towards step 4 its says i should copy this code:
> *CODE:*
> curl -H "Content-Type: application/json" \
>  -H "Authorization: Bearer
> 9C9232906DFC6C8F8115926CC30D637945EB75F60467DA77977C399C4235E61C" \
>  -X POST "
> https://733e2240-aca0-4a12-a5a9-c3b1422b9063.pushnotifications.pusher.com/publish_api/v1/instances/733e2240-aca0-4a12-a5a9-c3b1422b9063/publishes;
> \
>  -d
> '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello,
> world!"}}}'
>
> to my console! Which console is this one? My desktop console? I'm hosted
> with pythonanywhere.com, can i use the Bash console in my dashboard?
>
> On Tuesday, November 17, 2020 at 7:53:20 AM UTC+2 mostwanted wrote:
>
>> Thanks alot Ramos, think this will work, very little work needs to be
>> done here, I'll try it out.
>>
>> On Tuesday, November 17, 2020 at 1:06:10 AM UTC+2 Ramos wrote:
>>
>>> Why reiventing the wheel ???
>>> https://pusher.com/
>>>
>>> I use it with web2py and works like a charm
>>>
>>>
>>> Em seg., 16 de nov. de 2020 às 08:44, mostwanted 
>>> escreveu:
>>>
 So far all I have been able achieve is asking the user for permission
 to send them notifications & if they accept all that happens is that
 everytime they open the app they get a greetings notification, achieving
 that was not complicated because it was straight forward, I placed the code
 in my main.js script & it runs everytime the service worker gets 
 registered.

 *CODE:*
 Notification.requestPermission(result => {
   if (result === 'granted') {
 showNotification('Welcome to My App™', 'Everything Services™')
   }
 });

 function showNotification(title, message) {
   if ('Notification' in window) {
 navigator.serviceWorker.ready.then(registration => {
   registration.showNotification(title, {
 body: message,
 tag: 'my-app',
 icon:'/init/static/images/icon_192x192.png',
 badge:'/init/static/images/icon_128x128.png',
 vibrate: [200, 100, 200, 100, 200, 100]
   });
 });
   }
 }


 On Monday, November 16, 2020 at 10:31:10 AM UTC+2 mostwanted wrote:

>
> Has anyone been able to implement push notifications on their web2py
> apps?
>
> I need a working application with some examples on how to implement
> this for one of my applications.
>
> I've been looking at the "web-push-book (
> https://web-push-book.gauntface.com/how-push-works/)" but I cant put
> it together in my head.
>
> What I wanna achieve is relatively basic, I have an applivcation that
> offers information on services & products sold in my area, so what I want
> is to be able to send notifications everytime a new service or product is
> registered.
>
> If anyone has any idea on how I can easily implement this please help
> me.
>
> Regards;
>
> Mostwanted
>
 --
 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.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/web2py/01da1065-f7d3-4394-9014-a424639bef03n%40googlegroups.com
 
 .

>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/ca28be9e-6720-4993-9f68-1a42cf57a2c1n%40googlegroups.com
>