[web2py] Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: ordinal not in range(128)

2015-05-15 Thread Annet
Hi,

Thanks for you reply, I read the post before posting my question,
I also read this post: https://github.com/web2py/web2py/issues/910

My problem is that I wasn't having this issue in:

Version 2.9.11-stable+timestamp.2014.09.15.23.35.11
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), 
MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib)

which as far as I can see also only has pg8000 available not psycopg2

Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.10.3-stable+timestamp.2015.04.02.21.42.07
Database drivers available: sqlite3, imaplib, pyodbc, pymysql, pg8000

I prefer to keep my web2py installation as close to when its first unzipped,
this makes in easier to host it.


Kind regards,

Annet

-- 
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: Which version of python to use with web2py?

2015-05-15 Thread weheh
Yes, but for the longest time the python of choice was 2.5.4. I'm looking 
for what python version it's being tested against now.

On Friday, May 15, 2015 at 8:56:21 PM UTC-7, Ron Chatterjee wrote:
>
> as the name implies, "web "2" py means", web interface with python using 
> python version 2. At least thats how I am reading it. Assuming with python 
> 3 it will be named web3py since its always backward compatible by 
> definition so web2py will break with python version 3.
>
>
> On Friday, May 15, 2015 at 8:42:55 PM UTC-4, weheh wrote:
>>
>> What is the sanctioned Windows version of python to use with the latest 
>> web2py, and that supports python HTTPSConnection or sslwrap?
>>
>> Probably wrong forum, but web2py with python on *Windows 7 SP1*. All 
>> python versions tested worked with web2py but failed HTTPS related stuff. 
>> Tried python 2.7.10rc1 had problems with HTTPSConnection. Backtracked 
>> version after version back to python 2.7.6, which is missing sslwrap 
>> module. Unbelievable that python is having so much trouble with SSL? Or is 
>> it something altogether different?
>>
>> 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: Which version of python to use with web2py?

2015-05-15 Thread Ron Chatterjee
as the name implies, "web "2" py means", web interface with python using 
python version 2. At least thats how I am reading it. Assuming with python 
3 it will be named web3py since its always backward compatible by 
definition so web2py will break with python version 3.


On Friday, May 15, 2015 at 8:42:55 PM UTC-4, weheh wrote:
>
> What is the sanctioned Windows version of python to use with the latest 
> web2py, and that supports python HTTPSConnection or sslwrap?
>
> Probably wrong forum, but web2py with python on *Windows 7 SP1*. All 
> python versions tested worked with web2py but failed HTTPS related stuff. 
> Tried python 2.7.10rc1 had problems with HTTPSConnection. Backtracked 
> version after version back to python 2.7.6, which is missing sslwrap 
> module. Unbelievable that python is having so much trouble with SSL? Or is 
> it something altogether different?
>
> Thanks!
>

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


Re: [web2py] Two SQLFORMs side by side?

2015-05-15 Thread Ron Chatterjee
Caveat to that, is there a way to have to SQLFORM top and bottom like the 
picture attached?

Its more like a django kind of admin panel feature. But in web2py, can we 
have the post and comment (two tables), embedded so when someone click on 
the blue "plus" sign a comment box shows up and people insert the comment 
on each post. Its one to many relationship (like attached picture). 

If someone really trying to know what I mean by that, here is the class 
definition generated for django.


class Post(models.Model):
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
title = models.CharField(max_length=255)
slug = models.SlugField()
body = models.TextField()
comments = models.ManyToManyField('Comment')

def get_absolute_url(self):
return reverse('post', kwargs={"slug": self.slug})

def __unicode__(self):
return self.title

class Meta:
ordering = ["-created_at"]


class Comment(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
body = models.TextField(verbose_name="Comment")
author = models.CharField(verbose_name="Name", max_length=255)


By the way, this app thats call "web2py.app.dummy.w2p", please be aware 
that it has some nasty nested stuff in it. Once I installed it was crawling 
all over desktop and wouldn't uninstall except from the DOS mode. Not fair.









On Thursday, May 14, 2015 at 3:53:15 PM UTC-4, LoveWeb2py wrote:
>
> No problem, Richard. Thank you for your help!
>
> On Thursday, May 14, 2015 at 11:45:28 AM UTC-4, Richard wrote:
>
> No time to hunt the issue with multiples loading...
>
> I guess it could come from not using the same web2py version... Or because 
> I made some change over app files which are binded to web2py version 
> /statis/js/web2py.js for instance... or views/web2py_ajax.html
>
>
> You have at least an semi-working example... There is 2 issues that remain 
> : 1) The component load the whole site which he shouldn't (that may be 
> related to the second issue), 2) When you access the 
> http://hostname/appname/second_table_form/second_table there is a weird 
> issue with LOAD...
>
> I may have more time next week, but for now, I can't help you further...
>
> Richard
>
>
> On Tue, May 12, 2015 at 11:11 AM, LoveWeb2py  wrote:
>
> Repeating load might be because I extended the layout in the view for the 
> load. 
>
> On Tuesday, May 12, 2015 at 10:22:41 AM UTC-4, Richard wrote:
>
> Almost there... I make it works, but there is something weird going on 
> related to component... I have to figure it out... But you were doing thing 
> the wrong way basically...  add_function is for the main_table which 
> contains the city name...
>
> I will send you back the corrected app when I found the issue with the 
> repeating load...
>
> Richard
>
> On Mon, May 11, 2015 at 4:39 PM, LoveWeb2py  wrote:
>
> No rush, Richard. Thank you for your help I really appreciate it.
>
> On Monday, May 11, 2015 at 4:34:14 PM UTC-4, Richard wrote:
>
> I will try to review it ASAP...
>
> On Mon, May 11, 2015 at 4:30 PM, LoveWeb2py  wrote:
>
> Here is my dummy app, Richard. 
>
>
> On Monday, May 11, 2015 at 3:50:20 PM UTC-4, Richard wrote:
>
> Did you make dummy app for testing it?
>
> Please attach it here and I have a look to your code... I can't help much 
> if I don't have a good idea of what you have done...
>
> new_exp_num=form.vars.exp_num
>
> This is something I left which should be adapted to your app... 
> form.vars.exp_num is the representation of the new inputed record... The 
> same field name you specify in the widget declaration for the field 
> attribute : db.table.representing_field, but that you get from the form 
> of the referenced table.
>
> Richard
>
>
> On Mon, May 11, 2015 at 3:28 PM, LoveWeb2py  wrote:
>
> Thanks haha. Just checking. Still not having much luck. I'm getting a 500 
> error on the add function and can't figure out why 
>
> when I try to edit my site I am getting an error for the "add function" 
> specified to add the  
> https://www.mywebsite.com/add_function/second_table_field
> def add_function():
> """
> Modal form for adding element
> """
>
>
> buttons = [TAG.button((I('', _class='icon-ok icon-large icon-white'), 
> CAT('  '), STRONG(T('Add'))),
>   _type='submit',
>   _class='btn btn-small btn-primary',
>   _id='add_button_id',
>   _name='add_button',
>   )]
> form = SQLFORM(db.table, buttons=buttons, formstyle=formstyle, 
> separator=separator)
> response.js = '$(document).ready(function(){ 
> $(".input_wrapper").has(".error").addClass("inputError"); ' \
>   '$(".w2p_fw").has(".error").addClass("control-group 
> error"); ' \
>   '$(".w2p_fw").each(function(){ 
> $(this).find(".error_wrapper").appendTo(this); }); });'
> response.js += '$(document).ready(function(){ 
> $("textarea")

[web2py] Re: ajax callback can not return string type data

2015-05-15 Thread Anthony
Your Javascript syntax is incorrect -- the text inside .html() must be 
wrapped in quotes:

"jQuery('#status').html('%s');" % (str(status))

Anthony

On Friday, May 15, 2015 at 9:13:21 PM UTC-4, 黄祥 wrote:
>
> hi,
>
> is it possible to have ajax callback return string type data?
> e.g.
> controllers
> def callback_2(session_order, target_response):
> ... cutted
> if int(total_debit) == int(total_credit):
> #status = "Balance"
> #status = str("Balance")
> status = 1
> else:
> #status = "Unbalance"
> #status = str("Unbalance")
> status = 0
> #return "jQuery('#status').html(%s);" % (status)
> return "jQuery('#status').html(%s);" % (str(status) )
>
> all comment is not worked (no errors occured, but the result is not 
> shown), when change it into integer type it can work (shown in views). any 
> idea how to achieve it using web2py way?
>
> i know i can put another conditional in views for that, but i want to know 
> another way to achieve this
> e.g.
> views
> {{if status == 1:}}
> {{=SPAN('Balance', _class = "text-success" ) }}
> 
> {{else:}}
> {{=SPAN('Unbalance', _class = "text-danger" ) }}
> 
> {{pass}}
>
> 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] ajax callback can not return string type data

2015-05-15 Thread 黄祥
hi,

is it possible to have ajax callback return string type data?
e.g.
controllers
def callback_2(session_order, target_response):
... cutted
if int(total_debit) == int(total_credit):
#status = "Balance"
#status = str("Balance")
status = 1
else:
#status = "Unbalance"
#status = str("Unbalance")
status = 0
#return "jQuery('#status').html(%s);" % (status)
return "jQuery('#status').html(%s);" % (str(status) )

all comment is not worked (no errors occured, but the result is not shown), 
when change it into integer type it can work (shown in views). any idea how 
to achieve it using web2py way?

i know i can put another conditional in views for that, but i want to know 
another way to achieve this
e.g.
views
{{if status == 1:}}
{{=SPAN('Balance', _class = "text-success" ) }}

{{else:}}
{{=SPAN('Unbalance', _class = "text-danger" ) }}

{{pass}}

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] Which version of python to use with web2py?

2015-05-15 Thread weheh
I'm upgrading a bunch of stuff and went with the latest version of python 
2.7.10rc1 and found it had problems with HTTPSConnect. Backtracked version 
after version until now am on python 2.7.6, which is missing sslwrap 
module. Unbelievable that python is having so much trouble with SSL.

Can someone tell me what is the sanctioned version of python to use with 
the latest web2py, and that supports SSL, of course?

Thanks!

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


Re: [web2py] issue with select with yearfield.year == YEAR

2015-05-15 Thread Anthony
It is a method, not an attribute, so should be db.table.datefield.year().

Anthony

On Friday, May 15, 2015 at 3:16:57 PM UTC-4, Richard wrote:
>
> Hello,
>
> Not tested with recent web2py version, but in 2.9.5 this lead to a no 
> where clause query :
>
> db(db.table.datefield.year == 2010).select(db.table.ALL)
>
> gives :
>
> SELECT * FROM table
>
> Instead of
>
> SELECT * FROM table WHERE EXTRACT(YEAR FROM datefield) = 2010
>
> For instance with postgres...
>
> I have the issue with postgres and psycopg and web2py 2.9.5
>
> I don't have time to check in recent version... So posted here before open 
> a ticket to pydal if issue is still there...
>
> Richard
>

-- 
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: New import problem when testing web2py app with pytest

2015-05-15 Thread Richard Vézina
I was not having the solution, but I thought to tell you to look there
since it smell like it was coming from there :)

Richard

On Fri, May 15, 2015 at 4:41 PM, Ian W. Scott  wrote:

> Never mind! I discovered the problem in my conftest.py file. Thanks anyway!
>
>
> On Friday, May 15, 2015 at 3:57:47 PM UTC-4, Ian W. Scott wrote:
>>
>> I've been successfully using pytest for quite a while now to do unit
>> testing for my web2py apps. Today, after upgrading to the latest web2py
>> version (Version 2.10.4-stable+timestamp.2015.04.26.15.11.54) my tests
>> won't run. When I try to run the tests in a test file (in the tests/
>> directory) web2py tries to import that test file as a module and raises an
>> ImportError.
>>
>> For example, I have a test file at
>> myapp/tests/modules/test_greek_parser.py. I try to run it like this:
>>
>> python2.7 -m pytest -xvs applications/paideia/tests/modules/
>> test_greek_parser.py
>>
>> The error looks like this:
>>
>> = test session starts
>> =
>> platform linux2 -- Python 2.7.9 -- py-1.4.20 -- pytest-2.5.2 -- 
>> /usr/bin/python
>>
>> collected 0 items / 1 errors
>>
>>
>>
>> === ERRORS
>> 
>> __ ERROR collecting applications/paideia/tests/
>> modules/test_greek_parser.py ___
>> /usr/local/lib/python2.7/dist-packages/py/_path/local.py:620: in
>> pyimport
>> >   __import__(modname)
>>
>> gluon/custom_import.py:89: in custom_importer
>>
>> >   raise ImportError, 'Cannot import module
>> %s' % str(e)
>> E   ImportError: Cannot import module
>> 'applications.paideia.modules.test_greek_parser'
>> === 1 error in 0.01 seconds
>> ===
>>
>>
>> It's not surprising that custom_importer can't find the module, since it
>> doesn't exist! It's looking for a file with my test file name, but looking
>> in the myapp/modules/ directory. I'm not even sure why gluon is trying to
>> import something with that file name at all.
>>
>> Now, if this isn't strange enough already, this import error only happens
>> with some of my test files. Others (in the same tests/modules/ directory)
>> run without a hitch. But I can't for the life of me find any significant
>> difference between the two.
>>
>> I'm attaching a couple of files here in case they help shed any light:
>>
>> 1. my conftest.py which is read by pytest before running the tests (this
>> seems to be fine; it sits in the parent 'tests' directory)
>> 2. test_paideia_utils.py (which runs without any problem)
>> 3. test_greek_parser.py (which raises the import error)
>>
>> I realize that this may appear to be a pytest problem rather than a
>> web2py problem. But the error is happening because custom_importer is being
>> called somewhere, so at the least it looks like some recent update has
>> introduced an incompatibility with pytest. Again, these tests were all
>> running fine (with the same conftest.py)
>>
>> Thanks again for any help. I'm really at a loss with this one!
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: New import problem when testing web2py app with pytest

2015-05-15 Thread Ian W. Scott
Never mind! I discovered the problem in my conftest.py file. Thanks anyway!

On Friday, May 15, 2015 at 3:57:47 PM UTC-4, Ian W. Scott wrote:
>
> I've been successfully using pytest for quite a while now to do unit 
> testing for my web2py apps. Today, after upgrading to the latest web2py 
> version (Version 2.10.4-stable+timestamp.2015.04.26.15.11.54) my tests 
> won't run. When I try to run the tests in a test file (in the tests/ 
> directory) web2py tries to import that test file as a module and raises an 
> ImportError.
>
> For example, I have a test file at 
> myapp/tests/modules/test_greek_parser.py. I try to run it like this:
>
> python2.7 -m pytest -xvs applications/paideia/tests/modules/
> test_greek_parser.py
>
> The error looks like this:
>
> = test session starts 
> =
> platform linux2 -- Python 2.7.9 -- py-1.4.20 -- pytest-2.5.2 -- 
> /usr/bin/python 
>   
> collected 0 items / 1 errors 
>  
>   
> 
> === ERRORS 
> 
> __ ERROR collecting applications/paideia/tests/modules
> /test_greek_parser.py ___
> /usr/local/lib/python2.7/dist-packages/py/_path/local.py:620: in pyimport 
>  
> >   __import__(modname)   
>  
> gluon/custom_import.py:89: in custom_importer 
>  
> >   raise ImportError, 'Cannot import module 
> %s' % str(e)   
> E   ImportError: Cannot import module 
> 'applications.paideia.modules.test_greek_parser'
> === 1 error in 0.01 seconds 
> ===
>
>
> It's not surprising that custom_importer can't find the module, since it 
> doesn't exist! It's looking for a file with my test file name, but looking 
> in the myapp/modules/ directory. I'm not even sure why gluon is trying to 
> import something with that file name at all.
>
> Now, if this isn't strange enough already, this import error only happens 
> with some of my test files. Others (in the same tests/modules/ directory) 
> run without a hitch. But I can't for the life of me find any significant 
> difference between the two.
>
> I'm attaching a couple of files here in case they help shed any light:
>
> 1. my conftest.py which is read by pytest before running the tests (this 
> seems to be fine; it sits in the parent 'tests' directory)
> 2. test_paideia_utils.py (which runs without any problem)
> 3. test_greek_parser.py (which raises the import error)
>
> I realize that this may appear to be a pytest problem rather than a web2py 
> problem. But the error is happening because custom_importer is being called 
> somewhere, so at the least it looks like some recent update has introduced 
> an incompatibility with pytest. Again, these tests were all running fine 
> (with the same conftest.py)
>
> Thanks again for any help. I'm really at a loss with this one!
>

-- 
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] New import problem when testing web2py app with pytest

2015-05-15 Thread Ian W. Scott
I've been successfully using pytest for quite a while now to do unit 
testing for my web2py apps. Today, after upgrading to the latest web2py 
version (Version 2.10.4-stable+timestamp.2015.04.26.15.11.54) my tests 
won't run. When I try to run the tests in a test file (in the tests/ 
directory) web2py tries to import that test file as a module and raises an 
ImportError.

For example, I have a test file at 
myapp/tests/modules/test_greek_parser.py. I try to run it like this:

python2.7 -m pytest -xvs applications/paideia/tests/modules/
test_greek_parser.py

The error looks like this:

= test session starts 
=
platform linux2 -- Python 2.7.9 -- py-1.4.20 -- pytest-2.5.2 -- /usr/bin/python 
  
collected 0 items / 1 errors   
   

  
=== ERRORS 

__ ERROR collecting applications/paideia/tests/modules/
test_greek_parser.py ___
/usr/local/lib/python2.7/dist-packages/py/_path/local.py:620: in pyimport   
   
>   __import__(modname) 
   
gluon/custom_import.py:89: in custom_importer   
   
>   raise ImportError, 'Cannot import module %s' 
% str(e)   
E   ImportError: Cannot import module 
'applications.paideia.modules.test_greek_parser'
=== 1 error in 0.01 seconds 
===


It's not surprising that custom_importer can't find the module, since it 
doesn't exist! It's looking for a file with my test file name, but looking 
in the myapp/modules/ directory. I'm not even sure why gluon is trying to 
import something with that file name at all.

Now, if this isn't strange enough already, this import error only happens 
with some of my test files. Others (in the same tests/modules/ directory) 
run without a hitch. But I can't for the life of me find any significant 
difference between the two.

I'm attaching a couple of files here in case they help shed any light:

1. my conftest.py which is read by pytest before running the tests (this 
seems to be fine; it sits in the parent 'tests' directory)
2. test_paideia_utils.py (which runs without any problem)
3. test_greek_parser.py (which raises the import error)

I realize that this may appear to be a pytest problem rather than a web2py 
problem. But the error is happening because custom_importer is being called 
somewhere, so at the least it looks like some recent update has introduced 
an incompatibility with pytest. Again, these tests were all running fine 
(with the same conftest.py)

Thanks again for any help. I'm really at a loss with this one!

-- 
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.
#!/usr/bin/env python

'''
py.test configuration and fixtures file.

This file is lightly adapted from the one by viniciusban;
Part of the web2py.test model app (https://github.com/viniciusban/web2py.test)

This file
- Tells application it's running in a test environment.
- Creates a complete web2py environment, similar to web2py shell.
- Creates a WebClient instance to browse your application, similar to a real
web browser.
- Propagates some application data to test cases via fixtures, like baseurl
and automatic appname discovery.

To write to db in test:

web2py.db.table.insert(**data)
web2py.db.commit()

To run tests:

cd web2py (you must be in web2py root directory to run tests)
python web2py.py -a my_password --nogui &
py.test -x [-l] [-q|-v] -s applications/my_app_name/tests

'''

import os
import pytest
import sys
from pprint import pprint
sys.path.insert(0, '')

# allow imports from modules and site-packages
dirs = os.path.split(__file__)[0]
appname = dirs.split(os.path.sep)[-2]
modules_path = os.path.join('applications', appname, 'modules')
if modules_path not in sys.path:
sys.path.append(modules_path)  # imports from app modules folder
if 'site-packages' not in sys.path:
sys.path.append('site-packages')  # imports from site-packages

from gluon.shell import en

[web2py] issue with select with yearfield.year == YEAR

2015-05-15 Thread Richard
Hello,

Not tested with recent web2py version, but in 2.9.5 this lead to a no where 
clause query :

db(db.table.datefield.year == 2010).select(db.table.ALL)

gives :

SELECT * FROM table

Instead of

SELECT * FROM table WHERE EXTRACT(YEAR FROM datefield) = 2010

For instance with postgres...

I have the issue with postgres and psycopg and web2py 2.9.5

I don't have time to check in recent version... So posted here before open 
a ticket to pydal if issue is still there...

Richard

-- 
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] two step verification

2015-05-15 Thread Richard Vézina
To me 2-steps verification just for admin is tough, better having 2-steps
for everyone...

I have a feature for changing role in my app... The design is very old
though, and I wouldn't implement it that way now since I better understand
RBAC of web2py... It is easy to create a role that if you are in (for
instance "change_role") you can change of role... But you need a subset of
roles for which users with change_role membership can change off... So you
need a user preferences for this...

What I did in the pass, was to create another table to store which role
user can change from and make a boolean field to specify in which group the
user was... But as I said, I would prefer reuse as much as possible the
RBAC system of web2py. So user preference table with a field called
"membership_allowed" and "actual_membership" give you a pretty what you
need then create a controller to manage the change of role process and
update the "actual_membership" field of user preferences table

Then you can easily append the button to the menu of your app base on the
change_role membership like so from the layout :

{{if auth.user_id in [r.user_id for r in db(db.auth_membership.group_id ==
  db(db.auth_group.role ==
'change_role'
 ).select(db.auth_group.id
).first().id

).select(db.auth_membership.user_id)]:}}
  
 jQuery(document).ready(function () {

$('#navbar').find('ul.dropdown-menu').prepend('{{=LI(A(I(_class="icon-share-alt"),
SPAN(' '),
   T("Role
change"),

 _href=URL(r=request, c="chmbshp",  # My change_role function was not well
named back then...

 f="change_membership",

 vars=dict(_next=URL(request.controller,

 request.function,

 args=request.args,

 vars=request.get_vars)}}');
 });
  
  {{pass}}

Richard

On Fri, May 15, 2015 at 2:37 AM, Martin Weissenboeck 
wrote:

> I have an app with two roles:
> a standard role for every user and
> an admin role for some administrators.
>
> For the standard user a simple one-step-login would be sufficient.
>
> What I want:
>
> (1) an admin user should change his role on the fly from standard to
> admin, eg. via a menu button (and back again)
>
> (2) on starting the admin role the second part of the two step
> verification should take place (once).
>
> What would be the best way to implement this idea?
>
> Regards, Martin
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: ordinal not in range(128)

2015-05-15 Thread Willoughby
Postgre?
https://groups.google.com/d/topic/web2py/LJwG9ec4o28/discussion


On Friday, May 15, 2015 at 12:15:16 PM UTC-4, Annet wrote:
>
> After upgrading to web2py version 2.10.3 I get an error on fields
> of type text when they contain accented latin characters, see
> traceback.
>
>
> Traceback (most recent call last):
>   File "/Users/iannet/web2py_local/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/iannet/web2py_local/applications/my/controllers/landingpage.py", 
> line 131, in 
>   File "/Users/iannet/web2py_local/gluon/globals.py", line 393, in 
> self._caller = lambda f: f()
>   File "/Users/iannet/web2py_local/gluon/tools.py", line 3440, in f
> return action(*a, **b)
>   File "/Users/iannet/web2py_local/gluon/tools.py", line 3440, in f
> return action(*a, **b)
>   File 
> "/Users/iannet/web2py_local/applications/my/controllers/landingpage.py", 
> line 116, in landingpage_form
> if form.process().accepted:
>   File "/Users/iannet/web2py_local/gluon/html.py", line 2301, in process
> self.validate(**kwargs)
>   File "/Users/iannet/web2py_local/gluon/html.py", line 2238, in validate
> if self.accepts(**kwargs):
>   File "/Users/iannet/web2py_local/gluon/sqlhtml.py", line 1677, in accepts
> self.id_field_name]).update(**fields)
>   File "/Users/iannet/web2py_local/gluon/packages/dal/pydal/objects.py", 
> line 2117, in update
> ret = db._adapter.update("%s" % table._tablename,self.query,fields)
>   File 
> "/Users/iannet/web2py_local/gluon/packages/dal/pydal/adapters/base.py", 
> line 988, in update
> raise e
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: 
> ordinal not in range(128)
>
>
> Why isn't my application backward compatible?
>
> Kind regards,
>
> Annet
>

-- 
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] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: ordinal not in range(128)

2015-05-15 Thread Annet
After upgrading to web2py version 2.10.3 I get an error on fields
of type text when they contain accented latin characters, see
traceback.


Traceback (most recent call last):
  File "/Users/iannet/web2py_local/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/Users/iannet/web2py_local/applications/my/controllers/landingpage.py", 
line 131, in 
  File "/Users/iannet/web2py_local/gluon/globals.py", line 393, in 
self._caller = lambda f: f()
  File "/Users/iannet/web2py_local/gluon/tools.py", line 3440, in f
return action(*a, **b)
  File "/Users/iannet/web2py_local/gluon/tools.py", line 3440, in f
return action(*a, **b)
  File 
"/Users/iannet/web2py_local/applications/my/controllers/landingpage.py", 
line 116, in landingpage_form
if form.process().accepted:
  File "/Users/iannet/web2py_local/gluon/html.py", line 2301, in process
self.validate(**kwargs)
  File "/Users/iannet/web2py_local/gluon/html.py", line 2238, in validate
if self.accepts(**kwargs):
  File "/Users/iannet/web2py_local/gluon/sqlhtml.py", line 1677, in accepts
self.id_field_name]).update(**fields)
  File "/Users/iannet/web2py_local/gluon/packages/dal/pydal/objects.py", 
line 2117, in update
ret = db._adapter.update("%s" % table._tablename,self.query,fields)
  File 
"/Users/iannet/web2py_local/gluon/packages/dal/pydal/adapters/base.py", 
line 988, in update
raise e
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: 
ordinal not in range(128)


Why isn't my application backward compatible?

Kind regards,

Annet

-- 
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: Restricting Access to database based on roles at the Database level.

2015-05-15 Thread Anthony
The Auth records are in the database, but you don't have to give users any 
direct access to the Auth tables (there is none by default). Can you explain 
your requirements in more detail?

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.