[web2py] which version of bootstrap is web2py running?

2014-05-28 Thread weheh
title says it all

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


[web2py] Re: Pypy and psycopg2-cffi?

2014-05-28 Thread Joe Barnhart
I only meant that a JIT might not benefit web2py as much because we are 
constantly loading and running bytecodes from the disk.  All of these JITs 
rely on loading code into memory and running it multiple times before the 
JIT optimizes it and provides enhanced performance.  Loading bytecodes from 
disk each time probably prevents a JIT from ever optimizing the code, and 
thus prevents it from providing any benefit.

Any code loaded from gluon or from modules, however, CAN benefit from the 
JIT, so there is a lot of ways pypy may help web2py.

The psycopg2-cffi supposedly runs faster on pypy than the normal psycopg2 
on cpython in all cases except one -- "fetchall" was still faster on 
psycopg2+cpython.  It was not a big difference in speed, however, and lots 
of benchmarks were improved with pypy.

-- Joe


On Wednesday, May 28, 2014 1:03:50 PM UTC-7, Niphlod wrote:
>
> web2py is constantly tested with pypy as an environment, and I really 
> don't see why web2py's implementation should be considered "not pypy 
> friendly".
> That being said, the improvements on psycopg2-cffi vs psycopg2 are 
> ISOLATED in that specific "corner". If, for example, psycopg2-ccfi turns to 
> be 50% faster than psycopg2, that "splice" of performances will be noticed 
> in regards of the driver itself and there's nothing that web2py can do (bad 
> or good) to "alter" that 50%.
> web2py needs to rely on the drivers to interact with the db, not the other 
> way around.
>
> On Wednesday, May 28, 2014 7:50:09 PM UTC+2, Joe Barnhart wrote:
>>
>> I see there is a fairly new-ish implementation of psycopg2 which conforms 
>> to the cffi calling convention, for use with pypy.  Has anyone tried this 
>> along with a fresh web2py to see if improvements have been made?
>>
>> I've always assumed pypy would not do much for web2py because of our 
>> preference for "exec" instead of compiled code.  But I noticed that my 
>> web2py projects recently have been putting most of the heavy-hitting stuff 
>> in modules, which would definitely be pypy-friendly.
>>
>> So I'm curious if anyone has dabbled with pypy and web2py (and Postgres) 
>> recently...
>>
>> -- Joe
>>
>>

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


[web2py] Re: I posted one question to web2py-user group not able to find it

2014-05-28 Thread Dave S


On Tuesday, May 27, 2014 6:54:14 AM UTC-7, sarfaraz ahmed wrote:
>
> The question was regarding using jqueryui in web2py.
>




Sometimes different GG server instances take longer to update, but your 
post is there.  It doesn't seem to be a victim of spontaneous deletion.

(GG also sometimes keeps showing me that some threads are unread after I've 
read them.)

/dps

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


[web2py] Re: requires IS_IN_DB set as a union of two queries

2014-05-28 Thread 98ujko9
I did try:
query =  query1 | guery2
and received error: "Set | Set" or similar

On Wednesday, May 28, 2014 7:47:36 PM UTC-4, 98u...@gmail.com wrote:
>
> Thank you Mr. Massimo and your colleagues for bringing the web2py to the 
> masses. 
> I need to have a field that will present a choice of values that result 
> from a union of query1 and query2
> How can i create a set that would go where the question mark is? Thanks 
> for any help!
>
> query1=((db.vehicle.id
> ==db.owner.own_veh_fk)&(db.owner.own_end_date!=None))
>
> query2=(~db.vehicle.id.belongs(db(db.owner.own_veh_fk==db.vehicle.id
> )._select(db.vehicle.id)))
>
> db.owner.own_veh_fk.requires=IS_IN_DB((db(?)),'vehicle.id', 
> '%(manufacturer)s %(vin)s')
>
>

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


Re: [web2py] requires IS_IN_DB set as a union of two queries

2014-05-28 Thread Carlos Costa
Have you tried something like:

query1=((db.vehicle.id==db.owner.own_veh_fk)&(db.owner.own_end_date!=None))

query2=(~db.vehicle.id.belongs(db(db.owner.own_veh_fk==db.vehicle.id
)._select(db.vehicle.id)))

query = query1 & query2

db.owner.own_veh_fk.requires=IS_IN_DB(query,'vehicle.id', '%(manufacturer)s
%(vin)s')





2014-05-28 20:47 GMT-03:00 <98uj...@gmail.com>:

> Thank you Mr. Massimo and your colleagues for bringing the web2py to the
> masses.
> I need to have a field that will present a choice of values that result
> from a union of query1 and query2
> How can i create a set that would go where the question mark is? Thanks
> for any help!
>
> query1=((db.vehicle.id
> ==db.owner.own_veh_fk)&(db.owner.own_end_date!=None))
>
> query2=(~db.vehicle.id.belongs(db(db.owner.own_veh_fk==db.vehicle.id
> )._select(db.vehicle.id)))
>
> db.owner.own_veh_fk.requires=IS_IN_DB((db(?)),'vehicle.id',
> '%(manufacturer)s %(vin)s')
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Att.

Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן

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


[web2py] requires IS_IN_DB set as a union of two queries

2014-05-28 Thread 98ujko9
Thank you Mr. Massimo and your colleagues for bringing the web2py to the 
masses. 
I need to have a field that will present a choice of values that result 
from a union of query1 and query2
How can i create a set that would go where the question mark is? Thanks for 
any help!

query1=((db.vehicle.id==db.owner.own_veh_fk)&(db.owner.own_end_date!=None))

query2=(~db.vehicle.id.belongs(db(db.owner.own_veh_fk==db.vehicle.id)._select(db.vehicle.id)))

db.owner.own_veh_fk.requires=IS_IN_DB((db(?)),'vehicle.id', 
'%(manufacturer)s %(vin)s')

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Anthony
Note, the Rows class already has .first, .last, .find, .sort, and .exclude 
methods -- we've just added one more such method. Hopefully most folks will 
recognize that because .select() returns a Rows object, any subsequent 
method calls must be operating on the Rows object. Those who don't may also 
have trouble figuring out the more explicit list comprehension/generator 
expression code (which prompted this thread to begin with). To make things 
more clear, you can do:

rows = db().select(db.mytable.myfield)
values = rows.column()

Anthony

On Wednesday, May 28, 2014 5:23:09 PM UTC-4, Leonel Câmara wrote:
>
> I don't like this new method. People can (due to being used to the method 
> chaining/cascading patterns which are used quite commonly in DALs) think 
> that the DAL will only request the given column from the DB when that's not 
> what's happening.
>
> I've done this many times using list comprehensions and generator 
> expressions which are readable to everyone who knows python and doesn't 
> lead to mistakes.
>

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Leonel Câmara
I don't like this new method. People can (due to being used to the method 
chaining/cascading patterns which are used quite commonly in DALs) think 
that the DAL will only request the given column from the DB when that's not 
what's happening.

I've done this many times using list comprehensions and generator 
expressions which are readable to everyone who knows python and doesn't 
lead to mistakes.

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Niphlod
yep, I always forget to do a quick summary on my "warnings".

Addition to my latest post

/**/
following the rule of "explicit is better than implicit" the last method 
shown is the best
/**/

^_^

On Wednesday, May 28, 2014 10:45:28 PM UTC+2, Anthony wrote:
>
> On Wednesday, May 28, 2014 4:26:28 PM UTC-4, Niphlod wrote:
>>
>> I'd also argue that it's a nice shortcut but you should ALWAYS select 
>> only what's needed. A select fetching 20 columns just to display the data 
>> from one column only will ALWAYS perform worse than a select fetching that 
>> only column.
>>
>
> Yes, though the new method is useful even (and especially) if you only 
> select a single column, as it allows you to easily extract a list:
>
> mylist = db().select(db.mytable.myfield).column()
>
> Anthony
>

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Anthony
On Wednesday, May 28, 2014 4:26:28 PM UTC-4, Niphlod wrote:
>
> I'd also argue that it's a nice shortcut but you should ALWAYS select only 
> what's needed. A select fetching 20 columns just to display the data from 
> one column only will ALWAYS perform worse than a select fetching that only 
> column.
>

Yes, though the new method is useful even (and especially) if you only 
select a single column, as it allows you to easily extract a list:

mylist = db().select(db.mytable.myfield).column()

Anthony

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


[web2py] Re: getting run_result from web2py scheduler

2014-05-28 Thread Niphlod
the same "mind error" applies.
you should queue the task in one function, and retrieve the result in 
another (polling is the easiest way, looping is the worst idea). 

On Wednesday, May 28, 2014 10:36:18 PM UTC+2, Cory wrote:
>
> Thanks Niphlod and good point. I am using it with LOAD() so im still 
> maintaining async, I just need to know when its ready. This helped a lot, I 
> did not try db.commit before and did not realize. Thanks again! 
>
> On Wednesday, May 28, 2014 1:23:16 PM UTC-7, Niphlod wrote:
>>
>> Hi.
>> There must be something wrong with what you expect.
>> The scheduler is an ASYNC process, meaning that - usually - trying to 
>> fetch the result in the same request that queued it is a wrong idea in so 
>> many ways that should be obvious.
>> That being said, this works without any issues.
>>
>> models/scheduler.py
>> def add(a,b):
>> return a + b
>>
>> from gluon.scheduler import Scheduler
>> mysched = Scheduler(db)
>>
>> controllers/default.py
>>
>> def index():
>> thetask = mysched.queue_task('add', pargs=[3,4])
>> db.commit() #otherwise the scheduler process can't see it
>> result = None
>> task_id = None
>> while 1:
>> intermediate = mysched.task_status(thetask.uuid, output=True)
>> if intermediate.result:
>> result = intermediate.result
>> task_id = thetask.uuid
>> break
>> time.sleep(1)
>> return dict(res=result, task_id=task_id)
>>
>> On Wednesday, May 28, 2014 5:55:20 PM UTC+2, Cory wrote:
>>>
>>> Hi,
>>> I am having trouble getting the run_result after  web2py has finished a 
>>> task using web2py's scheduler. 
>>> The code below is what I am using. The trouble I am having is grabbing 
>>> the result once the result is 
>>> ready. Do any of you know how to get the run_result from a task once the 
>>> task has finished? right now
>>> when I try to get the run_result I get a "None" value because I try to 
>>> get the result before it is ready.
>>> The task can take a couple of seconds to finish. I have tried many 
>>> different ways to get the result once
>>> it is ready. For instance, creating a while loop that checks to see if 
>>> the task status has changed to 
>>> "completed" then grab the result, but that does not work. Any ideas? I 
>>> have been stuck on this far too long.
>>>
>>> task2 = sched.queue_task('upsQuote', pargs = [session.Weight, 
>>> session.OrigZip, session.DestZip], timeout = 5, start_time = request.now)   
>>>  #add the task 
>>> task_status2  = sched.task_status(task2.uuid, output=True)# 
>>> get the task status 
>>> result2 = task_status2.scheduler_run.run_result 
>>>  # get the result from the finished task 
>>>
>>>
>>>

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


[web2py] Re: getting run_result from web2py scheduler

2014-05-28 Thread Cory
Thanks Niphlod and good point. I am using it with LOAD() so im still 
maintaining async, I just need to know when its ready. This helped a lot, I 
did not try db.commit before and did not realize. Thanks again! 

On Wednesday, May 28, 2014 1:23:16 PM UTC-7, Niphlod wrote:
>
> Hi.
> There must be something wrong with what you expect.
> The scheduler is an ASYNC process, meaning that - usually - trying to 
> fetch the result in the same request that queued it is a wrong idea in so 
> many ways that should be obvious.
> That being said, this works without any issues.
>
> models/scheduler.py
> def add(a,b):
> return a + b
>
> from gluon.scheduler import Scheduler
> mysched = Scheduler(db)
>
> controllers/default.py
>
> def index():
> thetask = mysched.queue_task('add', pargs=[3,4])
> db.commit() #otherwise the scheduler process can't see it
> result = None
> task_id = None
> while 1:
> intermediate = mysched.task_status(thetask.uuid, output=True)
> if intermediate.result:
> result = intermediate.result
> task_id = thetask.uuid
> break
> time.sleep(1)
> return dict(res=result, task_id=task_id)
>
> On Wednesday, May 28, 2014 5:55:20 PM UTC+2, Cory wrote:
>>
>> Hi,
>> I am having trouble getting the run_result after  web2py has finished a 
>> task using web2py's scheduler. 
>> The code below is what I am using. The trouble I am having is grabbing 
>> the result once the result is 
>> ready. Do any of you know how to get the run_result from a task once the 
>> task has finished? right now
>> when I try to get the run_result I get a "None" value because I try to 
>> get the result before it is ready.
>> The task can take a couple of seconds to finish. I have tried many 
>> different ways to get the result once
>> it is ready. For instance, creating a while loop that checks to see if 
>> the task status has changed to 
>> "completed" then grab the result, but that does not work. Any ideas? I 
>> have been stuck on this far too long.
>>
>> task2 = sched.queue_task('upsQuote', pargs = [session.Weight, 
>> session.OrigZip, session.DestZip], timeout = 5, start_time = request.now)   
>>  #add the task 
>> task_status2  = sched.task_status(task2.uuid, output=True)# 
>> get the task status 
>> result2 = task_status2.scheduler_run.run_result   
>># get the result from the finished task 
>>
>>
>>

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Niphlod
I'd also argue that it's a nice shortcut but you should ALWAYS select only 
what's needed. A select fetching 20 columns just to display the data from 
one column only will ALWAYS perform worse than a select fetching that only 
column.

On Wednesday, May 28, 2014 1:35:03 PM UTC+2, Anthony wrote:
>
> Note, in trunk there is now a new .column method for the Rows object, 
> which allows you to extract a single column as a list of values 
> (internally, it just does a list comprehension, as in my original answer). 
> So, in this case you could do:
>
> nums3 = db(db.Measures).select(orderby=db.Measures.measure_date_time).
> column('measure_value')
>
> You can also pass a field object to .column:
>
> nums3 = db(db.Measures).select(orderby=db.Measures.measure_date_time).
> column(db.Measures.measure_value)
>
> Also, if you don't pass any argument to .column, it will return the first 
> column, which is convenient if your database select returns only a single 
> column:
>
> nums3 = db().select(db.Measures.measure_value, orderby=db.Measures.
> measure_date_time).column()
>
> Anthony
>
> On Monday, May 26, 2014 1:21:15 PM UTC-4, Anthony wrote:
>>
>> You can do:
>>
>> nums3 = [r.measure_value for r in db().select(db.Measures.measure_value)]
>>
>> The .select() returns a Rows object, which acts like a list of Row 
>> objects -- if you want to extract just a single value from each Row object, 
>> you have to iterate through the Rows object and pull each value out.
>>
>> Note, depending on what you are doing, you can instead operate on the 
>> Rows object itself (rather than generating a list and then operating on the 
>> list). For example, to randomize the order:
>>
>> import random
>> random_rows = db(db.Measures).select().sort(lambda r: random.random())
>>
>> Anthony
>>
>> On Monday, May 26, 2014 6:20:07 AM UTC-4, Syd Stewart wrote:
>>>
>>> Hi
>>>
>>> What is the simplest way please to select a column of figures (floats 
>>> and int) into a list, so I can manipulate the list e.g randomise the order 
>>>
>>>  nums3 = db(db.Measures).select( db.Measures.measure_value, 
>>> orderby=db.Measures.measure_date_time)
>>>
>>>  meannums= sum(nums3)/float(len(nums3))
>>>
>>> This calculation of the mean keeps giving me an error
>>>
>>>   File "/home/sydstewart/web2py/applications/SydOwn/controllers/test.py" 
>>> ,
>>>  line 92, in cusum
>>> qnum[i][k] = (nums3[k]) - (meannums)
>>> TypeError: unsupported operand type(s) for -: 'Row' and 'int'
>>>
>>>
>>> Thanks
>>>
>>>
>>>

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


[web2py] Re: getting run_result from web2py scheduler

2014-05-28 Thread Niphlod
Hi.
There must be something wrong with what you expect.
The scheduler is an ASYNC process, meaning that - usually - trying to fetch 
the result in the same request that queued it is a wrong idea in so many 
ways that should be obvious.
That being said, this works without any issues.

models/scheduler.py
def add(a,b):
return a + b

from gluon.scheduler import Scheduler
mysched = Scheduler(db)

controllers/default.py

def index():
thetask = mysched.queue_task('add', pargs=[3,4])
db.commit() #otherwise the scheduler process can't see it
result = None
task_id = None
while 1:
intermediate = mysched.task_status(thetask.uuid, output=True)
if intermediate.result:
result = intermediate.result
task_id = thetask.uuid
break
time.sleep(1)
return dict(res=result, task_id=task_id)

On Wednesday, May 28, 2014 5:55:20 PM UTC+2, Cory wrote:
>
> Hi,
> I am having trouble getting the run_result after  web2py has finished a 
> task using web2py's scheduler. 
> The code below is what I am using. The trouble I am having is grabbing the 
> result once the result is 
> ready. Do any of you know how to get the run_result from a task once the 
> task has finished? right now
> when I try to get the run_result I get a "None" value because I try to get 
> the result before it is ready.
> The task can take a couple of seconds to finish. I have tried many 
> different ways to get the result once
> it is ready. For instance, creating a while loop that checks to see if the 
> task status has changed to 
> "completed" then grab the result, but that does not work. Any ideas? I 
> have been stuck on this far too long.
>
> task2 = sched.queue_task('upsQuote', pargs = [session.Weight, 
> session.OrigZip, session.DestZip], timeout = 5, start_time = request.now)   
>  #add the task 
> task_status2  = sched.task_status(task2.uuid, output=True)# 
> get the task status 
> result2 = task_status2.scheduler_run.run_result   
># get the result from the finished task 
>
>
>

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


[web2py] Re: Pypy and psycopg2-cffi?

2014-05-28 Thread Niphlod
web2py is constantly tested with pypy as an environment, and I really don't 
see why web2py's implementation should be considered "not pypy friendly".
That being said, the improvements on psycopg2-cffi vs psycopg2 are ISOLATED 
in that specific "corner". If, for example, psycopg2-ccfi turns to be 50% 
faster than psycopg2, that "splice" of performances will be noticed in 
regards of the driver itself and there's nothing that web2py can do to 
"alter" that 50%.

On Wednesday, May 28, 2014 7:50:09 PM UTC+2, Joe Barnhart wrote:
>
> I see there is a fairly new-ish implementation of psycopg2 which conforms 
> to the cffi calling convention, for use with pypy.  Has anyone tried this 
> along with a fresh web2py to see if improvements have been made?
>
> I've always assumed pypy would not do much for web2py because of our 
> preference for "exec" instead of compiled code.  But I noticed that my 
> web2py projects recently have been putting most of the heavy-hitting stuff 
> in modules, which would definitely be pypy-friendly.
>
> So I'm curious if anyone has dabbled with pypy and web2py (and Postgres) 
> recently...
>
> -- Joe
>
>

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


[web2py] Pypy and psycopg2-cffi?

2014-05-28 Thread Joe Barnhart
I see there is a fairly new-ish implementation of psycopg2 which conforms 
to the cffi calling convention, for use with pypy.  Has anyone tried this 
along with a fresh web2py to see if improvements have been made?

I've always assumed pypy would not do much for web2py because of our 
preference for "exec" instead of compiled code.  But I noticed that my 
web2py projects recently have been putting most of the heavy-hitting stuff 
in modules, which would definitely be pypy-friendly.

So I'm curious if anyone has dabbled with pypy and web2py (and Postgres) 
recently...

-- Joe

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


[web2py] What MongoDB operators are available in current DAL, and how to use pymongo with DAL in web2py

2014-05-28 Thread Andrey K
Dear web2py experts,
I would like to use MongoDB+w2p for my current task which might make my 
life a lot easier.
The only examples I have found are:
http://www.web2pyslices.com/slice/show/1580/save-the-earth-from-a-total-data-mess-with-mongodbadapter
http://stackoverflow.com/questions/21674013/can-mongodbs-embedded-documents-be-modeled-in-web2py-dal

It would be much nicer to use pymongo capabilities though. I wonder how to 
use pymongo and DAL together? Can I use following pymango query operators 
directly from DAL, and if so what is the syntax:
Query Operators: find, sort, find_one
Update Operator: set, unset, push, pop and etc?

it was implemented in Flask already (
http://flask-pymongo.readthedocs.org/en/latest/), I guess it should be 
available in w2p
If not what would be the way to deal with MongoDB using DAL and pymongo 
together?

For example, how to query nested json (see below) in mongoDB document using 
mango operator\function rather than simple loop? 
name: "Joe Bookreader",
addresses: [
{
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
},

{
street: "1 Some Other Street",
city: "Boston",
state: "MA",
zip: "12345"
}
]

What would be the way to embed and remove document in\from the existing 
mangoDB document using DAL?
Is there any links with more examples on how to marriage pymongo with DAL 
or web2py?
Also it would be nice to see comparison between DAL and other python 
alternatives like MongoEngine.

Thank a lot in advance.

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


Re: [web2py] Re: module has no attribute...

2014-05-28 Thread Anthony
See 
http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules.
 
Note, it adds some overhead, so not necessarily recommended for production.

Anthony

On Wednesday, May 28, 2014 11:40:00 AM UTC-4, BlueShadow wrote:
>
> Oo i didn't know. Tell me more about the track changes.
> Am 28.05.2014 17:04 schrieb "Anthony" :
>
>> Did you restart the server? Changes to modules have no effect after the 
>> first request in which they are imported, unless you restart or use the 
>> track_changes functionality.
>>
>> Anthony
>>
>> On Wednesday, May 28, 2014 10:53:49 AM UTC-4, BlueShadow wrote:
>>>
>>> I just added a function to my module sitemap called stats which basicly 
>>> counts the sites which are in my sitemap. My problem is the function I just 
>>> created (stats(db)) can't be called I always get a ticket:
>>> ...
>>>
>>>   sitemapstat=sitemap.stats(db)
>>> AttributeError: 'module' object has no attribute 'stats'
>>> ...
>>>
>>>  import sitemap
>>> sitemapstat=sitemap.stats(db)
>>>
>>>
>>> but I can see this d... function the module is saved and everything 
>>> seems to be OK.
>>> any ideas?
>>>
>>  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/g4DJhNYR_-Q/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/d/optout.
>>
>

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


[web2py] getting run_result from web2py scheduler

2014-05-28 Thread Cory
Hi,
I am having trouble getting the run_result after  web2py has finished a 
task using web2py's scheduler. 
The code below is what I am using. The trouble I am having is grabbing the 
result once the result is 
ready. Do any of you know how to get the run_result from a task once the 
task has finished? right now
when I try to get the run_result I get a "None" value because I try to get 
the result before it is ready.
The task can take a couple of seconds to finish. I have tried many 
different ways to get the result once
it is ready. For instance, creating a while loop that checks to see if the 
task status has changed to 
"completed" then grab the result, but that does not work. Any ideas? I have 
been stuck on this far too long.

task2 = sched.queue_task('upsQuote', pargs = [session.Weight, 
session.OrigZip, session.DestZip], timeout = 5, start_time = request.now)   
 #add the task 
task_status2  = sched.task_status(task2.uuid, output=True)# get 
the task status 
result2 = task_status2.scheduler_run.run_result 
 # get the result from the finished task 


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


Re: [web2py] Re: module has no attribute...

2014-05-28 Thread Kevin Bethke
Oo i didn't know. Tell me more about the track changes.
Am 28.05.2014 17:04 schrieb "Anthony" :

> Did you restart the server? Changes to modules have no effect after the
> first request in which they are imported, unless you restart or use the
> track_changes functionality.
>
> Anthony
>
> On Wednesday, May 28, 2014 10:53:49 AM UTC-4, BlueShadow wrote:
>>
>> I just added a function to my module sitemap called stats which basicly
>> counts the sites which are in my sitemap. My problem is the function I just
>> created (stats(db)) can't be called I always get a ticket:
>> ...
>>
>>   sitemapstat=sitemap.stats(db)
>> AttributeError: 'module' object has no attribute 'stats'
>> ...
>>
>>  import sitemap
>> sitemapstat=sitemap.stats(db)
>>
>>
>> but I can see this d... function the module is saved and everything seems
>> to be OK.
>> any ideas?
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/g4DJhNYR_-Q/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/d/optout.
>

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


Re: [web2py] Why won't my bootstrap modal form close?

2014-05-28 Thread Richard Vézina
I think the scope issue is coming from the dynamic caracteristic of your
modal that you add to the DOM with the web2py_component() function...

The second comment on the question here should work :
http://stackoverflow.com/questions/10280569/jquery-select-dynamically-created-html-element

But you should not remove the parent empty div that you need to add to the
component shell view, you need to remove the child that should be the
modal... Not sure if in this select scenario it gonna be better or not
though...

I you were have some way to use .on() some how it could solve the problem
if the problem come from the fact that your modal is a dynamic DOM
element...

You can try by adding a button that you can click like in the SO question
if you can hide/remove the modal this way or not.

You could also just redirect on the shell view and use valuekeep depending
of how you use your modal for subform... I guess your need is for adding a
missing value in a lookup table and autoselect it in the form you try to
complete if so, the blog post in one of my previous mail do exactly that
and it works I test it (the modal form at least work ok). But I am not sure
it autoselect the inserted value, but this is easy to do with a trigger
once component form has pass.

Hope it helps

Richard



On Wed, May 28, 2014 at 2:25 AM, weheh  wrote:

> Alright, I got it to work, but it's super fugly. I created a javascript
> function:
>
> function hide_modal() {
>
> $("#contact-dialog").modal("hide");
> }
>
>
> and then in my controller I replaced the response.js with this:
>
> response.js = 'hide_modal("#contact-dialog");'
>
> So that works. But WHY? I think there's something very fish with the
> scoping inside of the response.js. Can anyone explain what's going on here?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: sqlform.grid with linked tables

2014-05-28 Thread Mirek Zvolský
Use grid = smartgrid()
to display table with links to children tables




Dne úterý, 20. května 2014 23:50:23 UTC+2 Juan Luis napsal(a):
>
> thank you stifan, represent is what I needed to know and your example 
> worked perfect.
>
> My primary problem is that i am not able to see my other table in 
> SQLFORM.grid. Here I try to create two columns; one from db.contact and the 
> other from db.task. 
>
> Can my error be noticed?
>
>
>
> On Tuesday, May 20, 2014 3:06:28 PM UTC-5, 黄祥 wrote:
>>
>> please try (not tested) :
>>
>> Field('email', 'list:string', represent = lambda email, field: \
>> XML(", ".join([A(mail, _title=T("Send to %s") % mail, 
>> _target="_blank", 
>>  _href="mailto:%s"; % mail).xml() for mail in 
>> email] ) ) if email else ''), 
>> Field('website', represent = lambda website, field: \
>> A(website, _title = T("View Website"), _target = "_blank", 
>> _href = "%s" % website) if website else ''), 
>>
>> and please take a look the book at dal chapter:
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer
>>
>> best regards,
>> stifan
>>
>

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


[web2py] Re: DAL/Decorator for specific data

2014-05-28 Thread Anthony
You can include logic to set the readable and writable attributes of 
particular fields to True/False depending on Auth group membership. For 
example:

db.define_table('mytable', Field('myfield', readable=False, writable=False))

if auth.has_membership('admin'):
db.mytable.myfield.readable = db.mytable.myfield.writable = True

I suppose you could write a decorator that does that, but it's not clear 
there would be any benefit over the simple approach above.

Anthony

On Wednesday, May 28, 2014 11:00:13 AM UTC-4, Tom Russell wrote:
>
> I have read through the docs but have not come across what I am trying to 
> do, if its possible.
>
> I have a table with 40 columns of data, I want to use a decorator or 
> similar to only allow some of them viewable while others in a different 
> membership group can see all of the columns.
>
> Is this something that can be done?
>
> Thanks,
>
> Tom
>

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


[web2py] Re: module has no attribute...

2014-05-28 Thread Anthony
Did you restart the server? Changes to modules have no effect after the 
first request in which they are imported, unless you restart or use the 
track_changes functionality.

Anthony

On Wednesday, May 28, 2014 10:53:49 AM UTC-4, BlueShadow wrote:
>
> I just added a function to my module sitemap called stats which basicly 
> counts the sites which are in my sitemap. My problem is the function I just 
> created (stats(db)) can't be called I always get a ticket:
> ...
>
>   sitemapstat=sitemap.stats(db)
> AttributeError: 'module' object has no attribute 'stats'
> ...
>
>  import sitemap
> sitemapstat=sitemap.stats(db)
>
>
> but I can see this d... function the module is saved and everything seems 
> to be OK.
> any ideas?
>

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


[web2py] DAL/Decorator for specific data

2014-05-28 Thread Tom Russell
I have read through the docs but have not come across what I am trying to 
do, if its possible.

I have a table with 40 columns of data, I want to use a decorator or 
similar to only allow some of them viewable while others in a different 
membership group can see all of the columns.

Is this something that can be done?

Thanks,

Tom

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


[web2py] module has no attribute...

2014-05-28 Thread BlueShadow
I just added a function to my module sitemap called stats which basicly 
counts the sites which are in my sitemap. My problem is the function I just 
created (stats(db)) can't be called I always get a ticket:
...

  sitemapstat=sitemap.stats(db)
AttributeError: 'module' object has no attribute 'stats'
...

 import sitemap
sitemapstat=sitemap.stats(db)


but I can see this d... function the module is saved and everything seems 
to be OK.
any ideas?

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


Re: [web2py] DAL Referencing By Name Not By ID Possible?

2014-05-28 Thread Carlos Costa
You are welcome! :)


2014-05-28 11:08 GMT-03:00 'Michael Gheith' via web2py-users <
web2py@googlegroups.com>:

> Many thanks for this, I found it to be helpful :)
>
>
> On Wednesday, May 28, 2014 6:30:31 AM UTC-5, yamandu wrote:
>
>> Give a look here: http://web2py.com/books/default/chapter/29/06/the-
>> database-abstraction-layer#Legacy-databases-and-keyed-tables
>>
>> But I think it won't work in your case because name is a string.
>> Our you can model it another way.
>>
>> db.define_table('tiers',
>> Field('name', 'string'),
>> Field('created_on', 'datetime', default=request.now),
>> format = '%(name)s')
>>
>> db.define_table('metrics',
>> Field('tier_name', 'string', requires=IS_IN_DB(db, 'tiers.name
>> ',%(name)s')),
>> Field('total_count', 'integer'),
>> Field('total_size', 'bigint'),
>> Field('created_on', 'datetime', default=request.now))
>>
>> However, this will not enforce reference at db level, only in application.
>> But you can query an join it by name without problems.
>>
>> query = db(db.tiers.name == db.metrics.tier_name).select()
>> metric = db(db.metrics.tier_name == 'name').select()
>>
>> or you can obviously write a helper function to short it
>>
>> get_metrics = lambda name: db(db.metrics.tier_name == name).select()
>> get_tier = lambda name: db(db.tier.name == name).select().first()
>>
>> tier = get_tier(name)
>> tier_metrics = get_metrics(name)
>>
>>
>> 2014-05-27 21:35 GMT-03:00 'Michael Gheith' via web2py-users <
>> web...@googlegroups.com>:
>>
>>> I have two pretty basic tables:
>>>
>>> db.define_table('tiers',
>>> Field('name', 'string'),
>>> Field('created_on', 'datetime', default=request.now),
>>> format = '%(name)s')
>>>
>>> db.define_table('metrics',
>>> Field('tier_id', 'reference tiers'),
>>> Field('total_count', 'integer'),
>>> Field('total_size', 'bigint'),
>>> Field('created_on', 'datetime', default=request.now))
>>>
>>> I pre populated my tiers table with data.  When I store data in my
>>> metrics table, I don't know off hand the tier_id.  I know the tier name
>>> though.  Is there a way I can use the tier name instead of the tier_id in
>>> this reference?
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Att.
>>
>> Carlos J. Costa
>> Cientista da Computação
>> Esp. Gestão em Telecom
>>
>> EL MELECH NEEMAN!
>> אָמֵן
>>
>>   --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Att.

Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן

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


[web2py] Re: what is loader.js for?

2014-05-28 Thread Massimo Di Pierro
Perhaps you are talking about 
this? http://philogb.github.io/jit/static/v20/Docs/files/Loader/Loader-js.html
We have no clue.

On Monday, 26 May 2014 07:08:24 UTC-5, chuan137 wrote:
>
> looking at my simple example from chrome developer's tool, I noticed 
> loader.js doing something in the background.
> seems related with statistics or ads.
>
> can someone explain it to me? is it possible to disable it, because I want 
> to do some performance measurements?
>
> thanks :)
>

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


[web2py] Re: DAL Referencing By Name Not By ID Possible?

2014-05-28 Thread 'Michael Gheith' via web2py-users
Hello Anthony,

Indeed, inserting using the web2py grid or SQLFORM does have the drop-down 
with the tier name rather than the IDs.  I wanted to avoid the operation of 
looking up the tier_id because I thought there was a way to reference by 
name.  The lookup will do.  Thank you for your help!

On Wednesday, May 28, 2014 6:49:41 AM UTC-5, Anthony wrote:
>
> How are you inputting records into db.metrics? If via a web2py grid or 
> SQLFORM, the drop-down will have the tier names rather than the IDs (due to 
> the fact that you have specified format='%(name)s'). If you need to do 
> inserts programmatically outside of a form, you can just do a lookup in the 
> db.tiers table:
>
> tier_id = db.tiers(name='some name')
>
> Anthony
>
> On Tuesday, May 27, 2014 8:35:43 PM UTC-4, Michael Gheith wrote:
>>
>> I have two pretty basic tables:
>>
>> db.define_table('tiers',
>> Field('name', 'string'),
>> Field('created_on', 'datetime', default=request.now),
>> format = '%(name)s')
>>
>> db.define_table('metrics',
>> Field('tier_id', 'reference tiers'),
>> Field('total_count', 'integer'),
>> Field('total_size', 'bigint'),
>> Field('created_on', 'datetime', default=request.now))
>>
>> I pre populated my tiers table with data.  When I store data in my 
>> metrics table, I don't know off hand the tier_id.  I know the tier name 
>> though.  Is there a way I can use the tier name instead of the tier_id in 
>> this reference?
>>
>

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


[web2py] Re: DAL update expressions starting with an integer not working?

2014-05-28 Thread Massimo Di Pierro
What you trying to do, change the sign? Than do

db(db.table.lft > 0).update(lft = db.table.lft * (-1))


The first term of an expression has to be a field as operator overloading does 
not work.



On Wednesday, 28 May 2014 03:21:56 UTC-5, Marian wrote:
>
> I want to negate a value with this expression:
>
> db(db.table.lft > 0).update(lft = 0 - db.table.lft)
>
> but I get the following TypeError:
> TypeError: unsupported operand type(s) for -: 'int' and 'Field'
>
> My workaround is:
> db(db.table.lft > 0).update(lft = db.table.lft - db.table.lft - db.table.lft)
>
>
> *It seems that update expression need to start with the field or do I miss 
> something?*
>
>

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


Re: [web2py] DAL Referencing By Name Not By ID Possible?

2014-05-28 Thread 'Michael Gheith' via web2py-users
Many thanks for this, I found it to be helpful :)

On Wednesday, May 28, 2014 6:30:31 AM UTC-5, yamandu wrote:
>
> Give a look here: 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables
>
> But I think it won't work in your case because name is a string.
> Our you can model it another way.
>
> db.define_table('tiers',
> Field('name', 'string'),
> Field('created_on', 'datetime', default=request.now),
> format = '%(name)s')
>
> db.define_table('metrics',
> Field('tier_name', 'string', requires=IS_IN_DB(db, 'tiers.name
> ',%(name)s')),
> Field('total_count', 'integer'),
> Field('total_size', 'bigint'),
> Field('created_on', 'datetime', default=request.now))
>
> However, this will not enforce reference at db level, only in application.
> But you can query an join it by name without problems.
>
> query = db(db.tiers.name == db.metrics.tier_name).select()
> metric = db(db.metrics.tier_name == 'name').select()
>
> or you can obviously write a helper function to short it
>
> get_metrics = lambda name: db(db.metrics.tier_name == name).select()
> get_tier = lambda name: db(db.tier.name == name).select().first()
>
> tier = get_tier(name)
> tier_metrics = get_metrics(name)
>
>
> 2014-05-27 21:35 GMT-03:00 'Michael Gheith' via web2py-users <
> web...@googlegroups.com >:
>
>> I have two pretty basic tables:
>>
>> db.define_table('tiers',
>> Field('name', 'string'),
>> Field('created_on', 'datetime', default=request.now),
>> format = '%(name)s')
>>
>> db.define_table('metrics',
>> Field('tier_id', 'reference tiers'),
>> Field('total_count', 'integer'),
>> Field('total_size', 'bigint'),
>> Field('created_on', 'datetime', default=request.now))
>>
>> I pre populated my tiers table with data.  When I store data in my 
>> metrics table, I don't know off hand the tier_id.  I know the tier name 
>> though.  Is there a way I can use the tier name instead of the tier_id in 
>> this reference?
>>  
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Att.
>
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>
> 

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


[web2py] Re: DAL Referencing By Name Not By ID Possible?

2014-05-28 Thread Anthony
How are you inputting records into db.metrics? If via a web2py grid or 
SQLFORM, the drop-down will have the tier names rather than the IDs (due to 
the fact that you have specified format='%(name)s'). If you need to do 
inserts programmatically outside of a form, you can just do a lookup in the 
db.tiers table:

tier_id = db.tiers(name='some name')

Anthony

On Tuesday, May 27, 2014 8:35:43 PM UTC-4, Michael Gheith wrote:
>
> I have two pretty basic tables:
>
> db.define_table('tiers',
> Field('name', 'string'),
> Field('created_on', 'datetime', default=request.now),
> format = '%(name)s')
>
> db.define_table('metrics',
> Field('tier_id', 'reference tiers'),
> Field('total_count', 'integer'),
> Field('total_size', 'bigint'),
> Field('created_on', 'datetime', default=request.now))
>
> I pre populated my tiers table with data.  When I store data in my metrics 
> table, I don't know off hand the tier_id.  I know the tier name though.  Is 
> there a way I can use the tier name instead of the tier_id in this 
> reference?
>

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


[web2py] Re: global name 'db' is not defined

2014-05-28 Thread Anthony

>
> Would it make sense to have the first model file be named something like 
> 0_db.py - so that it is always run first?
>

Sure. You can name your model files whatever you want.
 

>  By the way: Am I doing the right thing here, by not modifying the db.py 
> file and instead adding my own file to specify the database schema?
>

db.py is in the scaffolding application just as an example. You should 
certainly feel free to modify it as well as rename it. The name "db.py" is 
just a convention.

Anthony

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


[web2py] Re: How to select a column of numbers into a list so that I can manipulate the list

2014-05-28 Thread Anthony
Note, in trunk there is now a new .column method for the Rows object, which 
allows you to extract a single column as a list of values (internally, it 
just does a list comprehension, as in my original answer). So, in this case 
you could do:

nums3 = db(db.Measures).select(orderby=db.Measures.measure_date_time).column
('measure_value')

You can also pass a field object to .column:

nums3 = db(db.Measures).select(orderby=db.Measures.measure_date_time).column
(db.Measures.measure_value)

Also, if you don't pass any argument to .column, it will return the first 
column, which is convenient if your database select returns only a single 
column:

nums3 = db().select(db.Measures.measure_value, orderby=db.Measures.
measure_date_time).column()

Anthony

On Monday, May 26, 2014 1:21:15 PM UTC-4, Anthony wrote:
>
> You can do:
>
> nums3 = [r.measure_value for r in db().select(db.Measures.measure_value)]
>
> The .select() returns a Rows object, which acts like a list of Row objects 
> -- if you want to extract just a single value from each Row object, you 
> have to iterate through the Rows object and pull each value out.
>
> Note, depending on what you are doing, you can instead operate on the Rows 
> object itself (rather than generating a list and then operating on the 
> list). For example, to randomize the order:
>
> import random
> random_rows = db(db.Measures).select().sort(lambda r: random.random())
>
> Anthony
>
> On Monday, May 26, 2014 6:20:07 AM UTC-4, Syd Stewart wrote:
>>
>> Hi
>>
>> What is the simplest way please to select a column of figures (floats and 
>> int) into a list, so I can manipulate the list e.g randomise the order 
>>
>>  nums3 = db(db.Measures).select( db.Measures.measure_value, 
>> orderby=db.Measures.measure_date_time)
>>
>>  meannums= sum(nums3)/float(len(nums3))
>>
>> This calculation of the mean keeps giving me an error
>>
>>   File "/home/sydstewart/web2py/applications/SydOwn/controllers/test.py" 
>> ,
>>  line 92, in cusum
>> qnum[i][k] = (nums3[k]) - (meannums)
>> TypeError: unsupported operand type(s) for -: 'Row' and 'int'
>>
>>
>> Thanks
>>
>>
>>

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


Re: [web2py] DAL Referencing By Name Not By ID Possible?

2014-05-28 Thread Carlos Costa
Give a look here:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables

But I think it won't work in your case because name is a string.
Our you can model it another way.

db.define_table('tiers',
Field('name', 'string'),
Field('created_on', 'datetime', default=request.now),
format = '%(name)s')

db.define_table('metrics',
Field('tier_name', 'string', requires=IS_IN_DB(db, 'tiers.name
',%(name)s')),
Field('total_count', 'integer'),
Field('total_size', 'bigint'),
Field('created_on', 'datetime', default=request.now))

However, this will not enforce reference at db level, only in application.
But you can query an join it by name without problems.

query = db(db.tiers.name == db.metrics.tier_name).select()
metric = db(db.metrics.tier_name == 'name').select()

or you can obviously write a helper function to short it

get_metrics = lambda name: db(db.metrics.tier_name == name).select()
get_tier = lambda name: db(db.tier.name == name).select().first()

tier = get_tier(name)
tier_metrics = get_metrics(name)


2014-05-27 21:35 GMT-03:00 'Michael Gheith' via web2py-users <
web2py@googlegroups.com>:

> I have two pretty basic tables:
>
> db.define_table('tiers',
> Field('name', 'string'),
> Field('created_on', 'datetime', default=request.now),
> format = '%(name)s')
>
> db.define_table('metrics',
> Field('tier_id', 'reference tiers'),
> Field('total_count', 'integer'),
> Field('total_size', 'bigint'),
> Field('created_on', 'datetime', default=request.now))
>
> I pre populated my tiers table with data.  When I store data in my metrics
> table, I don't know off hand the tier_id.  I know the tier name though.  Is
> there a way I can use the tier name instead of the tier_id in this
> reference?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Att.

Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן

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


[web2py] Re: Not able to access scheduler_task table getting error "DAL" object has no attribute "scheduler_task"

2014-05-28 Thread Niphlod
where is this ? before or after the 

mysched = Scheduler(db)

call ?


BTW: anything you do in that _after_update IS NOT SUPPORTED. You shouldn't 
fiddle with any scheduler table if not in the proper and documented way if 
you want support back ^_^

On Tuesday, May 27, 2014 8:14:05 AM UTC+2, Keerti Agrawal wrote:
>
> I am trying to write a callback function on scheduler_task table but its 
> giving rror "DAL" object has no attribute "scheduler_task".
> when i see attributes of SAL object using dir(db) it is not having 
> scheduler_task table or any table which is maintained by scheuler.
> Please help me how can i write callback function on scheduler_task table.
>
> i am witing it as
> db.scheduler_task._after_update = [.callback functn..]
>

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


[web2py] Re: what is loader.js for?

2014-05-28 Thread Niphlod
loader.js is not part of web2py.

On Tuesday, May 27, 2014 9:49:15 AM UTC+2, chuan137 wrote:
>
> anyone kowns what it is?
>
> On Monday, May 26, 2014 2:08:24 PM UTC+2, chuan137 wrote:
>>
>> looking at my simple example from chrome developer's tool, I noticed 
>> loader.js doing something in the background.
>> seems related with statistics or ads.
>>
>> can someone explain it to me? is it possible to disable it, because I 
>> want to do some performance measurements?
>>
>> thanks :)
>>
>

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


[web2py] Re: not able to include jqueryui in web2py

2014-05-28 Thread Niphlod
where is the javascript part that "turns on" the accordion effect ?


  $(function() {
$( "#accordion" ).accordion();
  });
  


On Tuesday, May 27, 2014 2:41:28 PM UTC+2, sarfaraz ahmed wrote:
>
> Hello All,
>
> I am trying to override the web2py default theme and use customized 
> jqueryui theme. Hence I downloaded the customized jqueryui js files and css 
> files. Copied them to static folder of my test project. I created the 
> jqueryui folder under static folder. I created the layout1.html file which 
> I am using as extended layout. Mentioned below is first code in layout1.html
> *Part1 : *
>
>  
> response.files.insert(0,URL('static','jqueryui/css/excite-bike/jquery-ui-1.10.4.custom.css'))
>   response.files.insert(1,URL('static','jqueryui/js/jquery-1.10.2.js'))
>   
> response.files.insert(2,URL('static','jqueryui/js/jquery-ui-1.10.4.custom.js'))
>   response.files.insert(3,URL('static','css/web2py.css'))
>   response.files.insert(4,URL('static','css/bootstrap.min.css'))
>   response.files.insert(5,URL('static','css/bootstrap-responsive.min.css'))
>   response.files.insert(6,URL('static','css/web2py_bootstrap.css'))
>
>   }}
>  
>   {{include 'web2py_ajax.html'}}
> 
> $(function() {
>  $( "#accordion" ).accordion();
> $( "#button" ).button();
> )};
>   
>
> 
> under default.index.html i wrote 
> {{extend 'layout1.html'}}
> 
> 
> Par1
> 
> 
> This is new para
> 
> 
> Par1
> 
> 
> This is new para
> 
>
> 
> Now when I press F12 to check html page source I see all the files are 
> properly included (I mean js and css files) However, I don't see accordion 
> or button from jqueryui theme.
>
> I read the one article posted by rami. I am newbie and fail to reach 
> solution from that thread. Please post step by step help.
> Regards,
> Sarfaraz Ahmed
>
>

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


[web2py] Re: DAL update expressions starting with an integer not working?

2014-05-28 Thread Niphlod
check again after dropping the db and recreating it. if you're using sqlite 
and that field(..., 'integer') was a string before, for a well known and 
very well documented bug of sqlite, that behaviour will happen.

db.define_table('a_table', Field('a_field', 'integer'))
db.a_table.insert(a_field=1)
db(db.a_table.id > 0).update(a_field = db.a_table.a_field + 1)

will make a_field == 2.

On Wednesday, May 28, 2014 11:03:59 AM UTC+2, Mirko wrote:
>
> I never updated data this way before, and after having made some tests, it 
> turns out that db.table.lft type is a Field that is converted into a string 
> and then an integer later (I don't know how).
>
> And I try the example from the book 
> db(db.table.lft>0).update(lft=db.table.lft+1) appends the string '1' to the 
> value (casted to string) of db.table.lft (this seems very weird to me 
> because db.table.lft type is Field)
>
> For example if db.table.lft (Field, type int) row value is 12345, 
> db.table.lft+1 after db update will give 123451
>
> Or am I missing something ?
>
>
> On Wednesday, May 28, 2014 8:21:56 AM UTC, Marian wrote:
>>
>> I want to negate a value with this expression:
>>
>> db(db.table.lft > 0).update(lft = 0 - db.table.lft)
>>
>> but I get the following TypeError:
>> TypeError: unsupported operand type(s) for -: 'int' and 'Field'
>>
>> My workaround is:
>> db(db.table.lft > 0).update(lft = db.table.lft - db.table.lft - db.table.lft)
>>
>>
>> *It seems that update expression need to start with the field or do I miss 
>> something?*
>>
>>

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


[web2py] Re: DAL update expressions starting with an integer not working?

2014-05-28 Thread Mirko
I never updated data this way before, and after having made some tests, it 
turns out that db.table.lft type is a Field that is converted into a string 
and then an integer later (I don't know how).

And I try the example from the book 
db(db.table.lft>0).update(lft=db.table.lft+1) appends the string '1' to the 
value (casted to string) of db.table.lft (this seems very weird to me 
because db.table.lft type is Field)

For example if db.table.lft (Field, type int) row value is 12345, 
db.table.lft+1 after db update will give 123451

Or am I missing something ?


On Wednesday, May 28, 2014 8:21:56 AM UTC, Marian wrote:
>
> I want to negate a value with this expression:
>
> db(db.table.lft > 0).update(lft = 0 - db.table.lft)
>
> but I get the following TypeError:
> TypeError: unsupported operand type(s) for -: 'int' and 'Field'
>
> My workaround is:
> db(db.table.lft > 0).update(lft = db.table.lft - db.table.lft - db.table.lft)
>
>
> *It seems that update expression need to start with the field or do I miss 
> something?*
>
>

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


[web2py] DAL update expressions starting with an integer not working?

2014-05-28 Thread Marian


I want to negate a value with this expression:

db(db.table.lft > 0).update(lft = 0 - db.table.lft)

but I get the following TypeError:
TypeError: unsupported operand type(s) for -: 'int' and 'Field'

My workaround is:
db(db.table.lft > 0).update(lft = db.table.lft - db.table.lft - db.table.lft)


*It seems that update expression need to start with the field or do I miss 
something?*

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