[web2py] Re: Why input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Andriy
I completely agree. It would be better if this will be fixed. I never 
noticed this behavior until I`ve got to the case where I need to keep white 
spaces in front and at the back of the input field.

-- 
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: Python Social Auth - example site working with downlevel version of PSA

2017-02-10 Thread Joe Barnhart
Hi Don --

Just getting around to playing with this and having fun...  Being a novice 
at python social-auth-core as well as your code, setting it up is slow 
going.

Is your Git repo just an example of how to add this, or is this a w2p 
plugin of sorts?  My intent is to add the minimum needed to my own site to 
get social auth working, or course.

Anyway, happy to get any tips you may share.  I think I've gotten 
social-auth-core loaded on my mac so it should all be clear sailing now... 
heh heh...

-- Joe


On Wednesday, January 11, 2017 at 2:27:59 PM UTC-8, Donald McClymont wrote:
>
> Just an update that in line with the re-organization and new site for 
> python social auth (https://github.com/python-social-auth) I have made a 
> new repository https://github.com/DonaldMcC/social-app-web2py with 
> updated import statements etc.  The plug-in has been tested with google, 
> facebook, twitter and microsoft providers and demo is available at 
> http://www.netdecisionmaking.com/socialappweb2py/default/index  
>
> It's still entirely based on https://github.com/bnmnetp/w2p-social-auth but 
> just rolled forward in line with psa changes and far from fully tested.
>
>
>
> On Sunday, November 6, 2016 at 11:38:45 PM UTC, Donald McClymont wrote:
>>
>> Not  a great deal from me - it is still generally working fine with 
>> latest version of psas on www.netdecisionmaking.com - this is really a 
>> hobby project to demo a different approach to running the world or any part 
>> of it.  Only change I have made recently was to swap-out mozilla persona 
>> and replace with google+ as Mozilla are turning off persona at the end of 
>> November.  That does however give me an issue that google+ authentication 
>> works but doesn't populate the users email which obviously then means users 
>> logging in this way will not get mails.  I need to look at how to add 
>> additional steps to query this after authentication at some point.
>>
>> Regards
>> Donald
>>
>>
>>
>> On Saturday, November 5, 2016 at 3:12:37 PM UTC, mweissen wrote:
>>>
>>> It is a very interesting project. Are there any news?
>>>
>>> Am Freitag, 24. Juni 2016 00:45:51 UTC+2 schrieb Donald McClymont:

 Just a further note that following some further updating I can login 
 via Facebook, Twitter, Google (using Mozilla Persona) and Microsoft 
 accounts.  There is a test site at 
 https://www.netdecisionmaking.com/w2ppsatest if anyone wants to take a 
 look without setting up themselves.  I am not really planning to do much 
 more with this unless there are issues or suggestions on what needs done 
 next.

 Regards
 Donald

 On Friday, June 10, 2016 at 9:49:05 PM UTC+1, Donald McClymont wrote:
>
> I have now forked and pruned w2p-social-auth at the following:  
> https://github.com/DonaldMcC/w2p-social-auth  basically only two 
> changes of substance:
>
> 1 It now uses appconfig to store the keys in so you will need to be on 
> a fairly recent web2py if you want to use this approach - alternatively 
> just put the keys directly into db.py but this obviously isn't a best 
> practice with github for sharing code.
> 2 I have removed the version of python social auth - I think 0.1.24 
> which was included in previous file which means a lot less code - as far 
> as 
> I can tell this was unmodified however it was not best if the plugin was 
> importing from their and internal imports within PSA were from the 
> installed version of that I had installed as a python package.
>
> Having done the above - I have successfully completed a basic login 
> with the revised plugin and PSA 0.2.19 which is the latest version use 
> Mozilla Persona as the provider - I will need to move it onto an actual 
> site rather than localhost to test a few other providers but that will be 
> next week at the earliest and I still have a very limited knowledge of 
> Auth, PSA or the actual code in the plug-in - so it would be good if 
> people 
> that do could perhaps chip-in with suggestions on where this should be 
> heading and how it should be properly tested that would be appreciated.
>
> Donald
>
> On Monday, June 6, 2016 at 10:43:18 PM UTC+1, Donald McClymont wrote:
>>
>> Sounds good - possibly worth trying to contact someone on the psa 
>> team as well.  I think we need to decide whether an updated plug-in is 
>> the 
>> best way to go or whether this should be a core part of either PSA or 
>> web2py.  The plug-in may be the quickest way forward but it might well 
>> be 
>> better to go another route as it reduces the risk of being back in the 
>> same 
>> situation we have now where changes in PSA mean the plug-in doesn't work 
>> with latest versions.
>>
>> There was some previous dialogue on wihether python social auth or 
>> authomatic was the better approach 

Re: [web2py] Re: japronto

2017-02-10 Thread Richard Vézina
If you want easy performance improvement (easy is relative here) you can
try to use pypy interpreter or ironpython, ironpython don't have GIL, pypy
suppose to execute 5x faster the same python code (http://speed.pypy.org/)...
Other interpreters :
http://docs.python-guide.org/en/latest/starting/which-python/

The problem that happen often is that dependencies are not pypy
"compliant".

But depending of the app you have wrote (if few dependency) it may be a
proper path for you...

Good luck

Richard

On Fri, Feb 10, 2017 at 10:25 AM, Ron Chatterjee 
wrote:

> Thank you for explaining Richard. That's very nice of you. May be we can
> have a module that makes some of web2py code executable for faster
> processing. Something for someone to look at may be.
>
> On Monday, February 6, 2017 at 4:39:49 PM UTC-5, Richard wrote:
>>
>> I guess partly for the same reason we can't make cpython faster (GIL -
>> https://wiki.python.org/moin/GlobalInterpreterLock)... But not only for
>> this reason of course. But let ask the question differently, why is
>> clienteside app faster? You move computer processing load to client in many
>> part, you reduce the size of the data that have to move back and forth as
>> you only have to transmit json instead of the whole DOM. Also, web2py can
>> be really fast, it all depends how you use it. For instance if you don't
>> need auth on every page you can avoid a lot of queries to the backend. The
>> same is true, you can use auth.has_membership() which triggers many queries
>> or you can initialize a varibale that you can cache for the duration of the
>> session. You use to check membership against this cached variable, that way
>> you avoid many queries to the backend which is most probably the bottleneck
>> of any application. The drawback is that you can't modify users privileges
>> once they are connected without maintaining the the cache variable up to
>> date (which is not that difficult you just have to make sure you update it
>> each time you manipulate membership) or ask them to logout and login again
>> when you modify their membership.
>>
>> At some point if you really need more speed and you already have make it
>> sure your app is lean and properly tuned, you have to look on the side of
>> replication and redundancy...
>>
>> You also have to gave a look at "model-less" app paradigm which involve
>> moving models definition into module which have some drawback. Before, that
>> make sure you don't defined any function into you models files, since the
>> code defined there is execute at each request. You can also activate lazy
>> table (http://web2py.com/books/default/chapter/29/06/the-database-
>> abstraction-layer#Lazy-Tables--a-major-performance-boost).
>>
>> Also, notice that SSL has it pound in the balance... I had issue recently
>> since Chrome start to trigger error for certificate using SHA-1 hashing
>> key... I had to read and create a new private key... The out come despite
>> having a new secure certificate that pass Chrome validation was that using
>> Elliptic Curve key (https://www.digicert.com/ecc.htm) ECDSA 256 bits
>> that give an ssl certificate as secure as RSA 2048 bits (at least it said
>> to be as secure) which make ssl data encryption much faster. I wasn't able
>> to properly benchmark the speed improvement, but it seems as much as 25%
>> faster them my previous certficate.
>>
>> Finally, Massimo is looking to find a solution that will allow us develop
>> client side app within web2py with help of ractivejs/vuejs (vuejs seems
>> much easier to pickup than ractive and much more well supported so I guess
>> it will win the battle). He had propose proof of concept in the past :
>>
>> https://github.com/mdipierro/w3
>>
>> But until now there were no traction from core developpers. Basically
>> because they are buzzy fixing issues and improving stuff (and speed :
>> https://groups.google.com/d/msg/web2py-developers/j6uxYMxo
>> 5qI/OQPEpJ5CWIoJ), porting web2py over python 3 (
>> https://github.com/web2py/web2py/issues/1353) which turn to be a big
>> undertake as we didn't have a new release for months now.
>>
>> From what I do  understand, and I didn't have much time to follow and
>> contribute much recently, we are trying to make web2py build python 3
>> compliant then we will undertake others challenges.
>>
>> In either way, once we will have web2py/web3py we will have to rewrite
>> (your are not forced because you will still be able to use python 2) our
>> apps, so Massimo is planning to seize the opportunity to break the promise
>> of backward compatibility and introducing client side goodies into web2py.
>> At least it's my understanding of what is going on rigth now.
>>
>> Have a good day!
>>
>> Richard
>>
>>
>> On Mon, Feb 6, 2017 at 11:23 AM, Ron Chatterjee 
>> wrote:
>>
>>> Why can't we make web2py faster ?
>>>
>>>
>>> On Thursday, February 2, 2017 at 9:36:34 AM UTC-5, mcm wrote:


 I agree 

[web2py] Re: reference_field_value = None

2017-02-10 Thread Pierre
thanks guys

for sure a minor problem  :)  i am afraid the most difficult is 
comingan "iceberg" or something equivalent

-- 
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: routes onerror not working for xhr

2017-02-10 Thread Anthony
Could be a bug. Please file an issue on Github.

On Thursday, February 9, 2017 at 7:33:30 PM UTC-5, MDSIII wrote:
>
> I have tried implementing routes_onerror in routes.py like this:
>
> routes_onerror = [
> (r'welcome/500', r'/welcome/default/on500'), 
> (r'welcome/400', r'/welcome/default/on400')
> ]
>
> and added these functions in default.py controller:
>
> def raise500():
>
> raise ValueError('random internal error')
>
> def raise400():
>
> print "in raise 400"
> raise HTTP(400, 'not the droids')
>
> def on500():
> 
> print "alternate handler for 500"
> return "something useful, maybe ticket number encoded in json?"
>
> def on400():
> 
> print "in on 400"
> return "handler for 400s"
>
> def myform():
> form = FORM('blah', INPUT(_name='name'),
> INPUT(_type='submit'), _action=URL('raise400'))
> 
> return response.render({'form': form})
>
>
> If I visit the "raise" urls from a browser everything works as expected 
> (although I thought I'd see redirects in DevTools:network and I'm not 
> seeing that, just immediate responses). Even the response status is correct.
> But if I post from a form (or use python requests lib) then the response 
> is status 500 and response text = "Server Error"
> Also I get this traceback from the console running the web2py server:
>
> ERROR:Rocket.Errors.Thread-2:Traceback (most recent call last):  
>  
>   File "D:\web2py\gluon\rocket.py", line 1337, in run
> self.run_app(conn)   
>  
>   File "D:\web2py\gluon\rocket.py", line 1838, in run_app
> output = self.app(environ, self.start_response)  
>  
>   File "D:\web2py\gluon\main.py", line 653, in app_with_logging  
> ret[0] = wsgiapp(environ, responder2)
>  
>   File "D:\web2py\gluon\main.py", line 564, in wsgibase  
> return wsgibase(new_environ, responder)  
>  
>   File "D:\web2py\gluon\main.py", line 534, in wsgibase  
> if request.body: 
>  
>   File "D:\web2py\gluon\globals.py", line 281, in body   
> raise HTTP(400, "Bad Request - HTTP body is incomplete") 
>  
> HTTP: 400 BAD REQUEST
>
> Am I doing something wrong or is routes on error not supposed to handle 
> POST?
>

-- 
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 input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Anthony
On Friday, February 10, 2017 at 3:10:54 PM UTC-5, Anthony wrote:
>
> On Friday, February 10, 2017 at 11:45:39 AM UTC-5, Andriy wrote:
>>
>> Thanks, Anthony. lambda that you posted works like you described, I`ll 
>> use it.
>>
>> But if I remove* requires=[IS_NOT_EMPTY* validator completely, the 
>> form.vars still returns name without spaces. Does it apply some validation 
>> without "requires" set, by default, and removing spaces?
>>
>
> The default validator for a "string" field is IS_EMPTY_OR(IS_LENGTH(...)), 
> and the IS_EMPTY_OR validator also strips the whitespace.
>

Note, I submitted an issue, as I consider this a bug: 
https://github.com/web2py/web2py/issues/1570

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 input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Anthony
On Friday, February 10, 2017 at 11:45:39 AM UTC-5, Andriy wrote:
>
> Thanks, Anthony. lambda that you posted works like you described, I`ll use 
> it.
>
> But if I remove* requires=[IS_NOT_EMPTY* validator completely, the 
> form.vars still returns name without spaces. Does it apply some validation 
> without "requires" set, by default, and removing spaces?
>

The default validator for a "string" field is IS_EMPTY_OR(IS_LENGTH(...)), 
and the IS_EMPTY_OR validator also strips the whitespace.

Anthony 

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


Re: {Disarmed} [web2py] Re: Once again stuck with a calculation

2017-02-10 Thread Greenpoise
Perhaps its not the frameworks fault, perhaps the term MVC should not be 
applicable to all the frameworks or in this case to the flexibility of 
web2py?  In any case it is certainly very interesting. I for one cant see 
all the code being ran down in the view specially if there is going to be 
some sort of visual customization. It just forms all sorts of clutter.

Thanks for the input guys


 

On Thursday, February 9, 2017 at 5:18:14 PM UTC-8, Carlos Cesar Caballero 
wrote:
>
> Let me disagree with Leonel.
>
> In MVC, business logic should be handled by model and application logic by 
> controller, this is also called "fat models and thin controllers", by 
> example, a model should know by itself how to calculate his own {put here: 
> price, length, age, pretty hard calculation using my super algorithm}, and 
> the controller should only worry about giving to the model the data he 
> needs.
>
> In fact, a MVC purist will say that code like sqlform.factory does not 
> belong to controller (this is something that I partially disagree when we 
> are using frameworks like web2py).
>
> Greetings.
> El 09/02/17 a las 18:01, Leonel Câmara escribió:
>
> Yes they should be done in the controller, web2py mostly follows the MVC 
> architecture so most of the business logic is supposed to be in the 
> controller. Notice that if you put the calculations in the view for 
> instance "product_calc.html" then you would not have the result available 
> in "product_calc.pdf" or "product_calc.json" or some other view that you 
> could do for this logic. That said, it's kind of a matter of taste, for 
> instance, you may feel strongly that a given calculation is only useful for 
> a given view so you can start by putting it there and later move it to the 
> controller if you find out that you were wrong and you will need it 
> elsewhere.
> -- 
> 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 *MailScanner ha detectado un intento de fraude en 
> la siguiente página web "groups.google.com". No confíe en esta página web:* 
> *MailScanner 
> ha detectado un intento de fraude en la siguiente p�gina web 
> "groups.google.com". No conf�e en esta p�gina web:* 
> https://groups.google.com/d/optout .
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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: info: interesting hack, sort in IS_IN_DB lists with regard to current locale

2017-02-10 Thread Anthony
Does IS_IN_DB(sort=True) not do what you want? If not, it might be a bit 
simpler to instead override the options() method of IS_IN_DB and just 
provide an alternative function in place of options_sorter() (or, if you 
want an alternative options_sorter in all cases, you could just monkey 
patch it in gluon.validators).

Anthony

On Friday, February 10, 2017 at 12:08:58 PM UTC-5, Mirek Zvolský wrote:
>
> ... or to any other special order.
>
> For me was creazy that I was not able to sort items (names) in IS_IN_DB 
> lists alphabetically.
> IS_IN_DB has lot of undocumented parameters but I think nothing can help.
>
> Of course when running from Postgres, you will receive records with proper 
> locale order.
> However with SQLite you need (maybe) a hacked and special compiled SQLite 
> to have correct order.
> Otherwise you start with uppercase ascii, then follow lowercase ascii, and 
> at the end are accented (non-ascii) characters. Crazy.
>
> Now I use this hack in my model:
>
> import locale
> locale.setlocale(locale.LC_ALL, 'cs_CZ.UTF-8')
>
>
> class IS_IN_DB_(IS_IN_DB):
> def build_set(self):
> super(IS_IN_DB_, self).build_set()
> records = [(lbl, self.theset[pos]) for pos, lbl in enumerate(self.
> labels)]
> records.sort(key=lambda x: locale.strxfrm(x[0]))
> self.labels = [rec[0] for rec in records]
> self.theset = [rec[1] for rec in records]
>
>
> db.define_table('payment',
> Field('idauth_user', 'reference auth_user', requires=IS_EMPTY_OR(
> IS_IN_DB_(db, db.auth_user.id, '%(nick)s'))),
> ...)
>
>
>
> Not optimal, but works !
>
>

-- 
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] info: interesting hack, sort in IS_IN_DB lists with regard to current locale

2017-02-10 Thread Mirek Zvolský
... or to any other special order.

For me was creazy that I was not able to sort items (names) in IS_IN_DB 
lists alphabetically.
IS_IN_DB has lot of undocumented questions but I think nothing can help.

Of course when running from Postgres, you will receive records with proper 
locale order.
However with SQLite you need (maybe) a hacked and special compiled SQLite 
to have correct order.
Otherwise you start with uppercase ascii, then follow lowercase ascii, and 
at the end are accented (non-ascii) characters. Crazy.

Now I use this hack in my model:

import locale
locale.setlocale(locale.LC_ALL, 'cs_CZ.UTF-8')


class IS_IN_DB_(IS_IN_DB):
def build_set(self):
super(IS_IN_DB_, self).build_set()
records = [(lbl, self.theset[pos]) for pos, lbl in enumerate(self.
labels)]
records.sort(key=lambda x: locale.strxfrm(x[0]))
self.labels = [rec[0] for rec in records]
self.theset = [rec[1] for rec in records]


db.define_table('payment',
Field('idauth_user', 'reference auth_user', requires=IS_EMPTY_OR(
IS_IN_DB_(db, db.auth_user.id, '%(nick)s'))),
...)



Not optimal, but works !

-- 
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: reference_field_value = None

2017-02-10 Thread Anthony
Also, if you set notnull after the table was initially created, I don't 
think it will be changed (you need to handle such changes outside of 
web2py).

Anthony

On Friday, February 10, 2017 at 10:40:37 AM UTC-5, Leonel Câmara wrote:
>
> Do you have NOTNULL=True or notnull=True? Only the latter will work.
>

-- 
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: table._before_insert.append() wrong behaviour?

2017-02-10 Thread Anthony

>
> ret = self.table.insert(**fields)
>

Should probably be

ret = self.table.insert(**fields) or False

as we want ret (and self.accepted) to end up a boolean rather than 0.

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 input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Andriy
Thanks, Anthony. lambda that you posted works like you described, I`ll use 
it.

But if I remove* requires=[IS_NOT_EMPTY* validator completely, the 
form.vars still returns name without spaces. Does it apply some validtion 
without it by default and removing spaces?

-- 
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: table._before_insert.append() wrong behaviour?

2017-02-10 Thread Leonel Câmara
Humm this may actually be considered a SQLFORM bug. Since it just puts 
whatever the insert returns in self.vars.id and never checks if it is 
actually an id or zero, zero actually means it failed because of a 
before_insert such as yours.

The bug is here:
https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L1857

It should be:

ret = self.table.insert(**fields)

if ret:
self.vars.id = ret



-- 
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 input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Anthony
It is actually the IS_NOT_EMPTY validator that strips the whitespace (it 
does this so a string containing only spaces will be considered empty). You 
can either create your own custom validator, or do something like:

requires=lambda v: (v, IS_NOT_EMPTY()(v)[1])

The above returns the original value along with the error message (if any) 
from IS_NOT_EMPTY.

Anthony

On Friday, February 10, 2017 at 8:11:18 AM UTC-5, Andriy wrote:
>
> fields = [ Field('name', 'string', default=defaults['name'], 
> requires=[IS_NOT_EMPTY(error_message='Enter name')]), ]
> form = SQLFORM.factory(*fields, _class="uk-form uk-form-horizontal", 
> _name="edit_form")
> if form.process(hideerror=True).accepted:
> print (form.vars.name, request.vars.name)
>
> If I enter "Bob " (with trailing space in input field) I get printed:
> ('Bob', 'Bob ')
>
> form.vars.name looses trailing space and I didn`t ask for this. 
> request.vars.name is correct. 
>
> I do *form.vars.name  = request.vars.name 
> * later in my code to counter this. I need all 
> spaces preserved as they are entered. I didn`t find any explanation for 
> this in the help/book.
>

-- 
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: reference_field_value = None

2017-02-10 Thread Leonel Câmara
Do you have NOTNULL=True or notnull=True? Only the latter will work.

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

2017-02-10 Thread Ron Chatterjee
Thank you for explaining Richard. That's very nice of you. May be we can 
have a module that makes some of web2py code executable for faster 
processing. Something for someone to look at may be. 

On Monday, February 6, 2017 at 4:39:49 PM UTC-5, Richard wrote:
>
> I guess partly for the same reason we can't make cpython faster (GIL - 
> https://wiki.python.org/moin/GlobalInterpreterLock)... But not only for 
> this reason of course. But let ask the question differently, why is 
> clienteside app faster? You move computer processing load to client in many 
> part, you reduce the size of the data that have to move back and forth as 
> you only have to transmit json instead of the whole DOM. Also, web2py can 
> be really fast, it all depends how you use it. For instance if you don't 
> need auth on every page you can avoid a lot of queries to the backend. The 
> same is true, you can use auth.has_membership() which triggers many queries 
> or you can initialize a varibale that you can cache for the duration of the 
> session. You use to check membership against this cached variable, that way 
> you avoid many queries to the backend which is most probably the bottleneck 
> of any application. The drawback is that you can't modify users privileges 
> once they are connected without maintaining the the cache variable up to 
> date (which is not that difficult you just have to make sure you update it 
> each time you manipulate membership) or ask them to logout and login again 
> when you modify their membership.
>
> At some point if you really need more speed and you already have make it 
> sure your app is lean and properly tuned, you have to look on the side of 
> replication and redundancy...
>
> You also have to gave a look at "model-less" app paradigm which involve 
> moving models definition into module which have some drawback. Before, that 
> make sure you don't defined any function into you models files, since the 
> code defined there is execute at each request. You can also activate lazy 
> table (
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Lazy-Tables--a-major-performance-boost
> ).
>
> Also, notice that SSL has it pound in the balance... I had issue recently 
> since Chrome start to trigger error for certificate using SHA-1 hashing 
> key... I had to read and create a new private key... The out come despite 
> having a new secure certificate that pass Chrome validation was that using 
> Elliptic Curve key (https://www.digicert.com/ecc.htm) ECDSA 256 bits that 
> give an ssl certificate as secure as RSA 2048 bits (at least it said to be 
> as secure) which make ssl data encryption much faster. I wasn't able to 
> properly benchmark the speed improvement, but it seems as much as 25% 
> faster them my previous certficate.
>
> Finally, Massimo is looking to find a solution that will allow us develop 
> client side app within web2py with help of ractivejs/vuejs (vuejs seems 
> much easier to pickup than ractive and much more well supported so I guess 
> it will win the battle). He had propose proof of concept in the past :
>
> https://github.com/mdipierro/w3
>
> But until now there were no traction from core developpers. Basically 
> because they are buzzy fixing issues and improving stuff (and speed : 
> https://groups.google.com/d/msg/web2py-developers/j6uxYMxo5qI/OQPEpJ5CWIoJ), 
> porting web2py over python 3 (https://github.com/web2py/web2py/issues/1353) 
> which turn to be a big undertake as we didn't have a new release for months 
> now.
>
> From what I do  understand, and I didn't have much time to follow and 
> contribute much recently, we are trying to make web2py build python 3 
> compliant then we will undertake others challenges. 
>
> In either way, once we will have web2py/web3py we will have to rewrite 
> (your are not forced because you will still be able to use python 2) our 
> apps, so Massimo is planning to seize the opportunity to break the promise 
> of backward compatibility and introducing client side goodies into web2py. 
> At least it's my understanding of what is going on rigth now.
>
> Have a good day!
>
> Richard
>
>
> On Mon, Feb 6, 2017 at 11:23 AM, Ron Chatterjee  > wrote:
>
>> Why can't we make web2py faster ?
>>
>>
>> On Thursday, February 2, 2017 at 9:36:34 AM UTC-5, mcm wrote:
>>>
>>>
>>> I agree nice and could be useful in speedy services and we should see if 
>>> it can be used in front of web2py.
>>>
>>> But it is more important for the long term that we start to think about 
>>> leveraging HTTP/2 soon
>>>
>>> Il giorno mercoledì 1 febbraio 2017 16:23:46 UTC+1, Anthony ha scritto:

 On Wednesday, February 1, 2017 at 4:54:31 AM UTC-5, Massimo Di Pierro 
 wrote:
>
> I just discovered this:
>
> https://github.com/squeaky-pl/japronto
>
> I am impressed. I like the speed and the semantics.
>

 Seems interesting, though the benchmarks seem a bit contrived. It does 

Re: [web2py] Re: table._before_insert.append() wrong behaviour?

2017-02-10 Thread Marvi Benedet
I think the message is misleading...




2017-02-10 13:09 GMT+01:00 Leonel Câmara :

> I don't see the problem. Appadmin only checks that the insert form is
> accepted which it is.
>
> --
> 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] Why input field in form.vars is stripped of trailing spaces?

2017-02-10 Thread Andriy
fields = [ Field('name', 'string', default=defaults['name'], 
requires=[IS_NOT_EMPTY(error_message='Enter name')]), ]
form = SQLFORM.factory(*fields, _class="uk-form uk-form-horizontal", 
_name="edit_form")
if form.process(hideerror=True).accepted:
print (form.vars.name, request.vars.name)

If I enter "Bob " (with trailing space in input field) I get printed:
('Bob', 'Bob ')

form.vars.name looses trailing space and I didn`t ask for this. 
request.vars.name is correct. 

I do *form.vars.name = request.vars.name* later in my code to counter this. 
I need all spaces preserved as they are entered. I didn`t find any 
explanation for this in the help/book.

-- 
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: table._before_insert.append() wrong behaviour?

2017-02-10 Thread Leonel Câmara
I don't see the problem. Appadmin only checks that the insert form is 
accepted which it is.

-- 
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] table._before_insert.append() wrong behaviour?

2017-02-10 Thread Marvix
Hello,
I tried this:

db.define_table('tablename', )
db.tablename._before_insert.append(lambda r : True )

this is supposed to never insert a record.
Infact no record is added, but using, for example, the relative appadmin 
form and submitting some values I get the notification "new record 
inserted", when it isn't.

This is obviously not the right behaviour.
web2py version 2.14.6

-- 
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] reference_field_value = None

2017-02-10 Thread Pierre

Hello everyone,

I noticed by accident  i can insert a record with 
reference_field_value=None. Is this the desired behavior ? I thought this 
would trigger an exception especially when NOTNULL=True but None is not 
considered NULL ?

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