[web2py] How to customize widgets to act like Onsen UI components

2017-09-15 Thread Bernardo Leon
I have been researching about UI Frameworks and stumbled upon Onsen UI 
. It seems easy and provides good results but to use 
this UI Framework I need to use their components which are html tags.

If I have a field that is rendered as an html input how can I customize its 
widget so I can use  instead of  and so on? Thank you!

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


Re: [web2py] Re: Support for BIT(1) as boolean?

2017-09-15 Thread 'Yan Wong' via web2py-users
The following seems to work, by the way (modified from 
https://groups.google.com/forum/#!topic/web2py/TZsLnytjqhA)

## allow mysql tinyint
from gluon.dal import SQLCustomType
boolean = SQLCustomType(
 type ='boolean',
 native='TINYINT(1)',
 encoder = (lambda x: 1 if x else 0),
 decoder = (lambda x: True if x else False)
)

then

Field('xxx', type = boolean,...)

-- 
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: Stopping a loaded component

2017-09-15 Thread Francisco Ribeiro
Found a solution for this which is to add the 'w2p_component_stop' class 
onto the div, as follows:

  $('#my_target').addClass('w2p_component_stop');
  $('#my_target').html(''); 

this will break the infinite loop set by the call in my original post and 
then will hide the content left from the last iteration of the loop.

Francisco


On Friday, 15 September 2017 03:35:06 UTC+1, Francisco Ribeiro wrote:
>
> Hi all,
>
> I have a monitoring component in which my app continuously grabs data from 
> the database through a controller which is triggered by a javascript call 
> as follows:
>
> $.web2py.component("{{=URL('controller', 'my_function.load')}}", 
> "my_target", timeout=2000, times='Infinity');
>
> As you can see, this component is calling my controller every 2s for an 
> infinite number of times and it works well.
>
> Now, I would like to add an option to allow the user to arbitrarily stop 
> this monitoring component but I could not find a way to trap and stop the 
> JS call above (nor its reload_check) once the page and the component are 
> loaded. Any ideas?
>
> Thank you
> Kind regards,
> Francisco
>

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


Re: [web2py] Re: Support for BIT(1) as boolean?

2017-09-15 Thread 'Yan Wong' via web2py-users


On Monday, 11 September 2017 00:08:00 UTC+1, Massimo Di Pierro wrote:
>
> what adapter are you using. What is your URI string (without passwords 
> please)?
>

By the way, starting web2py using Rocket now says 
/usr/local/lib/python2.7/site-packages/pymysql/cursors.py:166: 
Warning: (3090, u"Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It 
will be removed in a future release."), but I guess you know that.

-- 
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: Email with body from 'response.render'

2017-09-15 Thread tomasz bandura
Thank you ,
solved

Tom

2017-09-14 23:40 GMT+02:00 黄祥 :

> had you tried to use *.html file?
> e.g.
> *controllers/default.py*
> def mail():
> table_id = request.args(0)
> message = response.render('templates/mail/test.html', dict(table_id =
> table_id) )
>
> *views/templates/mail/test.html*
> 
> 
> 
> 
> test {{=table_id}}
> 
> 
>
> 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.
>

-- 
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: web2py 2.15.4 is OUT

2017-09-15 Thread Anthony
Looks like there's already an issue about that: 
https://github.com/web2py/pydal/issues/480

Anthony

On Thursday, September 14, 2017 at 11:56:26 PM UTC-4, 黄祥 wrote:
>
> *e.g.*
> *models/db.py*
> def __before_insert_cash_in(f):
> chart_of_account = int(f['chart_of_account'] )
>
> # get default value for branch field from coa table field branch
> query_coa = (db.chart_of_account.id == chart_of_account) 
> row_coa = db(query_coa).select().first()
> #f['branch'] = '%s' % (row_coa.branch)
> f['branch'] = row_coa.branch
>
> db.cash_in._before_insert.append(__before_insert_cash_in)
> db.cash_in.branch.required = True # set True if before insert is fixed 
> like in 2.14.6
>
> *error traceback :*
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 219, in 
> restricted
> exec(ccode, environment)
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/transaction.py", 
> line 86, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 414, in 
> 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/controllers/transaction.py", 
> line 51, in cash_in
> db.cash_in.insert(**db.cash_in._filter_fields(form.vars) )
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", line 
> 731, in insert
> row = self._fields_and_values_for_insert(fields)
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", line 
> 709, in _fields_and_values_for_insert
> 'Table: missing required field: %s' % name)
> RuntimeError: Table: missing required field: branch
>
> *temporary solution :*
> db.cash_in.branch.required = False
> or
> db.cash_in.branch.default = 1
>
> thanks and 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: Storing stuff on request object

2017-09-15 Thread Anthony
It should be OK. The only potential issue is if the framework adds 
request.some_stuff in the future -- then your app code would be overwriting 
an attribute used by the framework (unlikely to be an issue if you avoid 
generic names).

Anthony

On Friday, September 15, 2017 at 1:10:06 AM UTC-4, Brendan Barnwell wrote:
>
> Is it considered kosher for controller functions to add their own custom 
> data to the request object?  I didn't see anything in the docs about this.  
> For instance if a controller wants to do request.some_stuff = 123, is that 
> "allowed"?
>
> The reason for this is that I have some library functions called by 
> controllers that may need access to information that could be in the 
> request, or they can fall back to a default.  I would prefer not to make 
> these library functions accept this extra information as a parameter, but 
> rather have them look to see if it is available in the current request, and 
> use it if so, otherwise fall back to the default.  This information would 
> not normally be available on the request object, but is derived from 
> request.args, so the controller function could store this "processed" 
> version of args on the request object for use by other functions later.  (I 
> don't want to store it in session because it really is supposed to be 
> request-local and shouldn't persist from one request to another.)
>

-- 
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: caching variable data sample

2017-09-15 Thread Anthony
Forgot about that. It's documented here: 
http://web2py.com/books/default/chapter/29/04/the-core?search=lazy_cache#Warning--Do-not-use-the-current-object-in-global-scope-in-a-module.
 
Yes, that would be the way to go if you want to move the function to a 
module.

Anthony

On Friday, September 15, 2017 at 8:15:21 AM UTC-4, Pierre wrote:
>
> the more digging the deeper one gets :
>
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/cache$20in$20module/web2py/AZa5Boj3y3E/_BPMTdXwSaMJ
>
> and here is the *cache_this*  module version :
>
> from gluon.cache import lazy_cache
>
> @lazy_cache('data_sample', time_expire=60, cache_model='redis')
> def cache_this():
> ...
> rows = db(db.atable.id > 0).select(limitby=limitby, cacheable=True)
> return rows
>
>
> This seems to do the trick.  Is it 'kosher' ?
>

-- 
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: caching variable data sample

2017-09-15 Thread Anthony
On Friday, September 15, 2017 at 6:15:44 AM UTC-4, Pierre wrote:
>
> actually the real function is a little more complex since it returns rows 
> plus other datas that don't require caching. I tried to move the cache_this 
> function to a module (don't know if this is orthodox) but then i get a 
> decorator error:
>
> @current.cache('data_sample', time_expire=60, 
> cache_model=current.cache.redis)
> attributeError cache object has not attribute redis
>

Hard to say what's going wrong without seeing your code. But you don't 
necessarily have to put the function in a module -- it can go in a model or 
even in the controller (if the function takes no arguments, start its name 
with a double underscore to prevent it from being exposed as an action). 
You can even define the function inside the controller function that calls 
it if that's the only place it is needed.

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 to get rid if the /init/default/ in the URL?

2017-09-15 Thread Anthony
See 
http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system. 
In routes.py, something like:

routers = dict(
BASE = dict(
default_application='init',
default_controller='default',
default_function='index'
),
init = dict(
functions=['list', 'of', 'functions', 'in', 'default', 'controller']
),
)

Anthony

On Friday, September 15, 2017 at 2:43:11 AM UTC-4, Joe wrote:
>
> I've been trying to do this for so long, but with *pythonanywhere* 
> hosting, it doesn't seem to be possible to get rid of the *init/default/* 
> part of the URL.
>
> I think, this nested sub-directories structure is not optimal for SEO and 
> also makes it difficult to place the *robot,txt* and *sitmap.xml* in a 
> way that it's easy to find for search engines?
> I am not a SEO expert, but I read that this kind of URL structure is not 
> optimal.
>
> When I looked at the Web2py website, *which I think is also hosted by 
> pythonanywhere*, I noticed that, www.web2py.com has not solved this 
> problem either i.e. http://www.web2py.com/init/default/support
>
> Is there any way to change this URL structure?
>

-- 
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: caching variable data sample

2017-09-15 Thread Pierre
the more digging the deeper one gets :

https://groups.google.com/forum/?fromgroups#!searchin/web2py/cache$20in$20module/web2py/AZa5Boj3y3E/_BPMTdXwSaMJ

and here is the *cache_this*  module version :

from gluon.cache import lazy_cache

@lazy_cache('data_sample', time_expire=60, cache_model='redis')
def cache_this():
...
rows = db(db.atable.id > 0).select(limitby=limitby, cacheable=True)
return rows


This seems to do the trick.  Is it 'kosher' ?

-- 
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: caching variable data sample

2017-09-15 Thread Pierre
very True: productivity rules and I am far below modern 
standards(more or less the 'Bangladesh level'):)

Le jeudi 14 septembre 2017 16:55:29 UTC+2, Anthony a écrit :
>
>  
> Maybe you should have asked a week ago. ;-)
>
> 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: caching variable data sample

2017-09-15 Thread Pierre
actually the real function is a little more complex since it returns rows 
plus other datas that don't require caching. I tried to move the cache_this 
function to a module (don't know if this is orthodox) but then i get a 
decorator error:

@current.cache('data_sample', time_expire=60, 
cache_model=current.cache.redis)
attributeError cache object has not attribute redis

Le jeudi 14 septembre 2017 16:49:49 UTC+2, Anthony a écrit :
>
> Looks like you want to cache the results of the entire function -- so why 
> not do that:
>
> @cache(some_key, time_expire=60, cache_model=cache.ram)
> def cache_this():
> ...
> rows = db(db.atable.id > 0).select(..., cacheable=True)
> return dict(rows=rows)
>
> Just be sure to set cacheable=True, which will make the entire Rows object 
> cacheable.
>
> 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: Why web2py server hangs/freeze?

2017-09-15 Thread Dave S


On Thursday, September 14, 2017 at 10:40:46 PM UTC-7, Narendra Kumar wrote:
>
> Hi,
>
> As suggested in previous posts, I deploy my web2py application on apache 
> sever. I use scripts/setup-web2py-debian-sid.sh file to make setup on local 
> server, which exists in web2py folder and follow steps defined on URL 
> http://web2py.com/books/default/chapter/29/13/deployment-recipes#One-step-production-deployment
> .
> But Still I get the server down issue.
>
>
> Regards
> Narendra
>
>
>> If you're using Apache, then you should be looking in the Apache log 
files to see what it thinks happened.  If you find something in the log 
files that you don't understand, or that you think points to a bug in 
web2py, post that information here and we'll try to help.  (Well, I won't, 
because I'm going the nginx route, not having any existing Apache legacy to 
 live with, but there are several experience Apache users in the group.)

/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] How to get rid if the /init/default/ in the URL?

2017-09-15 Thread Joe
I've been trying to do this for so long, but with *pythonanywhere* hosting, 
it doesn't seem to be possible to get rid of the *init/default/* part of 
the URL.

I think, this nested sub-directories structure is not optimal for SEO and 
also makes it difficult to place the *robot,txt* and *sitmap.xml* in a way 
that it's easy to find for search engines?
I am not a SEO expert, but I read that this kind of URL structure is not 
optimal.

When I looked at the Web2py website, *which I think is also hosted by 
pythonanywhere*, I noticed that, www.web2py.com has not solved this problem 
either i.e. http://www.web2py.com/init/default/support

Is there any way to change this URL structure?

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