[web2py] web2py on Android

2013-07-14 Thread Fernando Pacheco
I'm trying to run a minimal version of web2py (git version) on Android 
(Samsung Galaxy Tab 2 10 ) with kivy (as a service, latest python version 
2.7) and / or from the launcher SL4A (pythn 2.6).

Everything works fine when I use GET, but when I submit a form (POST) I get 
the following error: 

*close failed in file object destructor: **
**IOError: [Errno 5] I/O error
*
The admin application also has this problem (password submit with the same 
error).

Full web2py version (from git) has the same problem. 

I have tried to detect the source of error with no luck. Has anyone run 
applications -on Android- that contain forms (POST) successfully?.Any 
thoughts on this?. 

Thank you very much. Greetings. Fernando.

-- 

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




127.0.0.1.2013-07-14.04-08-19.9a47a329-25ec-41c2-8c6d-e00d2ed94d33
Description: Binary data


[web2py] Re: Quoting in export_to_csv_file() / import_from_csv_file()

2013-07-14 Thread Massimo Di Pierro
I opened an issue about this until I can verify the problem:
https://code.google.com/p/web2py/issues/detail?id=1585thanks=1585ts=1373793319

On Wednesday, 10 July 2013 16:40:59 UTC-5, Wes Hall wrote:

 After using import_from_csv_file(), additional quotes are showing up in 
 the db.

 Should I be using some different quoting in export_to_csv_file() or is 
 this an inherent problem with specifying filter_out in in the model, or am 
 I completely off the mark?

 Exporting db = 2.4.6
 Importing db = 2.5.1

 Table definition
 db.define_table('evaluation',
 Field('form', type='text',
   label=T('Evaluation form')),
 Field('results', type='text',
   label=T('JSON results')),
 auth.signature,
 format='%(form)s',
 migrate=settings.migrate)

 db.evaluation.results.filter_in = lambda obj, dumps=dumps: dumps(obj)
 db.evaluation.results.filter_out = lambda txt, loads=loads: loads(txt)

 Export
 db.export_to_csv_file(open('test.csv', 'w'))

 (Excerpt from test.csv)
 89,se2,{u'name': u'Good User', u'answers': {u'q1': u'5', u'comment1': 
 uThis answer should've had an apostrophe.}, u'email': 
 u'...@mail.comjavascript:
 '},auth fields

 Import
 db.import_from_csv_file(open('test.csv', 'r'))

 MySQL row.results from within current application on original and new db
 {name: Good User, answers: {q1: 5, comment1: This answer 
 should've had an apostrophe.}, email: u...@mail.com javascript:}

 MySQL row.results from import on new db (note the new enclosing double 
 quotes)
 {u'name': u'Good User', u'answers': {u'q1': u'5', u'comment1': u\This 
 answer should've had an apostrophe.\}, u'email': u'...@mail.comjavascript:
 '}

 This all leads to the following error:

 evaluation.results['name']),
 TypeError: string indices must be integers



-- 

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




[web2py] Re: session id is set to none with login_bare

2013-07-14 Thread Massimo Di Pierro
I this still an open issue? If so, please open a ticket on google code.

On Friday, 5 July 2013 10:45:06 UTC-5, Vikas Gupta wrote:


 The client is an adroid app. I am getting the session_id as none in this 
 function

 def myTestUserLoginFunc():

 import json
 import gluon.contrib.simplejson

 import gluon.contrib.simplejson as sj 
 data = sj.loads(request.body.read())

 myemail=data['email']
 mypassword=data['password']

 logged_user=auth.login_bare(myemail, mypassword.encode('utf8'))


 if (auth.is_logged_in() == True):
 logger.debug(I am logged in.)
 else:
 logger.debug(I am not logged in.)

 logger.debug(session.session_id = %s %session.session_id)
 logger.debug(response session id - %s  % response.session_id)
 logger.debug(session file %s  % response.session_file_name)
 logger.debug(session id name %s  % response.session_id_name)
 logger.debug(session status %s  % response.session_status)

 ret=
 if (logged_user == False):
 ret=sj.dumps([invalid])
 else:
 ret=response.session_id
 if auth.is_logged_in():
 ret=session.session_id
 else:
 logger.debug(not logged in)
 if (ret == None):
 ret=DummySessionId

 return ret

 user gets successfully logged in, but the session id, session_status and 
 session_file_name are always set to None. sessionid_id_name is set to 
 session_id_appname

 user record is like this -

 Row {'first_name': 'v g', 'last_name': '', 'id': 3, 'registration_id': 
 '', 'social_login': False, 'reset_password_key': 
 '1373017333-f58bd8f5-d560-40c6-8117-c3815a93fc06', 'password': 
 'pbkdf2(1000,20,sha512)$a9e9d5525d1daac6$a8e63a319b8e8113f41a2bf3a8cd2c818499f899',
  
 'registration_key': '', 'email': 'myem...@gmail.com javascript:'}




-- 

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




[web2py] Re: Field.Virtual does not show up in db.table.fields

2013-07-14 Thread Massimo Di Pierro
No. This is the intended behavior.



On Saturday, 13 July 2013 12:27:04 UTC-5, Woody wrote:

 I'm using version 2.5.1 stable and I've created a virtual field as part of 
 a table definition, like this:

 db_mydb.define_table('my_table',
 Field('ROWID', 'id'),
 Field('test_field1', 'string', required=True),
 Field('test_field2', 'string', required=False),
 Field.Virtual('virtual_field_test', lambda row: 
 test_field), 
 Field('test_field3', 'string', required=False),
 migrate=False)


 The other fields show up in mydb.my_table.fields, but the virtual field 
 does not.  According to the documentation, this didn't work in earlier 
 versions, but I assumed that means that it does work in the current 
 version.  Is this a bug?



-- 

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




[web2py] Re: SQLFORM.smartgrid works as expected up to web2py 2.4.2, but not later versions

2013-07-14 Thread Massimo Di Pierro
I cannot reproduce the error with trunk.

Yet this does not do what you expect:

db.subroute.route.writable = False

To make the table routes not editable you should do:

 grid = SQLFORM.smartgrid(db.route, editable={'routes':False})



On Wednesday, 3 July 2013 14:50:09 UTC-5, Otto Domínguez wrote:

 I have a working app since web2py 1.99 times, and I have been upgrading to 
 later versions periodically. Today I noticed my app does not work in 2.5.1 
 in some simple uses of SQLFORM.smartgrid. I took time this morning to check 
 versions from 2.3.2 up to latest to check in which version it stopped 
 working. It works up to 2.4.2. In 2.4.3 it does not, up to the latest 
 2.5.1. In the non working versions the ticket message is the same, so the 
 code should have been introduced in 2.4.3. The message reads: 
 'Table' object has no attribute 'content_of_some_parent_field'

 Take this simple model:

 db.define_table('route',
 Field('route', label=T('Route')),
 format='%(route)s')

 db.define_table('subroute',
 Field('subroute', label=T('Subroute')),
 Field('route', 'reference route', label=T('Route')),
 format=lambda subroute: '%s-%s' % (db.route[subroute.route].route, 
 subroute.subroute))

 Take this simple route.py controller:

 @auth.requires_membership('Manager')
 def index():
 db.subroute.route.writable = False
 grid = SQLFORM.smartgrid(db.route)
 return locals()

 Navigate to localhost:8000/appname/route. Create a route (parent record). 
 Click subroute (child link). Add subroute (child record). Now the grid is 
 showing the subroute (child) with an active link to its route (parent). 
 Click this link. It works on or below 2.4.2. It does not work on or above 
 2.4.3. When working, it allows to view/edit/delete the parent.

 Should I file a bug or this is a known bug/expected behavior?


-- 

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




[web2py] Re: web2py on Android

2013-07-14 Thread Massimo Di Pierro
Can you try wrap (in main.py)

parse_get_post_vars(request, environ)

in try: ...  except IOError: pass and see what happens.

Web2py copies the input stream into a temp file in order to be able to 
parse it but also pass a copy to the app. I suspect something happens to 
the original stream and it gets closed twice (not sure why, not by web2py, 
but by the wsgi adapter). If we isolate the problem we can find a work 
around.

On Sunday, 14 July 2013 03:16:09 UTC-5, Fernando Pacheco wrote:

 I'm trying to run a minimal version of web2py (git version) on Android 
 (Samsung Galaxy Tab 2 10 ) with kivy (as a service, latest python version 
 2.7) and / or from the launcher SL4A (pythn 2.6).

 Everything works fine when I use GET, but when I submit a form (POST) I 
 get the following error: 

 *close failed in file object destructor: **
 **IOError: [Errno 5] I/O error
 *
 The admin application also has this problem (password submit with the same 
 error).

 Full web2py version (from git) has the same problem. 

 I have tried to detect the source of error with no luck. Has anyone run 
 applications -on Android- that contain forms (POST) successfully?.Any 
 thoughts on this?. 

 Thank you very much. Greetings. Fernando.

-- 

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




[web2py] Re: Field.Virtual does not show up in db.table.fields

2013-07-14 Thread Woody
Thanks for the clarification.  This is what appears in the book:

Mind that virtual fields do not have the same attributes as the other 
fields (default, readable, requires, etc). In older versions of web2py they 
do not appear in the list of db.table.fields and they require a special 
approach to display in SQLFORM.grid and SQLFORM.smartgrid. See the 
discussion on grids and virtual fields in the Forms chapter.
*
*
The statement that it doesn't appear in older versions made me think that 
it would appear in the current version.  Is it likely that this will work 
in some future version?
*
*
On Sunday, July 14, 2013 5:18:26 AM UTC-4, Massimo Di Pierro wrote:

 No. This is the intended behavior.



 On Saturday, 13 July 2013 12:27:04 UTC-5, Woody wrote:

 I'm using version 2.5.1 stable and I've created a virtual field as part 
 of a table definition, like this:

 db_mydb.define_table('my_table',
 Field('ROWID', 'id'),
 Field('test_field1', 'string', required=True),
 Field('test_field2', 'string', required=False),
 Field.Virtual('virtual_field_test', lambda row: 
 test_field), 
 Field('test_field3', 'string', required=False),
 migrate=False)


 The other fields show up in mydb.my_table.fields, but the virtual field 
 does not.  According to the documentation, this didn't work in earlier 
 versions, but I assumed that means that it does work in the current 
 version.  Is this a bug?




-- 

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




[web2py] Re: Field.Virtual does not show up in db.table.fields

2013-07-14 Thread Massimo Di Pierro
You are right... that needs to be fixed.

On Sunday, 14 July 2013 08:34:23 UTC-5, Woody wrote:

 Thanks for the clarification.  This is what appears in the book:

 Mind that virtual fields do not have the same attributes as the other 
 fields (default, readable, requires, etc). In older versions of web2py they 
 do not appear in the list of db.table.fields and they require a special 
 approach to display in SQLFORM.grid and SQLFORM.smartgrid. See the 
 discussion on grids and virtual fields in the Forms chapter.
 *
 *
 The statement that it doesn't appear in older versions made me think 
 that it would appear in the current version.  Is it likely that this will 
 work in some future version?
 *
 *
 On Sunday, July 14, 2013 5:18:26 AM UTC-4, Massimo Di Pierro wrote:

 No. This is the intended behavior.



 On Saturday, 13 July 2013 12:27:04 UTC-5, Woody wrote:

 I'm using version 2.5.1 stable and I've created a virtual field as part 
 of a table definition, like this:

 db_mydb.define_table('my_table',
 Field('ROWID', 'id'),
 Field('test_field1', 'string', required=True),
 Field('test_field2', 'string', required=False),
 Field.Virtual('virtual_field_test', lambda row: 
 test_field), 
 Field('test_field3', 'string', required=False),
 migrate=False)


 The other fields show up in mydb.my_table.fields, but the virtual field 
 does not.  According to the documentation, this didn't work in earlier 
 versions, but I assumed that means that it does work in the current 
 version.  Is this a bug?




-- 

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




[web2py] this talk...

2013-07-14 Thread Massimo Di Pierro
https://vimeo.com/2723800

I think this talk is really relevant to our community, and it gets really 
funny after the first 19 minute.

Massimo

-- 

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




[web2py] Re: this talk...

2013-07-14 Thread David Marko
Hi Massimo, can you elaborate more on how it is relevant to this community? 
Do you have some ideas that come from this presentation?

Dne neděle, 14. července 2013 18:03:06 UTC+2 Massimo Di Pierro napsal(a):

 https://vimeo.com/2723800

 I think this talk is really relevant to our community, and it gets really 
 funny after the first 19 minute.

 Massimo


-- 

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




[web2py] Re: this talk...

2013-07-14 Thread Massimo Di Pierro
The talk is about tricks and tips to push forward technologies which a 
programmer finds useful within a traditional and technologically 
conservative corporate environment. He tells the story of a Ruby project 
within a corporate environment that was very hostile to changes. I have 
been in similar situations and I always ended up defeated. I have written 
programs (fully working, tested, offered at zero cost) that would have 
saved somebody $50K/year in software licenses. The CTO said: no thanks. 
Most CTO prefer a big vendor to free or in-house because are incapable of 
estimating the value and hidden costs of that and, the company ends up with 
the worst employees, those who will put up with that mentality. I can think 
of many people here who work for Java or C# shops and some times they'd 
rather use something else. I think the talks gives them useful tips.


On Sunday, 14 July 2013 11:20:25 UTC-5, David Marko wrote:

 Hi Massimo, can you elaborate more on how it is relevant to this 
 community? Do you have some ideas that come from this presentation?

 Dne neděle, 14. července 2013 18:03:06 UTC+2 Massimo Di Pierro napsal(a):

 https://vimeo.com/2723800

 I think this talk is really relevant to our community, and it gets really 
 funny after the first 19 minute.

 Massimo



-- 

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




[web2py] web2py roadmap

2013-07-14 Thread Niphlod
web2py's developers work often behind the curtain and users are not able 
to see what they're working on. Historically we tracked down 
feature-requests and todo-lists on google code, but it's a nightmare to 
track them and work with it efficiently.

On a nice tip received by a power web2py user, we (developers) decided to 
create something more readable to give us (developers AND users) a nice 
representation on what's going on.

Please welcome the official trello board for web2py's roadmap : 
https://trello.com/b/d3aqBbBl

-- 

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




[web2py] How to insert line breaks in table cell created by a virtual field

2013-07-14 Thread Woody
I have a virtual field that concatenates 2 fields like this:

Field.Virtual('alert_time', 
lambda row: (str(a calculation that generates an integer) 
+ ' hours' + str(references a field that has type datetime))

The result goes into a table cell and looks something like this:  8 hours 
2013-07-14 09:10:20

I want to force  line breaks so that it will look like this
 8 hours
  2013-07-14
09:10:20

I tried inserting line breaks using /n or br / in the text like this:

lambda row: (str(a calculation that generates an integer) + ' hours/n' + 
str(references a field that has type datetime))

but they printed out as string literals in the table.  How can I format the 
text for this cell?

-- 

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




[web2py] Using ROWID function as id field in sqlite tables

2013-07-14 Thread Woody
This may be something that is known by people with more experience than me, 
but it took me a lot of experimenting to figure it out, so I thought I 
would post it here so others will find it.

I have legacy sqlite tables that do not have an id field.  This makes it 
difficult to update them using SQLFORM.

ROWID is a hidden auto-increment integer field that's included in all 
sqlite tables.  You can make ROWID explicit by declaring it as the first 
field in a table definition, then you can assign it the 'id' alias.

Here's an example:

db.define_table('my_sqlite_table',
Field('ROWID', 'id'),
Field('some_field', 'string'),
Field('some_other_field', 'integer'),

migrate=False)

You can then use 'id' as a field name just as if your table had an actual 
id field defined in the underlying table.  As far as I can tell, this hack 
works without any problems.  The use of the 'id' alias is documented, but 
 I haven't seen the use of 'ROWID' with the alias discussed.  This might be 
something that could be tested and added to the documentation.

-- 

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




[web2py] How to handle multiple domains with the same application

2013-07-14 Thread Marcio Andrey Oliveira
Hi.

Currently I have 3 arcade sites: 1 with all kinds of games, 1 with only 
girls games and another one with only escaping games.

Each site is running in a separated script, and worst than that is that I 
have some games in girls game site and on escaping games sites that exist 
on general arcade site. It means I'm expending database and disk space with 
duplicated date.

I want to make one application that will receive requests from all domains 
and according to the domain, it will show a different look and feel with 
its respective games.

How do I do it in web2py? I mean, how do I handle resources based in the 
domain user typed in browser? 

Regards.

-- 

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




[web2py] Re: web2py roadmap

2013-07-14 Thread dhmorgan
Love it!

On Sunday, July 14, 2013 3:30:05 PM UTC-5, Niphlod wrote:

 web2py's developers work often behind the curtain and users are not able 
 to see what they're working on. Historically we tracked down 
 feature-requests and todo-lists on google code, but it's a nightmare to 
 track them and work with it efficiently.

 On a nice tip received by a power web2py user, we (developers) decided to 
 create something more readable to give us (developers AND users) a nice 
 representation on what's going on.

 Please welcome the official trello board for web2py's roadmap : 
 https://trello.com/b/d3aqBbBl


-- 

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




Re: [web2py] Re: this talk...

2013-07-14 Thread Jason (spot) Brower
When started my company I felt the same way.  I am a programmer.  I am also
the CEO.  I tell people no to jobs at my company because I want managers
that know how to program, or better, programmers that know how to manage. :)


On Sun, Jul 14, 2013 at 10:28 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 The talk is about tricks and tips to push forward technologies which a
 programmer finds useful within a traditional and technologically
 conservative corporate environment. He tells the story of a Ruby project
 within a corporate environment that was very hostile to changes. I have
 been in similar situations and I always ended up defeated. I have written
 programs (fully working, tested, offered at zero cost) that would have
 saved somebody $50K/year in software licenses. The CTO said: no thanks.
 Most CTO prefer a big vendor to free or in-house because are incapable of
 estimating the value and hidden costs of that and, the company ends up with
 the worst employees, those who will put up with that mentality. I can think
 of many people here who work for Java or C# shops and some times they'd
 rather use something else. I think the talks gives them useful tips.


 On Sunday, 14 July 2013 11:20:25 UTC-5, David Marko wrote:

 Hi Massimo, can you elaborate more on how it is relevant to this
 community? Do you have some ideas that come from this presentation?

 Dne neděle, 14. července 2013 18:03:06 UTC+2 Massimo Di Pierro napsal(a):

 https://vimeo.com/2723800

 I think this talk is really relevant to our community, and it gets
 really funny after the first 19 minute.

 Massimo

  --

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




-- 

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




[web2py] Smartgrid custom form problem

2013-07-14 Thread Sarbjit singh
Hi,

I am using customized form for adding records into database and using 
smartgrid to view/edit the records inserted in the database. Since, I am 
using the customized form for adding records into the database, I want to 
use the same layout for Edit operation (from SMARTGRID).

To achieve this, I added the check in the controller as :

{extend 'layout.html'}}
{{if 'edit' in request.args:}}
{{=grid.custom.begin}}
divName of object {{=grid.custom.widget.name}}/div
{{=grid.custom.submit}}
{{=grid.custom.end}}
{{else:}}
{{=grid}}
{{pass}}

But with this code, I am getting error. Can someone please help me on how 
to use custom form with SMARTGRID

-Sarbjit

-- 

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