[web2py] Re: Do you use web2py professionally?

2013-08-15 Thread Arnon Marcus
The explenation I gave shoul make it trivial to write a simple example - it 
boils everytings down to a few urls that return an xml. Writing such 
controller-actions in web2py is trivial to do with the aid of the web2py 
documentation - you may even be able to find examples. As for the xml 
formatting, again, it's in the documentation of treegrid itself - there may 
even be examples there also.

-- 

--- 
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: Do you use web2py professionally?

2013-08-15 Thread webpypy

Thank you, Arnon, for your cooperation.

Ashraf

-- 

--- 
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: File extention automatically changes when a file is uploaded

2013-08-15 Thread Anthony
Explicitly calling the .store() method should work in 2.4.6, but this 
method:

db(db.mytable.id==24).update(file1=request.vars.file1)

doesn't work in any stable version -- it only works in trunk (and therefore 
will work in the next stable release).

Anthony

On Thursday, August 15, 2013 2:39:13 AM UTC-4, at wrote:
>
>
> Thank you Anthony!
>
> That means it should be working in 2.4.6-stable? we've 2.4.6-stable on 
> production server.
>
> Regards,
> AT
>
> On Thursday, 15 August 2013 10:55:50 UTC+5, Anthony wrote:
>>
>> Looks like there was a bug, which has now been fixed in trunk. So, the 
>> second version will work in the next stable release.
>>
>> Anthony
>>
>> On Thursday, August 15, 2013 1:26:18 AM UTC-4, at wrote:
>>>
>>>
>>> 2.4.5
>>>
>>> On Thursday, 15 August 2013 07:44:02 UTC+5, Anthony wrote:

 What version of web2py are you using?

 On Wednesday, August 14, 2013 9:22:57 PM UTC-4, at wrote:
>
> Thanks a lot anthony,
> db(db.mytable.id==24).update(file1=db.mytable.file1.store(request.vars
> .file1)) 
> works,
>
> whereas
> db(db.mytable.id==24).update(file1=request.vars.file1)
> gives error:
>  ('ERROR', 
> '22001', 'value too long for type character varying(512)')
>
> PS. I'd replied to your post yesterday, but somehow it was not posted 
>
> On Tuesday, 13 August 2013 19:19:44 UTC+5, Anthony wrote:
>>
>> On Tuesday, August 13, 2013 9:20:47 AM UTC-4, at wrote:
>>
>>>
>>> Here is my controller code:
>>> def test_upload:
>>> if request.vars.file1 is not None:
>>>result = db(db.mytable.id
>>> ==24).update(file1=request.vars.file1.file)
>>>
>>
>> request.vars.file1 is a cgi.FieldStorage object. The original 
>> filename is therefore in request.vars.file1.filename. 
>> request.vars.file1.file is a temporary file on the filesystem, and it 
>> does 
>> not contain the original filename (instead, it has a temporary filename 
>> with no extension). If you want to manually insert an uploaded file, you 
>> should pass the cgi.FieldStorage object to the .insert() or .update() 
>> method rather than passing only the .file object from it. So, should be:
>>
>> db(db.mytable.id==24).update(file1=request.vars.file1)
>>
>> which is equivalent to calling:
>>
>> db(db.mytable.id==24).update(file1=db.mytable.file1.store(request.
>> vars.file1)) 
>>
>> Anthony
>>
>

-- 

--- 
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] It would be nice to see the downloads of web2py.

2013-08-15 Thread Jason (spot) Brower
It would be fun to have a download chart about how many people download
web2py in the day, week, month, ever.  Could that be added to the page
somewhere?  Maybe the download page?
BR,
Jason Brower

-- 

--- 
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] GAE local MySQL with DAL

2013-08-15 Thread Grace
Hi,

I am trying to work with Web2py for GAE, connect to my local MySQL. When I 
use DAL, with the following command:
db = DAL('mysql://username:password@localhost/dbname')

GAE log show the following:
RuntimeError: no driver available ('MySQLdb', 'pymysql')

but the above command work perfectly from web2py server.

Can someone please assist ?

I have try the following too:
1. From Python, I can use "import pymysql" without error
2. From Python, I can use "import MySQLdb" without error
(because I have install all relevant adapters following other threads 
suggestion.)

Thanks !


-- 

--- 
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: Request: Course about Web2py & TDD + pledge for cash

2013-08-15 Thread Mika Sjöman
Hi looks great.

Why don't you make it a free coursera.org course and add a hundred thousand 
students to your class? I am moving to Sweden so California is a bit far to 
go even though I would love to study in California ;) Also I see UCSC is 
already at Coursera: https://www.coursera.org/ucsc

What I would really like to see in a course is testing getting in from the 
start. This so it becomes less a programming lesson than a how to design 
applications really well. TDD should not be the last chapter, but rather 
one of the first. Otherwise we learn bad practices from start, get lazy, 
write tons of bad code, just to see it blow up in our faces later with mad 
bosses and customers. I am guessing I have written a million lines of code 
that is really that bad until today.

Mostly many of us (read the guys/girls who does not have a CS degree) start 
testing because we finally realize that we have to, or that one of those 
two categories above forces us to do so. 

I really think it is incredibly sad that programming courses mostly skip 
these subjects, when well written code requires testing and systematic 
approach/following design recipes. For me it feels a bit like being in 
highschool just to suddenly find out that my math teacher forgot to teach 
me division all the way.

Web2py is already super simple to learn, so why not teach it with a 
systematic programming recipes and testing from the start? All the way 
trough. It would make the students think like engineers instead of 
tinkers/hackers/coders just randomly writing code to get "stuff" done. 
Doing this from the start does not make it more difficult to learn. It 
makes people solve problems easier because they can use a systematic 
approach to solving the problems. Having the systematic approach removes 
hassle of the code mess blurring out the learning task. 

Cheers!


On Wednesday, August 14, 2013 1:36:45 AM UTC+8, Luca wrote:
>
> Dear Michael, 
>
> last year's class web page is here, and all is accessible mostly by 
> everybody.  There may be videos that, as they include students and did not 
> have all permissions, are accessible only from UCSC, but the rest should be 
> wide open. 
> This year will be similar, perhaps with more emphasis on angular. 
>
>
> https://sites.google.com/a/ucsc.edu/luca/classes/cmps-183-hypermedia-and-the-web/cmps-183-fall-2012
>
> Luca
>
> On Monday, August 12, 2013 7:23:08 PM UTC-7, Michael Herman wrote:
>>
>> I'd love to hear more about your curriculum that you're going to be 
>> teaching. I wrote the course Real Python for the Web @ RealPython.com. I'd 
>> love to compare notes. :)
>>  
>>
>> On Mon, Aug 12, 2013 at 6:53 PM, Luca  wrote:
>>
>>> I will be teaching a web dev class at UCSC based on web2py, and I may 
>>> make the videos available in YouTube.  
>>> Starting around September 20. 
>>> Email me if you are interested - lu...@ucsc.edu
>>>
>>> Thanks! -Luca
>>>
>>> On Sunday, August 11, 2013 10:29:46 AM UTC-7, Mika Sjöman wrote:

 Hi

 I am trying to get started with TDD and web2py, but it is really hard 
 since I do not have a CS degree. I have been studying this two courses at 
 Coursera, and especially the former is awesome (I did not like the Intro 
 to 
 Systematic program design so much)

 https://class.coursera.org/**programming2-001/
   # LTHP How to write quality code - awesome!
 https://class.coursera.org/**programdesign-001/class/index
  #Systematic program design

 I just wanted to say that if anyone out there is thinking of writing a 
 book or video course, I would certainly pay for it! Preferably a Udemy 
 course that shows how to do functional testing, unit testing, front end 
 Selenium, integration testing, proper cashing techniques for fast webites 
 etc. Preferably with TDD or some other framework, building lets say 3 to 4 
 small simple projects from scratch. 

 I am really sick and tired of writing code that blows up. While web2py 
 gave me an awesome way to easily write code and get going, I have not made 
 much progress writing better quality code with web2py. I think too much 
 time has been spent on learning to program (the language / frameworks), 
 while the problem for me has always been not being able to do proper 
 software engineering. 

 So here is a pledge. If any of you good TDD programmers do a small 
 video course on writing web2py software with TDD, Selenium, version 
 control 
 etc, then Ill be happy to chip in 50 USD for such a course. How about a 
 Udemy.com course? Here is the guide to get started: https://www.udemy.*
 *com/official-udemy-instructor-**course/
 For inspiration about topics I really reccomend looking at that LHTP 
 Writing Quali

[web2py] A few website projects built in Web2py

2013-08-15 Thread leapingstudios
I built these sites a while ago and figured I would release them. They 
weren't for clients, more personal projects. 

https://github.com/techshinobi/free-business-pages
https://github.com/techshinobi/echovids

The echovids project is a bit older but free-business-pages is a newer one. 
Can't give to much of an online example of either of these. But here is 
www.free-business-pages.com

Thanks for your time

Maybe some one can find some use for them. free-business-pages uses paypal 
and has a paypal subscription service, thanks to Bruna Rocha for a video 
tutorial of his which I came across on using Paypal/Web2py :D Echovids you 
can schedule a time for a TV show to play between. You can specify the time 
zone in the code.

Anyway *cheers

-- 

--- 
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] encoding problem in GAE when using format in db.define_table

2013-08-15 Thread juanchín chin chin
It seems that something isn't working properly when using the attribute
'format' and not-only English chars on db.define_table when deployed on GAE

Please, consider theses two table definitions:

db.define_table('ingrediente',
Field('nombre', 'string',
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')),
Field('precio', 'decimal(2,2)',
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el precio'),
default=1),
format="%(nombre)s - %(precio)s")

db.define_table('bocadillo',
Field('nombre', 'string',
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')),
Field('precio', 'decimal(2,2)',
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el precio'),
default=4.5),
Field('ingredientes', 'list:reference ingrediente',
comment='Seleccionar los componentes del bocadillo prediseñado usando
Control+click.'),
format='%(db.fotos)s - %(nombre)s - %(precio)s')

As you see, the second table has a one to many relation wich I would want
to be represented by the format attribute stated in the definition of the
first. The problem appears when I have non-English chars set in the first
table, chars as (áóé...) at the time to render a SQLFORM on the second
table.

Still, if I set the preferred format to the first table:

format="%(nombre)s - %(precio)s€" (Note the €)

Then it fails every time.

It happens only in deployed  GAE, not in local whether GAE or not.

I attach here the logs from GAE wich points out to an encodind issue:

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/restricted.py",
line 212, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
line 433, in 
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/globals.py",
line 194, in 
self._caller = lambda f: f()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
line 127, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
line 1140, in __init__
inp = self.widgets.options.widget(field, default)
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
line 278, in widget
options = requires[0].options()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
line 553, in options
self.build_set()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
line 548, in build_set
self.labels = [self.label % r for r in records]UnicodeDecodeError:
'ascii' codec can't decode byte 0xe2 in position 10: ordinal not in
range(128)


Is there anything I missed or a workaround to solve this?.

This is my first question here and I'm totally new to this great framework,
please, if this is already stated somewhere please refer it to me.

Thank you.

-- 

--- 
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] Encoding problem in 'format' from define_table on GAE

2013-08-15 Thread juan
Hello,

It seems that the format option in db.define_table isn't working properly 
when deployed on GAE.

Please, consider these two tables:

db.define_table('ingrediente',
Field('nombre', 'string', 
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')),
Field('precio', 'decimal(2,2)', 
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el precio'), 
default=1),
format="%(nombre)s - %(precio)s")

db.define_table('bocadillo',
Field('nombre', 'string', 
requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')), 
  
Field('ingredientes', 'list:reference ingrediente', 
comment='Seleccionar los componentes del bocadillo prediseñado usando 
Control+click.'))

The problem appears only in GAE and happens when some non-english character 
(áéíóú) is in the field name in the first table. It fails to render the 
SQLFORM of the second table. In addition, if I set the first table's format 
to the preferred

 format="%(nombre)s - %(precio)s€"

Note the new '€', then it always fails.

Here is the GAE log:

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/restricted.py",
 line 212, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
 line 433, in 
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/globals.py",
 line 194, in 
self._caller = lambda f: f()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
 line 127, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
 line 1140, in __init__
inp = self.widgets.options.widget(field, default)
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
 line 278, in widget
options = requires[0].options()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
 line 553, in options
self.build_set()
  File 
"/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
 line 548, in build_set
self.labels = [self.label % r for r in records]UnicodeDecodeError: 'ascii' 
codec can't decode byte 0xe2 in position 10: ordinal not in range(128)


Is there anything I missed, or if it's a bug, is there something I can do?

This is my first question and I am totally new to web2py, so please if this 
question is already aswered, I'm sorry to bother you.

Thank you



-- 

--- 
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 Sem Segredos

2013-08-15 Thread Matheus Godoy
Tenho muito interesse no curso, mas não consigo encaixar minha rotina em 
nenhum dos horários.
É possível a venda da gravação das aulas?

Abraço!

-- 

--- 
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] Header for selectable

2013-08-15 Thread Leonardo Pires Felix
How put a header on selectable column on SQLFORM.grid?

-- 

--- 
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: Has the format of the auth tables changed recently? Or the format of t

2013-08-15 Thread Massimo Di Pierro
This is strange because memdb has not changed. Looks like there is a query 
by id with id value = None and on GAE this is not possible. Anyway, I am 
looking into this ...

On Wednesday, 14 August 2013 18:21:45 UTC-5, Luca wrote:
>
> I have recently upgraded from web2py release R-2.4.6 to the head of the 
> branch. 
> I am using web2py on appengine, using: 
>
> from gluon.contrib.memdb import MEMDB
> from google.appengine.api.memcache import Client
> session.connect(request, response, db = MEMDB(Client()))
>
>
> I also have the following code in db.py, to monitor db performance: 
>
> def log_db(action): 
> d = action() 
> logger.info(repr(db._timings)) 
> return d
>
> response._caller = log_db
>
>
> When trying to login, using a session cookie that might have been set 
> before the update, I got the error below.  It happened systematically, 
> whenever I tried to log in. 
> Then, I downgraded to the older web2py R-2.4.6 release, logged in, then 
> out, and reupgraded to the newest release, and the error went away. 
>  Does anyone have any suggestions as to why this might be the case?  Has 
> the logging mechanism changed?  Have the auth tables changed? 
> Also, should this error be caught by web2py and handled in a more graceful 
> way? 
>
> Luca
>
>   File 
> "/home/luca/work/web2py-crowdrank/applications/crowdgrader/models/db.py", 
> line 220, in log_db
> d = action()
>   File 
> "/home/luca/work/web2py-crowdrank/applications/crowdgrader/controllers/default.py",
>  
> line 31, in user
> return dict(form=auth())
>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1293, in 
> __call__
> return getattr(self, args[0])()
>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 2253, in 
> login
> self.login_user(user)
>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1874, in 
> login_user
> db=sessdb
>   File "/home/luca/work/web2py-crowdrank/gluon/globals.py", line 739, in 
> renew
> row = db(table.id == record_id).select()
>   File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 
> 327, in __eq__
> return Query(self, '=', value)
>   File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 
> 507, in __init__
> id=long(right))
> ValueError: invalid literal for long() with base 10: 'None'
>
>
>

-- 

--- 
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: deployment to google app engine did not include my static files

2013-08-15 Thread Massimo Di Pierro
Sorry, was out of town and had connection very few hours a day. Trying to 
catch up. Tomorrow will be a little better.

On Wednesday, 14 August 2013 18:33:33 UTC-5, Luca wrote:
>
> Massimo, I have been trying to send you emails for some time without 
> success.  Is there some issue with your email? 
> Luca
>
> On Tuesday, August 13, 2013 7:15:57 AM UTC-7, Massimo Di Pierro wrote:
>>
>> email it to me please or post a patch on github.
>>
>> On Monday, 12 August 2013 19:03:59 UTC-5, Luca wrote:
>>>
>>> Shall I post a working app.yaml (minus confidential details) that works 
>>> with threadsafe=True? 
>>> Let me know if this would help.
>>> Luca
>>>
>>> On Sunday, August 4, 2013 12:12:16 PM UTC-7, davedigerati wrote:

 as you can see from here: http://sportssquaresonline.appspot.com/
 it did upload most of the static files, specifically 30, but the ones I 
 added, both images and a css file, it did not.
 any idea why???

 deployed both through the web2py admin feature and the GAE Launcher



-- 

--- 
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: c.r.m. source

2013-08-15 Thread Corne Dickens
It's somewhere half way on the page..
CustomerRelationshipManagement

source:
https://github.com/mdipierro/web2py-appliances/tree/master/CustomerRelationshipManagement

download:
https://raw.github.com/mdipierro/web2py-appliances/master/CustomerRelationshipManagement/web2py.app.CustomerRelationshipManagement.w2p

Op woensdag 14 augustus 2013 10:59:03 UTC+2 schreef andrej burja:
>
> hi
>
> i would like to examine the source code of 
> http://web2py-crm.appspot.com/
> but i can not find it on http://web2py.com/appliances/ 
>
> andrej
>

-- 

--- 
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: GAE local MySQL with DAL

2013-08-15 Thread Massimo Di Pierro
I do not believe GAE allows connections to external MySQL services. You 
have to connect to theirs with using DAL('google:sql://...')

On Thursday, 15 August 2013 02:33:04 UTC-5, Grace wrote:
>
> Hi, 
>
> I am trying to work with Web2py for GAE, connect to my local MySQL. When I 
> use DAL, with the following command: 
> db = DAL('mysql://username:password@localhost/dbname') 
>
> GAE log show the following: 
> RuntimeError: no driver available ('MySQLdb', 'pymysql') 
>
> but the above command work perfectly from web2py server. 
>
> Can someone please assist ? 
>
> I have try the following too: 
> 1. From Python, I can use "import pymysql" without error 
> 2. From Python, I can use "import MySQLdb" without error 
> (because I have install all relevant adapters following other threads 
> suggestion.) 
>
> Thanks ! 
>
>
>

-- 

--- 
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: Encoding problem in 'format' from define_table on GAE

2013-08-15 Thread Massimo Di Pierro
replace
 format="%(nombre)s - %(precio)s€"

with

 format= "%(nombre)s - %(precio)s\xe2\x82\xac"

because labels mush be in ascii (or utf8) but not unicode.

On Wednesday, 14 August 2013 15:57:24 UTC-5, juan wrote:
>
> Hello,
>
> It seems that the format option in db.define_table isn't working properly 
> when deployed on GAE.
>
> Please, consider these two tables:
>
> db.define_table('ingrediente',
> Field('nombre', 'string', 
> requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')),
> Field('precio', 'decimal(2,2)', 
> requires=IS_NOT_EMPTY(error_message='Se ha de indicar el precio'), 
> default=1),
> format="%(nombre)s - %(precio)s")
>
> db.define_table('bocadillo',
> Field('nombre', 'string', 
> requires=IS_NOT_EMPTY(error_message='Se ha de indicar el nombre')), 
>   
> Field('ingredientes', 'list:reference ingrediente', 
> comment='Seleccionar los componentes del bocadillo prediseñado usando 
> Control+click.'))
>
> The problem appears only in GAE and happens when some non-english 
> character (áéíóú) is in the field name in the first table. It fails to 
> render the SQLFORM of the second table. In addition, if I set the first 
> table's format to the preferred
>
>  format="%(nombre)s - %(precio)s€"
>
> Note the new '€', then it always fails.
>
> Here is the GAE log:
>
> Traceback (most recent call last):
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/restricted.py",
>  line 212, in restricted
> exec ccode in environment
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
>  line 433, in 
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/globals.py",
>  line 194, in 
> self._caller = lambda f: f()
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/applications/lapanza/controllers/appadmin.py",
>  line 127, in insert
> form = SQLFORM(db[table], ignore_rw=ignore_rw)
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
>  line 1140, in __init__
> inp = self.widgets.options.widget(field, default)
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/sqlhtml.py",
>  line 278, in widget
> options = requires[0].options()
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
>  line 553, in options
> self.build_set()
>   File 
> "/base/data/home/apps/s~lapanzaadomicilio-hrd/1.369502662945631224/gluon/validators.py",
>  line 548, in build_set
> self.labels = [self.label % r for r in records]UnicodeDecodeError: 
> 'ascii' codec can't decode byte 0xe2 in position 10: ordinal not in range(128)
>
>
> Is there anything I missed, or if it's a bug, is there something I can do?
>
> This is my first question and I am totally new to web2py, so please if 
> this question is already aswered, I'm sorry to bother you.
>
> Thank you
>
>
>
>

-- 

--- 
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: GAE local MySQL with DAL

2013-08-15 Thread Grace
Hi Massimo,

Thanks for the reply. I have change the line to 

db = DAL('google:sql://username:password@localhost/dbname')

and the GAE logs now show the following:

  File "C:\Program Files (x86)\Google\google_appengine\web2py\gluon\dal.py", 
lin
e 9958, in select
return adapter.select(self.query,fields,attributes)
  File "C:\Program Files (x86)\Google\google_appengine\web2py\gluon\dal.py", 
lin
e 1704, in select
return self._select_aux(sql,fields,attributes)
  File "C:\Program Files (x86)\Google\google_appengine\web2py\gluon\dal.py", 
lin
e 1670, in _select_aux
rows = self._fetchall()
  File "C:\Program Files (x86)\Google\google_appengine\web2py\gluon\dal.py", 
lin
e 1663, in _fetchall
return self.cursor.fetchall()
AttributeError: 'GoogleSQLAdapter' object has no attribute 'cursor'


Can you please advise ? Thanks and much appreciated.


-- 

--- 
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] reference db.auth_user from other Database..

2013-08-15 Thread hiro
Ok, well I will just think about moving all data to the external DB

On Wednesday, August 14, 2013 5:48:37 PM UTC+2, Carlos Correia wrote:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA1 
>
> Em 14-08-2013 15:23, hiro escreveu: 
> > Without touching db.py I have created a new file in order to add another 
> database. 
> > 
> > I want to keep the auth data in the standard setup but keep other parts 
> of my 
> > data in a large and fast external database. 
> > 
> > The problem I am having is that I cannot reference between the 
> databases. 
> > 
> > in my_new_db.py: 
> > 
> > external_db = DAL( 
> > 'postgres://connection_string', 
> > pool_size=10, 
> > migrate=False 
> > ) 
> > 
> > db.define_table( 
> > 'thing1', 
> > Field('name_of_thing1'), 
> > Field(user_id, db.auth_user) 
> > format = '%(name_of_thing1')s' 
> > ) 
> > 
> > external_db.define_table( 
> > 'thing2', 
> > Field('name_of_thing2'), 
> > Field(user_id, db.auth_user) 
> > format = '%(name_of_thing2')s' 
> > ) 
> > 
> > The first works fine but the second fail when I try to query from the 
> thing2 
> > table i get the error: AttributeError: 'DAL' object has no attribute 
> 'auth_user' 
> > 
> > Is it possible to cross reference the databases? If so, how? 
> > 
>
> Since you're using Postgresql, you can try dblink 
> (http://www.postgresql.org/docs/8.3/static/dblink.html), as suggested 
> here: 
>
> http://stackoverflow.com/questions/46324/possible-to-perform-cross-database-queries-with-postgres
>  
>
>
> - -- 
> Com os melhores cumprimentos, 
>
> Carlos Correia 
> = 
> MEMÓRIA PERSISTENTE 
> Tel.: 219 291 591 - GSM:  917 157 146 / 967 511 762 
> e-mail: ge...@memoriapersistente.pt  - URL: 
> http://www.memoriapersistente.pt 
> Jabber: m1...@jabber.org  
> GnuPG: wwwkeys.eu.pgp.net 
> URL Suporte: https://t5.m16e.com/gps 
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v1.4.12 (GNU/Linux) 
> Comment: Using GnuPG with undefined - http://www.enigmail.net/ 
>
> iEYEARECAAYFAlILptUACgkQ90uzwjA1SJXDXgCcDYla5lxis3KrvPTAwTbICM0P 
> Uh4AnRKEBUalCWrqev0LFHK4u+yjixV/ 
> =/izj 
> -END PGP SIGNATURE- 
>

-- 

--- 
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: reference db.auth_user from other Database..

2013-08-15 Thread hiro
Thank you...

On Wednesday, August 14, 2013 5:21:49 PM UTC+2, Niphlod wrote:
>
> nope it's not. 
>
> Is it possible to cross reference the databases? If so, how?
>>
>

-- 

--- 
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: InterfaceError: connection already closed

2013-08-15 Thread hiro
The latest: 2.5.1-stable+timestamp.2013.06.06.15.39.19, but I have hade the 
problem for a while with earlier versions of web2py.

On Tuesday, August 13, 2013 4:05:15 PM UTC+2, Massimo Di Pierro wrote:
>
> Do you know which web2py version?
>
> On Monday, 12 August 2013 09:49:32 UTC-5, hiro wrote:
>>
>> I have recently starting to get this error when accessing random pages 
>> and the admin interface.
>> All I need to do to stop receiving the error is to wait for a while, and 
>> then everything works for a while again.
>>
>> Where should I start looking in order to get rid of this error?
>>
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>>
>> Traceback (most recent call last):
>>   File "/home/me/web/gluon/main.py", line 631, in wsgibase
>> BaseAdapter.close_all_instances('rollback')
>>   File "/home/me/web/gluon/dal.py", line 553, in close_all_instances
>> db._adapter.close(action)
>>   File "/home/me/web/gluon/dal.py", line 533, in close
>> getattr(self, action)()
>>   File "/home/me/web/gluon/dal.py", line 1729, in rollback
>> if self.connection: return self.connection.rollback()
>> InterfaceError: connection already closed
>>
>>

-- 

--- 
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: GAE local MySQL with DAL

2013-08-15 Thread Massimo Di Pierro
Which web2py version?

On Thursday, 15 August 2013 04:32:58 UTC-5, Grace wrote:
>
> Hi Massimo, 
>
> Thanks for the reply. I have change the line to 
>
> db = DAL('google:sql://username:password@localhost/dbname') 
>
> and the GAE logs now show the following: 
>
>   File "C:\Program Files 
> (x86)\Google\google_appengine\web2py\gluon\dal.py", 
> lin 
> e 9958, in select 
> return adapter.select(self.query,fields,attributes) 
>   File "C:\Program Files 
> (x86)\Google\google_appengine\web2py\gluon\dal.py", 
> lin 
> e 1704, in select 
> return self._select_aux(sql,fields,attributes) 
>   File "C:\Program Files 
> (x86)\Google\google_appengine\web2py\gluon\dal.py", 
> lin 
> e 1670, in _select_aux 
> rows = self._fetchall() 
>   File "C:\Program Files 
> (x86)\Google\google_appengine\web2py\gluon\dal.py", 
> lin 
> e 1663, in _fetchall 
> return self.cursor.fetchall() 
> AttributeError: 'GoogleSQLAdapter' object has no attribute 'cursor' 
>
>
> Can you please advise ? Thanks and much appreciated. 
>
>
>

-- 

--- 
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: InterfaceError: connection already closed

2013-08-15 Thread Massimo Di Pierro
Can you try using the trunk version? This may be already fixed. For sure we 
have changed some of the relevant logic.
Let us know.

On Thursday, 15 August 2013 04:43:51 UTC-5, hiro wrote:
>
> The latest: 2.5.1-stable+timestamp.2013.06.06.15.39.19, but I have hade 
> the problem for a while with earlier versions of web2py.
>
> I am using and external Postgres db and Python 2.6.
>
> On Tuesday, August 13, 2013 4:05:15 PM UTC+2, Massimo Di Pierro wrote:
>>
>> Do you know which web2py version?
>>
>> On Monday, 12 August 2013 09:49:32 UTC-5, hiro wrote:
>>>
>>> I have recently starting to get this error when accessing random pages 
>>> and the admin interface.
>>> All I need to do to stop receiving the error is to wait for a while, and 
>>> then everything works for a while again.
>>>
>>> Where should I start looking in order to get rid of this error?
>>>
>>> Traceback
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/me/web/gluon/main.py", line 631, in wsgibase
>>> BaseAdapter.close_all_instances('rollback')
>>>   File "/home/me/web/gluon/dal.py", line 553, in close_all_instances
>>> db._adapter.close(action)
>>>   File "/home/me/web/gluon/dal.py", line 533, in close
>>> getattr(self, action)()
>>>   File "/home/me/web/gluon/dal.py", line 1729, in rollback
>>> if self.connection: return self.connection.rollback()
>>> InterfaceError: connection already closed
>>>
>>>

-- 

--- 
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: InterfaceError: connection already closed

2013-08-15 Thread hiro
Ok, I have updated to 2.6.0-development+timestamp.2013.08.08.09.00.28 now. 
Will give it some time and see if the error is still there.

Thank you very much for your help Massimo!

On Thursday, August 15, 2013 12:06:39 PM UTC+2, Massimo Di Pierro wrote:
>
> Can you try using the trunk version? This may be already fixed. For sure 
> we have changed some of the relevant logic.
> Let us know.
>
> On Thursday, 15 August 2013 04:43:51 UTC-5, hiro wrote:
>>
>> The latest: 2.5.1-stable+timestamp.2013.06.06.15.39.19, but I have hade 
>> the problem for a while with earlier versions of web2py.
>>
>> I am using and external Postgres db and Python 2.6.
>>
>> On Tuesday, August 13, 2013 4:05:15 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> Do you know which web2py version?
>>>
>>> On Monday, 12 August 2013 09:49:32 UTC-5, hiro wrote:

 I have recently starting to get this error when accessing random pages 
 and the admin interface.
 All I need to do to stop receiving the error is to wait for a while, 
 and then everything works for a while again.

 Where should I start looking in order to get rid of this error?

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.

 Traceback (most recent call last):
   File "/home/me/web/gluon/main.py", line 631, in wsgibase
 BaseAdapter.close_all_instances('rollback')
   File "/home/me/web/gluon/dal.py", line 553, in close_all_instances
 db._adapter.close(action)
   File "/home/me/web/gluon/dal.py", line 533, in close
 getattr(self, action)()
   File "/home/me/web/gluon/dal.py", line 1729, in rollback
 if self.connection: return self.connection.rollback()
 InterfaceError: connection already closed



-- 

--- 
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: Accessing attributes of reference fields

2013-08-15 Thread Quint
like this?
 
You run a query with an extra option specify the ref fields to pre-fetch. 
and then it would query all the referenced rows in a smart way (only fetch 
a record 1x).
 
Is there a  generally accepted way to handle this (in the absence of  the 
mentioned feature)?
 
Right now I'm fetching my rows and loop over it and store the referenced 
rows in a dictionary and at the end use the dict to store the fetched rows 
on the parent rows.
Then a pass the composite thing to my view.
 
 
 
 
 
 

On Tuesday, August 13, 2013 4:24:49 PM UTC+2, Anthony wrote:

> Yes, the reference fields execute a query each time when you access their 
> attributes -- there is no caching. I think it might be a good idea to 
> implement caching as an option. Even better, there should be an option to 
> fetch the related records for all rows along with the initial select, 
> either via a join or a single additional select -- this would be much more 
> efficient than running a separate select for each row when you've got lots 
> of rows.
>
> Anthony
>
> On Tuesday, August 13, 2013 3:34:37 AM UTC-4, Quint wrote:
>>
>> Hello web2py users,
>>  
>> I have a question about reference fields.
>>  
>> When i access a attribute of a reference Field, i notice that the 
>> reference field is represented by an instance of the "Reference" class.
>> When i access attributes on that reference , will it perform a new query 
>> each time or does it cache previous queries somehow?
>>  
>> BTW, I'm using *GAE*
>>  
>> Example:
>>  
>> I have a table "comment" which has a reference field "author auth_user"
>> Now i perform a query and i retrieve a list of comments which contains a 
>> lot of comments from the same user.
>> When i access a attribute on those comments will it query the auth_user 
>> table for all comments of the same author?
>>  
>> Thanks and 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: Accessing attributes of reference fields

2013-08-15 Thread Anthony
On Thursday, August 15, 2013 6:57:23 AM UTC-4, Quint wrote:

> like this?
>  
> You run a query with an extra option specify the ref fields to pre-fetch. 
> and then it would query all the referenced rows in a smart way (only fetch 
> a record 1x).
>  
> Is there a  generally accepted way to handle this (in the absence of  the 
> mentioned feature)?
>

Well, the most efficient way is probably to do a join, but that results in 
a somewhat different type of object.
 

>  
> Right now I'm fetching my rows and loop over it and store the referenced 
> rows in a dictionary and at the end use the dict to store the fetched rows 
> on the parent rows.
> Then a pass the composite thing to my view.
>

I suppose you could also do something like that using Field.Virtual:

db.define_table('person',
Field('name'),
Field.Virtual('dogs', lambda r: r.person.dog.select()))

db.define_table('dog',
Field('name'),
Field('owner', 'reference person'))

bob = db(db.person.name == 'Bob').select().first()
print bob.dogs

Or going in the other direction:

db.define_table('person',
Field('name'))

db.define_table('dog',
Field('name'),
Field('owner', 'reference person'),
Field.Virtual('owner_record', lambda r: db.person(r.dog.owner)))

spot = db(db.dog.name == 'spot').select().first()
print spot.owner_record.name

Note, don't define these virtual fields in both tables at the same time, as 
that will lead to infinite recursion when attempting a select from either 
one.

Anthony

-- 

--- 
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: How to define identical tables at once?

2013-08-15 Thread Richard Vézina
Read book about database design, database normalization particularly. To
get all those information (linked user, message the leave, etc.) you will
have to make query that just the way a database works.

Richard


On Wed, Aug 14, 2013 at 9:01 PM, Hunt  wrote:

> Yea sorry... I did an absolutely awful job of explaining.
>
> In my app, I want the user to have a list of 'friends' in his/her profile
> that he can message and see what content they have posted (very original,
> night?).  My plan is to have users be able to view other users content who
> they are NOT friends with through other means; but if they take a liking to
> it they can 'friend' the person and be able to easily view what the
> 'friended' user has been up to.  Sort of like book marking things in a
> browser I guess.
>
> In my mind it would be more efficient to have each user have its table
> that was a list of its users.  It just seamed silly in my mind to query
> every single user for the relationship...
>
> Clearly a total noob in database design here!  Thanks so much for taking
> the time to answer my dumb questions.
>
> Do you think it would help me to spend a while writing raw SQL to get an
> idea of how DBs are structured?  Any references to help me get a grip would
> be much appreciated.
>
> Thanks so much again for the help,
> Hunt
>
>
>
> On Wednesday, August 14, 2013 2:17:28 PM UTC-4, Richard wrote:
>
>> If you explain better what you want to acheive, we could help you
>> better...
>>
>> Maybe you just need a self reference field name friend_id let you
>> associate each user which are friends. Maybe you need a many to many
>> relation table where you will where you can manage there friendship
>> relation between each user.
>>
>> But for sure, forget about the idea of creating 1000 tables...
>>
>> RIchard
>>
>>
>> On Wed, Aug 14, 2013 at 1:27 PM, Hunt  wrote:
>>
>>> Really?  So I should just add like a 1000 "friend_id" fields to
>>> auth_user?  I thought there would an easier way to go about this.
>>>
>>> Thanks though Marin!
>>>
>>>
>>> On Wednesday, August 14, 2013 2:07:08 AM UTC-4, Marin Pranjić wrote:
>>>
 Don't do that. It is wrong.
 Create only one new table and put everything there

 Marin (mobile)

 On Aug 14, 2013 7:08 AM, "Hunt"  wrote:

 Did an absolutely atrocious job naming this question.  A better title
 would be:  "How to auto-generate an additional table for each auth_user
 table entry".



 On Tuesday, August 13, 2013 5:54:03 PM UTC-4, Hunt wrote:
 >
 > Hi all,
 >
 > I want to add a 'friends...


 --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users"...

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

-- 

--- 
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: Accessing attributes of reference fields

2013-08-15 Thread Quint
thnx, 
 
but my goal is to prevent repeated queries for the same record when 
accessing ref fields on rows from the same result set.
 
I'm missing something, how do those Virtual Fields achieve that?
 
And about the join, wouldn't that mean it won't work on GAE?
 

On Thursday, August 15, 2013 2:19:06 PM UTC+2, Anthony wrote:

> On Thursday, August 15, 2013 6:57:23 AM UTC-4, Quint wrote:
>
>> like this?
>>  
>> You run a query with an extra option specify the ref fields to pre-fetch. 
>> and then it would query all the referenced rows in a smart way (only fetch 
>> a record 1x).
>>  
>> Is there a  generally accepted way to handle this (in the absence of  the 
>> mentioned feature)?
>>
>
> Well, the most efficient way is probably to do a join, but that results in 
> a somewhat different type of object.
>  
>
>>  
>> Right now I'm fetching my rows and loop over it and store the referenced 
>> rows in a dictionary and at the end use the dict to store the fetched rows 
>> on the parent rows.
>> Then a pass the composite thing to my view.
>>
>
> I suppose you could also do something like that using Field.Virtual:
>
> db.define_table('person',
> Field('name'),
> Field.Virtual('dogs', lambda r: r.person.dog.select()))
>
> db.define_table('dog',
> Field('name'),
> Field('owner', 'reference person'))
>
> bob = db(db.person.name == 'Bob').select().first()
> print bob.dogs
>
> Or going in the other direction:
>
> db.define_table('person',
> Field('name'))
>
> db.define_table('dog',
> Field('name'),
> Field('owner', 'reference person'),
> Field.Virtual('owner_record', lambda r: db.person(r.dog.owner)))
>
> spot = db(db.dog.name == 'spot').select().first()
> print spot.owner_record.name
>
> Note, don't define these virtual fields in both tables at the same time, 
> as that will lead to infinite recursion when attempting a select from 
> either one.
>
> Anthony
>

-- 

--- 
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] (GAE) periodic updates

2013-08-15 Thread jjg0
(Using google app engine if that matters)

I have a table that I want to update on a weekly basis.  Basically it's a 
simple table of users with a date field that gets set to the last time they 
did something and a field to indicate that they are active. I want to check 
every Monday which users weren't active for the prior week and  set them to 
inactive.  Is this possible?  What would I use to do this so this check is 
only done once every week.  I could set this up to run every time someone 
requests a page but that seems like a waste. I want this to somehow trigger 
on its own.

Thanks!

-- 

--- 
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: Accessing attributes of reference fields

2013-08-15 Thread Anthony
On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:

> thnx, 
>  
> but my goal is to prevent repeated queries for the same record when 
> accessing ref fields on rows from the same result set.
>  
> I'm missing something, how do those Virtual Fields achieve that?
>

Yes, that's exactly what the virtual field does -- when the the Rows object 
is created from the initial select, the value of the virtual field is 
calculated for each Row, and it remains in the Row (i.e., it is not 
re-calculated on each access). There is also Field.Method(), which does 
re-calculate on every access (the advantage is that it is lazy, so nothing 
is calculated until accessed -- and because of that, it can take arguments 
at the time it is called).

 And about the join, wouldn't that mean it won't work on GAE?
>

Oh, yeah, forgot you said you are on GAE.

Anthony

-- 

--- 
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: Has the format of the auth tables changed recently? Or the format of t

2013-08-15 Thread Massimo Di Pierro
A possible fix is in trunk. Please help me check it.

On Thursday, 15 August 2013 03:59:56 UTC-5, Massimo Di Pierro wrote:
>
> This is strange because memdb has not changed. Looks like there is a query 
> by id with id value = None and on GAE this is not possible. Anyway, I am 
> looking into this ...
>
> On Wednesday, 14 August 2013 18:21:45 UTC-5, Luca wrote:
>>
>> I have recently upgraded from web2py release R-2.4.6 to the head of the 
>> branch. 
>> I am using web2py on appengine, using: 
>>
>> from gluon.contrib.memdb import MEMDB
>> from google.appengine.api.memcache import Client
>> session.connect(request, response, db = MEMDB(Client()))
>>
>>
>> I also have the following code in db.py, to monitor db performance: 
>>
>> def log_db(action): 
>> d = action() 
>> logger.info(repr(db._timings)) 
>> return d
>>
>> response._caller = log_db
>>
>>
>> When trying to login, using a session cookie that might have been set 
>> before the update, I got the error below.  It happened systematically, 
>> whenever I tried to log in. 
>> Then, I downgraded to the older web2py R-2.4.6 release, logged in, then 
>> out, and reupgraded to the newest release, and the error went away. 
>>  Does anyone have any suggestions as to why this might be the case?  Has 
>> the logging mechanism changed?  Have the auth tables changed? 
>> Also, should this error be caught by web2py and handled in a more 
>> graceful way? 
>>
>> Luca
>>
>>   File 
>> "/home/luca/work/web2py-crowdrank/applications/crowdgrader/models/db.py", 
>> line 220, in log_db
>> d = action()
>>   File 
>> "/home/luca/work/web2py-crowdrank/applications/crowdgrader/controllers/default.py",
>>  
>> line 31, in user
>> return dict(form=auth())
>>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1293, in 
>> __call__
>> return getattr(self, args[0])()
>>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 2253, in 
>> login
>> self.login_user(user)
>>   File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1874, in 
>> login_user
>> db=sessdb
>>   File "/home/luca/work/web2py-crowdrank/gluon/globals.py", line 739, in 
>> renew
>> row = db(table.id == record_id).select()
>>   File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 
>> 327, in __eq__
>> return Query(self, '=', value)
>>   File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 
>> 507, in __init__
>> id=long(right))
>> ValueError: invalid literal for long() with base 10: 'None'
>>
>>
>>

-- 

--- 
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: Accessing attributes of reference fields

2013-08-15 Thread Quint van den Muijsenberg
But when when a row is calculating it's virtual field, it will fetch the
referenced row even when some other row from the initial set has already
fetched this same referenced row (when they are referencing the same
thing). So they will both perform the same fetch.

?

I want to do this fetch 1x and use that record for all rows from the
initial set that reference it.
On Aug 15, 2013 4:18 PM, "Anthony"  wrote:

> On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:
>
>> thnx,
>>
>> but my goal is to prevent repeated queries for the same record when
>> accessing ref fields on rows from the same result set.
>>
>> I'm missing something, how do those Virtual Fields achieve that?
>>
>
> Yes, that's exactly what the virtual field does -- when the the Rows
> object is created from the initial select, the value of the virtual field
> is calculated for each Row, and it remains in the Row (i.e., it is not
> re-calculated on each access). There is also Field.Method(), which does
> re-calculate on every access (the advantage is that it is lazy, so nothing
> is calculated until accessed -- and because of that, it can take arguments
> at the time it is called).
>
>  And about the join, wouldn't that mean it won't work on GAE?
>>
>
> Oh, yeah, forgot you said you are on GAE.
>
> Anthony
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/IrAe-AGpiMU/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Accessing attributes of reference fields

2013-08-15 Thread Anthony
Good point. I suppose you can adapt your method to work with a virtual 
field:

owners = {}
db.define_table('dog',
...
Field.Virtual('owner_record',
lambda r: owners.setdefault(r.dog.owner, db.person(r.dog.owner)))

That will store each fetched owner record in the owners dict, so the record 
will be copied from the dict if it is already there rather than pulled from 
the db.

Anthony

On Thursday, August 15, 2013 12:09:02 PM UTC-4, Quint wrote:
>
> But when when a row is calculating it's virtual field, it will fetch the 
> referenced row even when some other row from the initial set has already 
> fetched this same referenced row (when they are referencing the same 
> thing). So they will both perform the same fetch.
>
> ?
>
> I want to do this fetch 1x and use that record for all rows from the 
> initial set that reference it.
> On Aug 15, 2013 4:18 PM, "Anthony" > 
> wrote:
>
>> On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:
>>
>>> thnx, 
>>>  
>>> but my goal is to prevent repeated queries for the same record when 
>>> accessing ref fields on rows from the same result set.
>>>  
>>> I'm missing something, how do those Virtual Fields achieve that?
>>>
>>
>> Yes, that's exactly what the virtual field does -- when the the Rows 
>> object is created from the initial select, the value of the virtual field 
>> is calculated for each Row, and it remains in the Row (i.e., it is not 
>> re-calculated on each access). There is also Field.Method(), which does 
>> re-calculate on every access (the advantage is that it is lazy, so nothing 
>> is calculated until accessed -- and because of that, it can take arguments 
>> at the time it is called).
>>
>>  And about the join, wouldn't that mean it won't work on GAE?
>>>
>>
>> Oh, yeah, forgot you said you are on GAE.
>>
>> Anthony
>>
>> -- 
>>  
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/IrAe-AGpiMU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@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.


Re: [web2py] Header for selectable

2013-08-15 Thread Richard Vézina
Could you be more precise?

There is headers SQLFORM.grid attribute :


   - headers is a dictionary that maps 'tablename.fieldname' into the
   corresponding header label, e.g. {'auth_user.email' : 'Email Address'}


But it difficult to know what you need exactly...

Richard


On Wed, Aug 14, 2013 at 9:16 AM, Leonardo Pires Felix <
leona...@piresfelix.com> wrote:

> How put a header on selectable column on SQLFORM.grid?
>
> --
>
> ---
> 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] IS_IN_DB zero= solution

2013-08-15 Thread Annet
Since IS_IN_DB ignores zero='' I tried this:

form.element('select[name=navID]').append("Select 4 functions")

However, the options are sorted by id and  "Select 4 functions" ends
up as the last option. Is there a way to move it to the top of the list
of options?


Kind regards,

Annet

-- 

--- 
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] IS_IN_DB zero= solution

2013-08-15 Thread Richard Vézina
insert(0, "Select 4 functions") doesn't work?

Richard


On Thu, Aug 15, 2013 at 1:56 PM, Annet  wrote:

> Since IS_IN_DB ignores zero='' I tried this:
>
> form.element('select[name=navID]').append("Select 4 functions")
>
> However, the options are sorted by id and  "Select 4 functions" ends
> up as the last option. Is there a way to move it to the top of the list
> of options?
>
>
> Kind regards,
>
> Annet
>
> --
>
> ---
> 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] web2py menus don't like iPhone!

2013-08-15 Thread Joe Barnhart
Well, it's not web2py's fault.  But Bootstrap recently did something that 
causes their menus to fail on iPhone, and I have verified this behavior. 
 Basically you can't select any menu choices, leaving you unable to log in. 
 I don't know if there's a real fix yet... We tried the suggested fix on 
the Bootstrap forum without success but we're still working on it...

Thought everyone should know...

-- Joe

P.S.  Please, no Android jokes!

-- 

--- 
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] web2py menus don't like iPhone!

2013-08-15 Thread Marin Pranjić
Are you using bootstrap 2.3.2?

Try this:

https://github.com/twbs/bootstrap/issues/7968

On Thu, Aug 15, 2013 at 8:04 PM, Joe  Barnhart  wrote:
> Well, it's not web2py's fault.  But Bootstrap recently did something that
> causes their menus to fail on iPhone, and I have verified this behavior.
> Basically you can't select any menu choices, leaving you unable to log in.
> I don't know if there's a real fix yet... We tried the suggested fix on the
> Bootstrap forum without success but we're still working on it...
>
> Thought everyone should know...
>
> -- Joe
>
> P.S.  Please, no Android jokes!
>
> --
>
> ---
> 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.


Re: [web2py] IS_IN_DB zero= solution

2013-08-15 Thread Niphlod
apart from that, IS_IN_DB totally works with zero (unless multiple=True, in 
which a zero argument kinda defeats the purpose). Are you sure that you're 
not adding other validators to that field ?

On Thursday, August 15, 2013 7:59:55 PM UTC+2, Richard wrote:
>
> insert(0, "Select 4 functions") doesn't work?
>
> Richard
>
>
> On Thu, Aug 15, 2013 at 1:56 PM, Annet 
> > wrote:
>
>> Since IS_IN_DB ignores zero='' I tried this:
>>
>> form.element('select[name=navID]').append("Select 4 functions")
>>
>> However, the options are sorted by id and  "Select 4 functions" ends
>> up as the last option. Is there a way to move it to the top of the list
>> of options?
>>
>>
>> Kind regards,
>>
>> Annet
>>  
>> -- 
>>  
>> --- 
>> 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 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] db.mytable.myfield.contains() gives an error Query Not Supported: parser stack overflow

2013-08-15 Thread dave
.
.
.
x = ['a', 'b', 'c', ...]
queries.append(db.mytable.myfield.contains(x))
query = reduce(lambda a,b:(a&b),queries)
grid = SQLFORM.grid(query, ...)

return (grid=grid)

gives an error of "Query Not Supported: parser stack overflow", if the list 
x has too many values, like around 100 or a 1000, I suspect its an sqlite 
limitation? can anyone suggest another succinct way of passing a list to a 
contain like operator or method 

-- 

--- 
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] IS_IN_DB zero= solution

2013-08-15 Thread Annet
Thank you both for your replies.

apart from that, IS_IN_DB totally works with zero (unless multiple=True, in 
> which a zero argument kinda defeats the purpose). Are you sure that you're 
> not adding other validators to that field ?
>

 This is the IS_IN_DB validator:

db.register.navID.requires=IS_IN_DB(db(db.nav.id.belongs(WHOWEARENAVID,WHATWEDONAVID,HOWWEWORKNAVID,OPENINGHOURSNAVID,\
EVENTLISTNAVID,TIMETABLENAVID,COURSETABLENAVID)),'nav.id','%(name)s', 
orderby='nav.id', multiple=(1, 5))

which works as expected, accept that I cannot set zero='select 4 functions'


Kind regards,

Annet

-- 

--- 
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: Pass python list back to controller

2013-08-15 Thread Richard Vézina
ids = [1, 2, 3]
redirect(URL(c='test', f='side_by_side', args=(request.args(0)),
vars=dict(ids=ids)))

ids = request.vars.ids

Work as well...

The url look like that :

test/side_by_side/table?ids=1&ids=2&ids=3

I have use session.ids before, but I need to pass a list of id by the url
in order to not have to write a big infrastructure to store each "report"
constructed by user... Having everything in the url let call the same
report again and again (constructed once by selecting the differents
records with a form that than redirect on the url of the report). Then the
only thing I have to manage is a bunch of links that user can keep in a
table of report or something. The user as only to copy url and send it by
email to colleague...

:)

Richard


On Thu, Aug 8, 2013 at 5:24 PM, Kyle Flanagan wrote:

> This worked well. Thanks.
>
>
> On Thursday, July 18, 2013 11:18:23 AM UTC-5, Ykä Marjanen wrote:
>>
>> Hi,
>>
>> If I understood correctly, you could use 'session' to save the list, so
>> you don't have to pass it back and forth to the controller.
>>
>> E.g. session.serials = [] and then session.serials.append(x)
>>
>> Ykä
>>
>> On Thursday, July 18, 2013 6:55:52 PM UTC+3, Kyle Flanagan wrote:
>>>
>>> What's the best way to pass a Python list back to the controller, i.e.
>>> keep the list object persistent between calls? The list could get quite
>>> large so I'm not sure if request.args or request.vars is appropriate for it
>>> (well the items in the list)? The code below is a mockup of what I'm trying
>>> to achieve. The list in question is 'serials.'
>>>
>>> @auth.requires_login()
>>> def send():
>>> """
>>> Method for 'sending'an IBC tote to a location.
>>> """
>>> try:
>>> if serials:
>>> pass
>>> except:
>>> serials = list()
>>>
>>> if request.vars["location_id"]:
>>> if request.vars["serial_number"]:
>>> # update the location
>>> serials.append(request.vars["**serial_number"])
>>>
>>> # start accepting input to update IBC's to this location
>>> status = "Location: " + db.MyLocation[request.vars['**
>>> location_id']].name
>>> form = SQLFORM.factory(Field('Object_**serial_number', requires=
>>> IS_IN_DB(db, 'Object.serial_number', '%(serial_number)s', orderby=db.
>>> Object.serial_**number)))
>>> if form.process().accepted:
>>> response.flash = form.vars.Object_serial_number
>>> redirect(URL('send', vars=dict(location_id=request.**vars[
>>> "location_id"], serial_number=form.vars.Object**_serial_number)))
>>> else:
>>> # we need to pick a location
>>> form = SQLFORM.factory(Field('send_**location', requires=
>>> IS_IN_DB(db, 'MyLocation.id', '%(name)s', orderby=db.MyLocation.name)))
>>> if form.process().accepted:
>>> response.flash = form.vars.send_location
>>> redirect(URL('send', vars=dict(location_id=form.var**s.
>>> send_location)))
>>> status = "No location"
>>>
>>> return dict(grid=form, status=status, serials=serials, count=len(
>>> serials))
>>>
>>> Basically, the user goes to the 'send' controller, picks a location,
>>> then enters serial numbers. I'd like to keep a list going so that the user
>>> can remove a serial number from the list if they added one in error and
>>> then submit them for updating all at once.
>>>
>>  --
>
> ---
> 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.


Re: [web2py] Re: Accessing attributes of reference fields

2013-08-15 Thread Quint
Thanks!

Got it woking now but i got strange results:

("Not working" means that the same referenced record is being fetched every 
time and not read from the dict)

This is not working:

Field.Virtual('created_by_record',
lambda r: users.setdefault(r.comment.created_by.id, db.
auth_user(r.comment.created_by))),

This is also not working:

users = {}
def created_by_record(r):
k = r.comment.created_by.id
return users.setdefault(k, db.auth_user(k))


Field.Virtual('created_by_record', created_by_record),

But this is working:

users = {}
def created_by_record(r):
k = r.comment.created_by.id
if k in users:
return users[k]
users[k] = db.auth_user(k)
return users[k]


Field.Virtual('created_by_record', created_by_record),






On Thursday, August 15, 2013 6:37:18 PM UTC+2, Anthony wrote:
>
> Good point. I suppose you can adapt your method to work with a virtual 
> field:
>
> owners = {}
> db.define_table('dog',
> ...
> Field.Virtual('owner_record',
> lambda r: owners.setdefault(r.dog.owner, db.person(r.dog.owner)))
>
> That will store each fetched owner record in the owners dict, so the 
> record will be copied from the dict if it is already there rather than 
> pulled from the db.
>
> Anthony
>
> On Thursday, August 15, 2013 12:09:02 PM UTC-4, Quint wrote:
>>
>> But when when a row is calculating it's virtual field, it will fetch the 
>> referenced row even when some other row from the initial set has already 
>> fetched this same referenced row (when they are referencing the same 
>> thing). So they will both perform the same fetch.
>>
>> ?
>>
>> I want to do this fetch 1x and use that record for all rows from the 
>> initial set that reference it.
>> On Aug 15, 2013 4:18 PM, "Anthony"  wrote:
>>
>>> On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:
>>>
 thnx, 
  
 but my goal is to prevent repeated queries for the same record when 
 accessing ref fields on rows from the same result set.
  
 I'm missing something, how do those Virtual Fields achieve that?

>>>
>>> Yes, that's exactly what the virtual field does -- when the the Rows 
>>> object is created from the initial select, the value of the virtual field 
>>> is calculated for each Row, and it remains in the Row (i.e., it is not 
>>> re-calculated on each access). There is also Field.Method(), which does 
>>> re-calculate on every access (the advantage is that it is lazy, so nothing 
>>> is calculated until accessed -- and because of that, it can take arguments 
>>> at the time it is called).
>>>
>>>  And about the join, wouldn't that mean it won't work on GAE?

>>>
>>> Oh, yeah, forgot you said you are on GAE.
>>>
>>> Anthony
>>>
>>> -- 
>>>  
>>> --- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/IrAe-AGpiMU/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> web2py+un...@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.


Re: [web2py] IS_IN_DB zero= solution

2013-08-15 Thread Richard Vézina
Maybe you could use IS_IN_SET... You just have to pass you query to it on
construct a dict from the query... Refer you to this post of Anthony :

https://groups.google.com/d/msg/web2py/QBTYaytNypU/DW2HpnT-xK0J

http://web2py.com/books/default/chapter/29/07/forms-and-validators#Validators
Scroll
a bit to IS_IN_SET

You may add a choice to your set for your Zero...

Richard


On Thu, Aug 15, 2013 at 3:18 PM, Annet  wrote:

> Thank you both for your replies.
>
>
> apart from that, IS_IN_DB totally works with zero (unless multiple=True,
>> in which a zero argument kinda defeats the purpose). Are you sure that
>> you're not adding other validators to that field ?
>>
>
>  This is the IS_IN_DB validator:
>
>
> db.register.navID.requires=IS_IN_DB(db(db.nav.id.belongs(WHOWEARENAVID,WHATWEDONAVID,HOWWEWORKNAVID,OPENINGHOURSNAVID,\
> EVENTLISTNAVID,TIMETABLENAVID,COURSETABLENAVID)),'nav.id','%(name)s',
> orderby='nav.id', multiple=(1, 5))
>
> which works as expected, accept that I cannot set zero='select 4 functions'
>
>
> Kind regards,
>
> Annet
>
> --
>
> ---
> 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.


Re: [web2py] IS_IN_DB zero= solution

2013-08-15 Thread Richard Vézina
You use multiple... So I guess as Niphold says you can't use zero...

Maybe consider create some kind of popover or use comment that is there for
that purpose so beside you field the user will be tell to select 4
functions...

Richard


On Thu, Aug 15, 2013 at 3:26 PM, Richard Vézina  wrote:

> Maybe you could use IS_IN_SET... You just have to pass you query to it on
> construct a dict from the query... Refer you to this post of Anthony :
>
> https://groups.google.com/d/msg/web2py/QBTYaytNypU/DW2HpnT-xK0J
>
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Validators 
> Scroll
> a bit to IS_IN_SET
>
> You may add a choice to your set for your Zero...
>
> Richard
>
>
> On Thu, Aug 15, 2013 at 3:18 PM, Annet  wrote:
>
>> Thank you both for your replies.
>>
>>
>> apart from that, IS_IN_DB totally works with zero (unless multiple=True,
>>> in which a zero argument kinda defeats the purpose). Are you sure that
>>> you're not adding other validators to that field ?
>>>
>>
>>  This is the IS_IN_DB validator:
>>
>>
>> db.register.navID.requires=IS_IN_DB(db(db.nav.id.belongs(WHOWEARENAVID,WHATWEDONAVID,HOWWEWORKNAVID,OPENINGHOURSNAVID,\
>> EVENTLISTNAVID,TIMETABLENAVID,COURSETABLENAVID)),'nav.id','%(name)s',
>> orderby='nav.id', multiple=(1, 5))
>>
>> which works as expected, accept that I cannot set zero='select 4
>> functions'
>>
>>
>> Kind regards,
>>
>> Annet
>>
>> --
>>
>> ---
>> 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.


Re: [web2py] Re: Accessing attributes of reference fields

2013-08-15 Thread Quint van den Muijsenberg
Appears that with set_default, the default param is always evaluated and
this will perform the query every time guess..
On Aug 15, 2013 9:21 PM, "Quint"  wrote:

> Thanks!
>
> Got it woking now but i got strange results:
>
> ("Not working" means that the same referenced record is being fetched
> every time and not read from the dict)
>
> This is not working:
>
> Field.Virtual('created_by_record',
> lambda r: users.setdefault(r.comment.created_by.id, db
> .auth_user(r.comment.created_by))),
>
> This is also not working:
>
> users = {}
> def created_by_record(r):
> k = r.comment.created_by.id
> return users.setdefault(k, db.auth_user(k))
>
>
> Field.Virtual('created_by_record', created_by_record),
>
> But this is working:
>
> users = {}
> def created_by_record(r):
> k = r.comment.created_by.id
> if k in users:
> return users[k]
> users[k] = db.auth_user(k)
> return users[k]
>
>
> Field.Virtual('created_by_record', created_by_record),
>
>
>
>
>
>
> On Thursday, August 15, 2013 6:37:18 PM UTC+2, Anthony wrote:
>>
>> Good point. I suppose you can adapt your method to work with a virtual
>> field:
>>
>> owners = {}
>> db.define_table('dog',
>> ...
>> Field.Virtual('owner_record',
>> lambda r: owners.setdefault(r.dog.owner, db.person(r.dog.owner)))
>>
>> That will store each fetched owner record in the owners dict, so the
>> record will be copied from the dict if it is already there rather than
>> pulled from the db.
>>
>> Anthony
>>
>> On Thursday, August 15, 2013 12:09:02 PM UTC-4, Quint wrote:
>>>
>>> But when when a row is calculating it's virtual field, it will fetch the
>>> referenced row even when some other row from the initial set has already
>>> fetched this same referenced row (when they are referencing the same
>>> thing). So they will both perform the same fetch.
>>>
>>> ?
>>>
>>> I want to do this fetch 1x and use that record for all rows from the
>>> initial set that reference it.
>>> On Aug 15, 2013 4:18 PM, "Anthony"  wrote:
>>>
 On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:

> thnx,
>
> but my goal is to prevent repeated queries for the same record when
> accessing ref fields on rows from the same result set.
>
> I'm missing something, how do those Virtual Fields achieve that?
>

 Yes, that's exactly what the virtual field does -- when the the Rows
 object is created from the initial select, the value of the virtual field
 is calculated for each Row, and it remains in the Row (i.e., it is not
 re-calculated on each access). There is also Field.Method(), which does
 re-calculate on every access (the advantage is that it is lazy, so nothing
 is calculated until accessed -- and because of that, it can take arguments
 at the time it is called).

  And about the join, wouldn't that mean it won't work on GAE?
>

 Oh, yeah, forgot you said you are on GAE.

 Anthony

 --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit https://groups.google.com/d/**
 topic/web2py/IrAe-AGpiMU/**unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 web2py+un...@googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .

>>>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/IrAe-AGpiMU/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


Re: [web2py] Re: Accessing attributes of reference fields

2013-08-15 Thread Anthony
Oops, of course, the select is done within setdefault. Your if statement 
version is the way to go.

Anthony

On Thursday, August 15, 2013 3:21:43 PM UTC-4, Quint wrote:
>
> Thanks!
>
> Got it woking now but i got strange results:
>
> ("Not working" means that the same referenced record is being fetched 
> every time and not read from the dict)
>
> This is not working:
>
> Field.Virtual('created_by_record',
> lambda r: users.setdefault(r.comment.created_by.id, db
> .auth_user(r.comment.created_by))),
>
> This is also not working:
>
> users = {}
> def created_by_record(r):
> k = r.comment.created_by.id
> return users.setdefault(k, db.auth_user(k))
>
>
> Field.Virtual('created_by_record', created_by_record),
>
> But this is working:
>
> users = {}
> def created_by_record(r):
> k = r.comment.created_by.id
> if k in users:
> return users[k]
> users[k] = db.auth_user(k)
> return users[k]
>
>
> Field.Virtual('created_by_record', created_by_record),
>
>
>
>
>
>
> On Thursday, August 15, 2013 6:37:18 PM UTC+2, Anthony wrote:
>>
>> Good point. I suppose you can adapt your method to work with a virtual 
>> field:
>>
>> owners = {}
>> db.define_table('dog',
>> ...
>> Field.Virtual('owner_record',
>> lambda r: owners.setdefault(r.dog.owner, db.person(r.dog.owner)))
>>
>> That will store each fetched owner record in the owners dict, so the 
>> record will be copied from the dict if it is already there rather than 
>> pulled from the db.
>>
>> Anthony
>>
>> On Thursday, August 15, 2013 12:09:02 PM UTC-4, Quint wrote:
>>>
>>> But when when a row is calculating it's virtual field, it will fetch the 
>>> referenced row even when some other row from the initial set has already 
>>> fetched this same referenced row (when they are referencing the same 
>>> thing). So they will both perform the same fetch.
>>>
>>> ?
>>>
>>> I want to do this fetch 1x and use that record for all rows from the 
>>> initial set that reference it.
>>> On Aug 15, 2013 4:18 PM, "Anthony"  wrote:
>>>
 On Thursday, August 15, 2013 10:04:45 AM UTC-4, Quint wrote:

> thnx, 
>  
> but my goal is to prevent repeated queries for the same record when 
> accessing ref fields on rows from the same result set.
>  
> I'm missing something, how do those Virtual Fields achieve that?
>

 Yes, that's exactly what the virtual field does -- when the the Rows 
 object is created from the initial select, the value of the virtual field 
 is calculated for each Row, and it remains in the Row (i.e., it is not 
 re-calculated on each access). There is also Field.Method(), which does 
 re-calculate on every access (the advantage is that it is lazy, so nothing 
 is calculated until accessed -- and because of that, it can take arguments 
 at the time it is called).

  And about the join, wouldn't that mean it won't work on GAE?
>

 Oh, yeah, forgot you said you are on GAE.

 Anthony

 -- 
  
 --- 
 You received this message because you are subscribed to a topic in the 
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/IrAe-AGpiMU/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@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] Re: web2py menus don't like iPhone!

2013-08-15 Thread Paolo Caruccio
In this days I'm building an experimental version of welcome app based on 
jQuery 2.0.3 and bootstrap 3 (now rc2). With safari on iPhone4 but also 
with chrome on galaxy s3 mini, the dropdown in navbar wasn't tapable. I 
solved partially by using this snippet

jQuery('.dropdown-toggle').click(function(e) {
e.preventDefault();
setTimeout(jQuery.proxy(function() {
if ('ontouchstart' in document.documentElement) {
$(this).siblings('.dropdown-backdrop').off().remove
();
}
}, this), 0);
});


found in 
 
https://github.com/twbs/bootstrap/issues/4550#issuecomment-21361314
 

Why partially? because if I change the orientation the menu is not 
scrollable but maybe the issue is related to something other.

 

Il giorno giovedì 15 agosto 2013 20:04:15 UTC+2, Joe Barnhart ha scritto:
>
> Well, it's not web2py's fault.  But Bootstrap recently did something that 
> causes their menus to fail on iPhone, and I have verified this behavior. 
>  Basically you can't select any menu choices, leaving you unable to log in. 
>  I don't know if there's a real fix yet... We tried the suggested fix on 
> the Bootstrap forum without success but we're still working on it...
>
> Thought everyone should know...
>
> -- Joe
>
> P.S.  Please, no Android jokes!
>

-- 

--- 
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] IS_IN_DB zero= solution

2013-08-15 Thread Niphlod
I agree. The purpose of the "zero" option is to prefill a select with an 
helper and return an error if that option is the one selected (meaning that 
the user didn't choose anything). This has been requested because if there 
is no sane default to provide, having a dropdown with nothing in it tells 
nothing to the user. 
On the other end, a multiple select is a totally different "beast", because 
choices are shown to the user having a multiple select with a field 
that stands for "please do something" in it is a poor design decision. 
Use comments on the fields if you need to give directions to your users, 
that's the reason web2py has them.

On Thursday, August 15, 2013 9:31:39 PM UTC+2, Richard wrote:
>
> You use multiple... So I guess as Niphold says you can't use zero...
>
> Maybe consider create some kind of popover or use comment that is there 
> for that purpose so beside you field the user will be tell to select 4 
> functions...
>
> Richard
>
>

-- 

--- 
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] Advice on Architecture/Design

2013-08-15 Thread Carlos Zenteno
Hi all,

Very new to web2py and I like it so far...

I am going to develop an app where a 'team' representative will sign up for 
an account
and this will create a team environment where the team players list can be 
entered.
Each account will have 5 groups on it and the players will be 
moved/assigned to one
or more groups.

So far I think that each team will have an account of the type: 
my_team.domain.com.

I think this can be achieved with multi-tenants.  Please tell me if I am in 
the right track or
if there is a better way to do this.

Some questions:

- what is the best way to approach this? 
  do I develop the application as if it was going to be for a single 
account and then transform it to multi-tenants? 
  or do I develop it for multi-tenants from the beginning?

- I want to use postgresql.  Do I start with sqlite and then migrate to 
postgresql 
  or is it better to start with postgresql from the beginning?

- Is there a place where I can read what are the best practices on 
developing with
web2py or what are the best ways to do it?

Thanks in advance for your advice 

-- 

--- 
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: A few website projects built in Web2py

2013-08-15 Thread samuel bonill
hey man !! 

the github links are broken !!

El lunes, 12 de agosto de 2013 19:12:14 UTC-5, leaping...@gmail.com 
escribió:
>
> I built these sites a while ago and figured I would release them. They 
> weren't for clients, more personal projects. 
>
> https://github.com/techshinobi/free-business-pages
> https://github.com/techshinobi/echovids
>
> The echovids project is a bit older but free-business-pages is a newer 
> one. Can't give to much of an online example of either of these. But here 
> is www.free-business-pages.com
>
> Thanks for your time
>
> Maybe some one can find some use for them. free-business-pages uses paypal 
> and has a paypal subscription service, thanks to Bruna Rocha for a video 
> tutorial of his which I came across on using Paypal/Web2py :D Echovids you 
> can schedule a time for a TV show to play between. You can specify the time 
> zone in the code.
>
> Anyway *cheers
>
>

-- 

--- 
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: A few website projects built in Web2py

2013-08-15 Thread Luca
I suspect the author forgot to change the permissions to public. -Luca

On Thursday, August 15, 2013 4:56:52 PM UTC-7, samuel bonill wrote:
>
> hey man !! 
>
> the github links are broken !!
>
> El lunes, 12 de agosto de 2013 19:12:14 UTC-5, leaping...@gmail.comescribió:
>>
>> I built these sites a while ago and figured I would release them. They 
>> weren't for clients, more personal projects. 
>>
>> https://github.com/techshinobi/free-business-pages
>> https://github.com/techshinobi/echovids
>>
>> The echovids project is a bit older but free-business-pages is a newer 
>> one. Can't give to much of an online example of either of these. But here 
>> is www.free-business-pages.com
>>
>> Thanks for your time
>>
>> Maybe some one can find some use for them. free-business-pages uses 
>> paypal and has a paypal subscription service, thanks to Bruna Rocha for a 
>> video tutorial of his which I came across on using Paypal/Web2py :D 
>> Echovids you can schedule a time for a TV show to play between. You can 
>> specify the time zone in the code.
>>
>> Anyway *cheers
>>
>>

-- 

--- 
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: jquery .hide() interfering with validators

2013-08-15 Thread Jordan Ladora
A I see - it works perfectly now - thanks very much for your help!!

-j

-- 

--- 
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] web2py on Google Drive

2013-08-15 Thread Vineet
On Wednesday, 14 August 2013 02:28:04 UTC+5:30, Luca wrote:
>
> If you use sqlite, it should work, since the db is kept in a local file. 
> Luca
>

There is a mysql-noinstall version available. It can reside in a local 
folder.
-- Vineet 

-- 

--- 
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: Advice on Architecture/Design

2013-08-15 Thread Alex Glaros
develop for multi-tenant from the beginning or else you will waste time 
re-entering corrected designed data

is a "group" equivalent to a "team"?

will team membership stay permanent for each season?



On Thursday, August 15, 2013 2:40:28 PM UTC-7, Carlos Zenteno wrote:
>
> Hi all,
>
> Very new to web2py and I like it so far...
>
> I am going to develop an app where a 'team' representative will sign up 
> for an account
> and this will create a team environment where the team players list can be 
> entered.
> Each account will have 5 groups on it and the players will be 
> moved/assigned to one
> or more groups.
>
> So far I think that each team will have an account of the type: 
> my_team.domain.com.
>
> I think this can be achieved with multi-tenants.  Please tell me if I am 
> in the right track or
> if there is a better way to do this.
>
> Some questions:
>
> - what is the best way to approach this? 
>   do I develop the application as if it was going to be for a single 
> account and then transform it to multi-tenants? 
>   or do I develop it for multi-tenants from the beginning?
>
> - I want to use postgresql.  Do I start with sqlite and then migrate to 
> postgresql 
>   or is it better to start with postgresql from the beginning?
>
> - Is there a place where I can read what are the best practices on 
> developing with
> web2py or what are the best ways to do it?
>
> Thanks in advance for your advice 
>

-- 

--- 
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] IS_IN_DB zero= solution

2013-08-15 Thread Annet


> On the other end, a multiple select is a totally different "beast", 
> because choices are shown to the user having a multiple select with a 
> field that stands for "please do something" in it is a poor design 
> decision. 
>

Probably.

In my table definitions I do use comments to give directives, however, this 
is a custom form on a landing page, and I think labels and comments in this 
case make the form look ugly, so I use placeholders to replace the labels 
and comments. For a select this doesn't work:

form.element('select[name=navID]').update(_placeholder='Select 4 functions')

Therefore, I was looking for a way to achieve the same using the zero 
option. This doesn't work:

form.element('select[name=navID]').append(0,"Select 4 functions")

TypeError: append() takes exactly 2 arguments (3 given)


But the solution Richard first provided (which for whatever reason,  I did 
not give a try first, sorry)
does work.

Why doesn't append work and why does insert?


Kind regards,

Annet


-- 

--- 
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 build windows binary?

2013-08-15 Thread step
For starters, this thread pretty much answers my question, 
https://groups.google.com/forum/?fromgroups#!searchin/web2py/build$20web2py.exe/web2py/Lirvj_J8q1U/vC1kWqXoDSMJ
 


However, I wonder what is the official method to build web2py.exe, and also 
if other people have devised or derived their own build methods, and can 
share them.

TIA

-- 

--- 
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: how to build windows binary?

2013-08-15 Thread Niphlod

You download py2exe, go to the web2py source folder, issue python 
setup_exe.py py2exe and wait.

With python 2.5, there are no "subtle" issues with the archive that results.
However, with python >= 2.6, you should ship MSVCR90.dll with it to make it 
work (that's true for every python binary you'll ever build): make sure 
that you have rights to redistribute it if you're planning to make your own 
binary.

-- 

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