[web2py] Error that i really dont understand

2012-02-27 Thread Hassan Alnatour
Dear All,

i have an error can you help me  ..  This is the error ..

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
exec ccode in environment
  File "C:\web2py\applications\Golden_Star\views\default/
Courses.html", line 41, in 
padding:10px;
  File "C:\web2py\gluon\dal.py", line 6333, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "C:\web2py\gluon\dal.py", line 1282, in select
rows = response(sql)
  File "C:\web2py\gluon\dal.py", line 1272, in response
self.execute(sql)
  File "C:\web2py\gluon\dal.py", line 1359, in execute
return self.log_execute(*a, **b)
  File "C:\web2py\gluon\dal.py", line 1353, in log_execute
ret = self.cursor.execute(*a, **b)
  File "C:\Python27\lib\sqlite3\dbapi2.py", line 66, in
convert_timestamp
datepart, timepart = val.split(" ")
ValueError: need more than 1 value to unpack
ERROR SNAPSHOT
(need more than 1 value to unpack)



Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Johann Spies
On 28 February 2012 00:25, Anthony  wrote:

> Also, keep in mind that "model-less" can mean many things. It doesn't
> necessarily entail the highly class-based approach you see in Bruno's
> Movuca. It could mean simply moving some standard table definitions from
> model files into functions in modules. In fact, I think Bruno's class-based
> design and the notion of "model-less" are largely orthogonal -- you can
> define classes in model files, and you can use a non-classed-based approach
> in modules.


I do not particularly like the OO-approach in programming and would prefer
to use classes only when it is clearly the best (or easiest) option.

Here is a very simple example of defining a table in a module without using
classes explicitly:

In the model (db.py):

from gluon import current
current.db = db

In the module(tabelle.py):

from gluon import *
import re

def tabel1():
db = current.db
db.define_table('toets',
Field('veld1'),
Field('veld2')
)

print db.tables
return db

Controller:
from  applications.toets.modules.tabelle import *
def index():
 db = tabel1()
print "in controller"
print db.tables
vorm = crud.create(db.toets)
return dict(vorm = vorm)


And in appadmin.py do the same import as above and


def get_databases(request):
db = tabel1()
dbs = {}
...

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)
:


Re: [web2py] Re: Time Substraction

2012-02-27 Thread Sanjeet Kumar
Thanks Massimo

On Tue, Feb 28, 2012 at 10:33 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Delta has only days and seconds.
>
> On Feb 27, 9:55 pm, Sanjeet Kumar  wrote:
> >  showing AttributeError: 'datetime.timedelta' object has no attribute
> 'minutes'
> >
> >
> >
> >
> >
> >
> >
> > On Tuesday, February 28, 2012 1:47:40 AM UTC+5:30, Ross Peoples wrote:
> >
> > > Well, one of the issues is going to be that you are using 'date' for
> your
> > > fields instead of 'datetime'. When using 'datetime', it becomes easy
> to do
> > > something like this:
> >
> > > delta = row.employee_logout_date - row.employee_login_date
> > > minutes = delta.minutes + (delta.hours * 60)
> >
> > > On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
> >
> > >> I am going to develop the time management sheet for that i have the
> one
> > >> table name employee table and i am allready taken the login and
> logout time
> > >> and i want to substract the time when i substract the time it show me
> in
> > >> nanoseconds when i convert this nanosecond to the minute it totally
> > >> confused me so if any one have solution please help me following is my
> > >> controller and database :-
> > >> *
> > >> Table:-*
> >
> > >> db.define_table('employee_detail',
> > >> Field('employee_id'),
> > >> Field('employee_name'),
> > >> Field('employee_login_date','date'),
> > >> Field('employee_logout_date','date'),
> > >> Field('employee_login_time'),
> > >> Field('employee_logout_time'),
> > >> Field('total_time'))*
> >
> > >> Controller:-*
> >
> > >> def lgin(form):
> > >> import datetime
> > >> import time
> > >> currentdate=datetime.date.today()
> > >> now = time.localtime(time.time())
> > >> session.sttime=time.time()
> > >> currenttime = time.strftime("%H:%M:%S", now)
> > >> session.time = currenttime
> > >> #response.flash=currentdate
> > >> for row in db(db.auth_user.email ==
> > >> auth.user.email).select(db.auth_user.first_name):
> > >> firstname=row.first_name
> > >> db.employee_detail.insert(employee_id = auth.user.email,
> > >> employee_name=firstname, employee_login_date=currentdate,
> > >> employee_login_time=currenttime)
> > >> return ''
> >
> > >> def lgout(usr):
> > >> import datetime
> > >> import time
> > >> currentdate=datetime.date.today()
> > >> now = time.localtime(time.time())
> > >> ettime=time.time()
> > >> duration = ettime-session.sttime
> > >> du = str(duration / 600)
> > >> currenttime = time.strftime("%H:%M:%S", now)
> > >> db((db.employee_detail.employee_id == auth.user.email) &
> > >> (db.employee_detail.employee_login_date == currentdate) &
> > >> (db.employee_detail.employee_login_time ==
> > >> session.time)).update(employee_logout_date=currentdate,
> > >> employee_logout_time=currenttime, total_time=du)
> > >> return ''
> >
> > > On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
> >
> > >> I am going to develop the time management sheet for that i have the
> one
> > >> table name employee table and i am allready taken the login and
> logout time
> > >> and i want to substract the time when i substract the time it show me
> in
> > >> nanoseconds when i convert this nanosecond to the minute it totally
> > >> confused me so if any one have solution please help me following is my
> > >> controller and database :-
> > >> *
> > >> Table:-*
> >
> > >> db.define_table('employee_detail',
> > >> Field('employee_id'),
> > >> Field('employee_name'),
> > >> Field('employee_login_date','date'),
> > >> Field('employee_logout_date','date'),
> > >> Field('employee_login_time'),
> > >> Field('employee_logout_time'),
> > >> Field('total_time'))*
> >
> > >> Controller:-*
> >
> > >> def lgin(form):
> > >> import datetime
> > >> import time
> > >> currentdate=datetime.date.today()
> > >> now = time.localtime(time.time())
> > >> session.sttime=time.time()
> > >> currenttime = time.strftime("%H:%M:%S", now)
> > >> session.time = currenttime
> > >> #response.flash=currentdate
> > >> for row in db(db.auth_user.email ==
> > >> auth.user.email).select(db.auth_user.first_name):
> > >> firstname=row.first_name
> > >> db.employee_detail.insert(employee_id = auth.user.email,
> > >> employee_name=firstname, employee_login_date=currentdate,
> > >> employee_login_time=currenttime)
> > >> return ''
> >
> > >> def lgout(usr):
> > >> import datetime
> > >> import time
> > >> currentdate=datetime.date.today()
> > >> now = time.localtime(time.time())
> > >> ettime=time.time()
> > >> duration = ettime-session.sttime
> > >> du = str(duration / 600)
> > >> currenttime = time.strftime("%H:%M:%S

[web2py] Re: Database deadlocks with new scheduler

2012-02-27 Thread Massimo Di Pierro
Do you do this in a controller?

db.scheduler_task.insert(...)

if not. Make sure you db.commit() immediately after. Would is solve
the problem?

On Feb 27, 9:14 pm, David Phillips 
wrote:
> I am experiencing database deadlocks in a worker processes that is
> being scheduled by web2py's new scheduler.
>
> I'm using the latest web2py with Python 2.7.2 and MySQL (a recent
> release) on OS X 10.7.3.
>
> The worker does a lengthy calculation that I wanted to take off the
> http thread. Every time I get a certain action, I schedule the thread
> programmatically like this:
>
> db.scheduler_task.insert(application_name = 'geo', task_name =
> 'match_task',
>                                 function_name = 'match_listings', vars = 
> json.dumps(vars))
>
> In my testing I execute this task about once every two seconds. It has
> failed in two separate tests after about an hour.
>
> I'm getting this traceback:
>
>   File "/Users/davidp/dev/python/web2py/gluon/shell.py", line 214, in
> run
>     exec(python_code, _env)
>   File "", line 1, in 
>   File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 363,
> in loop
>     MetaScheduler.loop(self)
>   File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 255,
> in loop
>     task = self.pop_task()
>   File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 392,
> in pop_task
>     grabbed.update(assigned_worker_name='',status=QUEUED)
>   File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 6346, in
> update
>     return self.db._adapter.update(tablename,self.query,fields)
>   File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1093, in
> update
>     self.execute(sql)
>   File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1359, in
> execute
>     return self.log_execute(*a, **b)
>   File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1353, in
> log_execute
>     ret = self.cursor.execute(*a, **b)
>   File "/Users/davidp/dev/python/web2py/gluon/contrib/pymysql/
> cursors.py", line 108, in execute
>     self.errorhandler(self, exc, value)
>   File "/Users/davidp/dev/python/web2py/gluon/contrib/pymysql/
> connections.py", line 184, in defaulterrorhandler
>     raise errorclass, errorvalue
> InternalError: (1213, u'Deadlock found when trying to get lock; try
> restarting transaction')
>
> When executed, the task does this SQL select:
>
> expr = '''SELECT *, ( 3959 * acos (cos (radians (%s)) * cos (radians
> (lat)) *
>         cos (radians (lon) - radians (%s)) + sin (radians (%s)) * sin
> (radians (lat
>         AS distance FROM users HAVING distance < radius;''' % (point[0],
> point[1], point[0])
>         nearby_users = db.executesql(expr, as_dict = True)
>
> and then does a read to collect some statistics to track performance:
>
>         num_listings = db (db.listings.id > 0).count()
>
> During this time, I am receiving asynchronous http requests that
> insert, update and delete from this table (and another table, too).
>
> My MySQL client responds to a "show engine innodb  status;" command
> this way:
>
> 
> LATEST DETECTED DEADLOCK
> 
> 120227 20:38:16
> *** (1) TRANSACTION:
> TRANSACTION 27AFF, ACTIVE 0 sec starting index read
> mysql tables in use 1, locked 1
> LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s), undo log
> entries 1
> MySQL thread id 19816, OS thread handle 0x10c5db000, query id 1558959
> localhost 127.0.0.1 root Updating
> UPDATE scheduler_task SET status='QUEUED',assigned_worker_name=''
> WHERE ((scheduler_task.assigned_worker_name = 'Mycroft.local#d600fcf2-
> a363-4870-bd24-1ad3694f6a62') AND (scheduler_task.status =
> 'ASSIGNED'))
> *** (1) WAITING FOR THIS LOCK TO BE GRANTED:
> RECORD LOCKS space id 0 page no 3031 n bits 120 index `PRIMARY` of
> table `geo`.`scheduler_task` trx id 27AFF lock_mode X waiting
> Record lock, heap no 2 PHYSICAL RECORD: n_fields 20; compact format;
> info bits 0
>  0: len 4; hex 802c; asc    ,;;
>  1: len 6; hex 00024db1; asc     M ;;
>  2: len 7; hex 6a0d4c2f35; asc j   L/5;;
>  3: len 3; hex 67656f; asc geo;;
>  4: len 10; hex 656d61696c207461736b; asc email task;;
>  5: len 4; hex 6d61696e; asc main;;
>  6: len 6; hex 515545554544; asc QUEUED;;
>  7: len 10; hex 73656e645f656d61696c; asc send_email;;
>  8: len 2; hex 5b5d; asc [];;
>  9: len 2; hex 7b7d; asc {};;
>  10: len 1; hex 54; asc T;;
>  11: len 8; hex 8000124c9afce86c; asc    L   l;;
>  12: len 8; hex 8000124c9afee908; asc    L    ;;
>  13: len 8; hex 8000124c9b0c193a; asc    L   :;;
>  14: len 4; hex 8000; asc     ;;
>  15: len 4; hex 8e10; asc     ;;
>  16: len 4; hex 8dde; asc     ;;
>  17: len 4; hex 800d; asc     ;;
>  18: len 8; hex 8000124c9afec1f8; asc    L    ;;
>  19: len 0; hex ; asc ;;
>
> *** (2) TRANSACTION:
> TRANSACTION 27AFD, ACTIVE 0 sec fetching rows
> mysql tables in use 2, locked 2
> 52 lock struct(s), heap size 6960, 2775 row lock(s), undo log entries
> 9
> MySQL thread id 19817, OS thread handle 0x

[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Massimo Di Pierro
you can do:

for row in rows: row.foo = row[foo]

and then you do not have to pass it.

On Feb 27, 10:40 pm, Anthony  wrote:
> > I am not convinced that
>
> > rows = db().select(db.table.field1.sum() as foo)
> > +  {{=row.foo}}
>
> > is any simpler than
>
> > foo = db.table.field1.sum()
> > rows = db().select(foo)
> > +  {{=row[foo]}}
>
> The problem is in the latter case, you have to pass foo to the view -- not
> a big deal with just foo, but more cumbersome with multiple expressions.
>
> Anthony


[web2py] Re: V199.4 Error when define table in module and import it?

2012-02-27 Thread Massimo Di Pierro
Not sure what the problem is but this is definitively cause for
trouble:

T = current.T

In fact that is not thread safe. You cannot reference stuff in current
outside a function or method.

On Feb 27, 10:39 pm, IVINH  wrote:
> HI,
>
> Please help me for this error:
>
> Traceback (most recent call last):
>   File "E:\web2py1994\gluon\restricted.py", line 204, in restricted
>     exec ccode in environment
>   File "E:/web2py1994/applications/app/controllers/plugin_attach.py" 
> , 
> line 29, in 
>   File "E:\web2py1994\gluon\globals.py", line 172, in 
>     self._caller = lambda f: f()
>   File "E:/web2py1994/applications/app/controllers/plugin_attach.py" 
> , 
> line 9, in index
>     a = define('object_attachment')
>   File "applications\app\modules\plugin_attach.py", line 28, in define
>     migrate=True)
>   File "E:\web2py1994\gluon\dal.py", line 5084, in define_table
>     common_filter=common_filter))
>   File "E:\web2py1994\gluon\dal.py", line 5344, in __init__
>     'define_table argument is not a Field or Table: %s' % field
> SyntaxError: define_table argument is not a Field or Table: .object
>
> My module:
>
> from gluon import current
> from html import *
> from dal import Field
> import os
> T = current.T
>
> def define(table_name):
>     db = current.globalenv['db']
>     auth= current.globalenv['auth']
>     if table_name not in db.tables:
>         db.define_table(table_name,
>             Field('object',writable=False,readable=False),
>             Field('object_id','integer',writable=False,readable=False),
>             Field('othet_object',writable=False,readable=False),
>             Field('other_id','integer',writable=False,readable=False),
>             Field('name',default=T('Attachment')),
>             Field('type'),
>             Field('extension'),
>             Field('file','upload',autodelete=True),
>             Field('created_by','integer',default=auth.user_id or
> 1,writable=False,readable=False),
>
> Field('created_on','datetime',default=current.request.now,writable=False,re 
> adable=False),
>             migrate=True)
>     return db[table_name]
>
> my controller:
>
> from plugin_attach import define
> def index():
>     a = define('object_attachment')
>     return dict(f=a.fields)


[web2py] Re: Time Substraction

2012-02-27 Thread Massimo Di Pierro
Delta has only days and seconds.

On Feb 27, 9:55 pm, Sanjeet Kumar  wrote:
>  showing AttributeError: 'datetime.timedelta' object has no attribute 
> 'minutes'
>
>
>
>
>
>
>
> On Tuesday, February 28, 2012 1:47:40 AM UTC+5:30, Ross Peoples wrote:
>
> > Well, one of the issues is going to be that you are using 'date' for your
> > fields instead of 'datetime'. When using 'datetime', it becomes easy to do
> > something like this:
>
> > delta = row.employee_logout_date - row.employee_login_date
> > minutes = delta.minutes + (delta.hours * 60)
>
> > On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>
> >> I am going to develop the time management sheet for that i have the one
> >> table name employee table and i am allready taken the login and logout time
> >> and i want to substract the time when i substract the time it show me in
> >> nanoseconds when i convert this nanosecond to the minute it totally
> >> confused me so if any one have solution please help me following is my
> >> controller and database :-
> >> *
> >> Table:-*
>
> >> db.define_table('employee_detail',
> >>                 Field('employee_id'),
> >>                 Field('employee_name'),
> >>                 Field('employee_login_date','date'),
> >>                 Field('employee_logout_date','date'),
> >>                 Field('employee_login_time'),
> >>                 Field('employee_logout_time'),
> >>                 Field('total_time'))*
>
> >> Controller:-*
>
> >> def lgin(form):
> >>     import datetime
> >>     import time
> >>     currentdate=datetime.date.today()
> >>     now = time.localtime(time.time())
> >>     session.sttime=time.time()
> >>     currenttime = time.strftime("%H:%M:%S", now)
> >>     session.time = currenttime
> >>     #response.flash=currentdate
> >>     for row in db(db.auth_user.email ==
> >> auth.user.email).select(db.auth_user.first_name):
> >>         firstname=row.first_name
> >>     db.employee_detail.insert(employee_id = auth.user.email,
> >> employee_name=firstname, employee_login_date=currentdate,
> >> employee_login_time=currenttime)
> >>     return ''
>
> >> def lgout(usr):
> >>     import datetime
> >>     import time
> >>     currentdate=datetime.date.today()
> >>     now = time.localtime(time.time())
> >>     ettime=time.time()
> >>     duration = ettime-session.sttime
> >>     du = str(duration / 600)
> >>     currenttime = time.strftime("%H:%M:%S", now)
> >>     db((db.employee_detail.employee_id == auth.user.email) &
> >> (db.employee_detail.employee_login_date == currentdate) &
> >> (db.employee_detail.employee_login_time ==
> >> session.time)).update(employee_logout_date=currentdate,
> >> employee_logout_time=currenttime, total_time=du)
> >>     return ''
>
> > On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>
> >> I am going to develop the time management sheet for that i have the one
> >> table name employee table and i am allready taken the login and logout time
> >> and i want to substract the time when i substract the time it show me in
> >> nanoseconds when i convert this nanosecond to the minute it totally
> >> confused me so if any one have solution please help me following is my
> >> controller and database :-
> >> *
> >> Table:-*
>
> >> db.define_table('employee_detail',
> >>                 Field('employee_id'),
> >>                 Field('employee_name'),
> >>                 Field('employee_login_date','date'),
> >>                 Field('employee_logout_date','date'),
> >>                 Field('employee_login_time'),
> >>                 Field('employee_logout_time'),
> >>                 Field('total_time'))*
>
> >> Controller:-*
>
> >> def lgin(form):
> >>     import datetime
> >>     import time
> >>     currentdate=datetime.date.today()
> >>     now = time.localtime(time.time())
> >>     session.sttime=time.time()
> >>     currenttime = time.strftime("%H:%M:%S", now)
> >>     session.time = currenttime
> >>     #response.flash=currentdate
> >>     for row in db(db.auth_user.email ==
> >> auth.user.email).select(db.auth_user.first_name):
> >>         firstname=row.first_name
> >>     db.employee_detail.insert(employee_id = auth.user.email,
> >> employee_name=firstname, employee_login_date=currentdate,
> >> employee_login_time=currenttime)
> >>     return ''
>
> >> def lgout(usr):
> >>     import datetime
> >>     import time
> >>     currentdate=datetime.date.today()
> >>     now = time.localtime(time.time())
> >>     ettime=time.time()
> >>     duration = ettime-session.sttime
> >>     du = str(duration / 600)
> >>     currenttime = time.strftime("%H:%M:%S", now)
> >>     db((db.employee_detail.employee_id == auth.user.email) &
> >> (db.employee_detail.employee_login_date == currentdate) &
> >> (db.employee_detail.employee_login_time ==
> >> session.time)).update(employee_logout_date=currentdate,
> >> employee_logout_time=currenttime, total_time=du)
> >>     return ''
>
> > On Monday, February 27, 2012 11:54:56 AM 

[web2py] Database deadlocks with new scheduler

2012-02-27 Thread David Phillips
I am experiencing database deadlocks in a worker processes that is
being scheduled by web2py's new scheduler.

I'm using the latest web2py with Python 2.7.2 and MySQL (a recent
release) on OS X 10.7.3.

The worker does a lengthy calculation that I wanted to take off the
http thread. Every time I get a certain action, I schedule the thread
programmatically like this:

db.scheduler_task.insert(application_name = 'geo', task_name =
'match_task',
function_name = 'match_listings', vars = 
json.dumps(vars))

In my testing I execute this task about once every two seconds. It has
failed in two separate tests after about an hour.

I'm getting this traceback:

  File "/Users/davidp/dev/python/web2py/gluon/shell.py", line 214, in
run
exec(python_code, _env)
  File "", line 1, in 
  File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 363,
in loop
MetaScheduler.loop(self)
  File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 255,
in loop
task = self.pop_task()
  File "/Users/davidp/dev/python/web2py/gluon/scheduler.py", line 392,
in pop_task
grabbed.update(assigned_worker_name='',status=QUEUED)
  File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 6346, in
update
return self.db._adapter.update(tablename,self.query,fields)
  File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1093, in
update
self.execute(sql)
  File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1359, in
execute
return self.log_execute(*a, **b)
  File "/Users/davidp/dev/python/web2py/gluon/dal.py", line 1353, in
log_execute
ret = self.cursor.execute(*a, **b)
  File "/Users/davidp/dev/python/web2py/gluon/contrib/pymysql/
cursors.py", line 108, in execute
self.errorhandler(self, exc, value)
  File "/Users/davidp/dev/python/web2py/gluon/contrib/pymysql/
connections.py", line 184, in defaulterrorhandler
raise errorclass, errorvalue
InternalError: (1213, u'Deadlock found when trying to get lock; try
restarting transaction')

When executed, the task does this SQL select:

expr = '''SELECT *, ( 3959 * acos (cos (radians (%s)) * cos (radians
(lat)) *
cos (radians (lon) - radians (%s)) + sin (radians (%s)) * sin
(radians (lat
AS distance FROM users HAVING distance < radius;''' % (point[0],
point[1], point[0])
nearby_users = db.executesql(expr, as_dict = True)

and then does a read to collect some statistics to track performance:

num_listings = db (db.listings.id > 0).count()

During this time, I am receiving asynchronous http requests that
insert, update and delete from this table (and another table, too).

My MySQL client responds to a "show engine innodb  status;" command
this way:


LATEST DETECTED DEADLOCK

120227 20:38:16
*** (1) TRANSACTION:
TRANSACTION 27AFF, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s), undo log
entries 1
MySQL thread id 19816, OS thread handle 0x10c5db000, query id 1558959
localhost 127.0.0.1 root Updating
UPDATE scheduler_task SET status='QUEUED',assigned_worker_name=''
WHERE ((scheduler_task.assigned_worker_name = 'Mycroft.local#d600fcf2-
a363-4870-bd24-1ad3694f6a62') AND (scheduler_task.status =
'ASSIGNED'))
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 3031 n bits 120 index `PRIMARY` of
table `geo`.`scheduler_task` trx id 27AFF lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 20; compact format;
info bits 0
 0: len 4; hex 802c; asc,;;
 1: len 6; hex 00024db1; asc M ;;
 2: len 7; hex 6a0d4c2f35; asc j   L/5;;
 3: len 3; hex 67656f; asc geo;;
 4: len 10; hex 656d61696c207461736b; asc email task;;
 5: len 4; hex 6d61696e; asc main;;
 6: len 6; hex 515545554544; asc QUEUED;;
 7: len 10; hex 73656e645f656d61696c; asc send_email;;
 8: len 2; hex 5b5d; asc [];;
 9: len 2; hex 7b7d; asc {};;
 10: len 1; hex 54; asc T;;
 11: len 8; hex 8000124c9afce86c; ascL   l;;
 12: len 8; hex 8000124c9afee908; ascL;;
 13: len 8; hex 8000124c9b0c193a; ascL   :;;
 14: len 4; hex 8000; asc ;;
 15: len 4; hex 8e10; asc ;;
 16: len 4; hex 8dde; asc ;;
 17: len 4; hex 800d; asc ;;
 18: len 8; hex 8000124c9afec1f8; ascL;;
 19: len 0; hex ; asc ;;

*** (2) TRANSACTION:
TRANSACTION 27AFD, ACTIVE 0 sec fetching rows
mysql tables in use 2, locked 2
52 lock struct(s), heap size 6960, 2775 row lock(s), undo log entries
9
MySQL thread id 19817, OS thread handle 0x10c598000, query id 1558955
localhost 127.0.0.1 root Sending data
UPDATE scheduler_task SET status='QUEUED',assigned_worker_name=''
WHERE ((scheduler_task.assigned_worker_name IN (SELECT
scheduler_worker.worker_name FROM scheduler_worker WHERE
(scheduler_worker.last_heartbeat < '2012-02-27 20:38:07'))) AND
(scheduler_task.status IN ('RUNNING','ASSIGNED','QUEUED')))
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 

[web2py] Re: request.user_agent() dumping [closed]

2012-02-27 Thread weheh
.


[web2py] Re: Obtaining URL to image blob in GAE

2012-02-27 Thread Anthony

>
> If there's a better way here, plaese let me know. The following should 
> work for you:
>
> def show_image():
> """
> return image - this method is referenced from the view - see below
> """
> if not request.args[0]:  return None
> id = request.args[0]
> image=db(db.imgtbl.id==id).select()
> return image[0].image_blob
> 
> my view code
>   {{extend 'layout.html'}}
>   
>   Display Jpeg Images
>   
>   
> 
>Image Title
>Image 
> 
> {{for img in images:}}
> 
> {{= TD(img.title)}}
> {{= TD(IMG(_src=URL("show_image", args=img.id), 
> _alt=img.title)) }}
> 
> {{pass}}
>   
>

You could define an upload field (maybe called 'image'), which will rename 
the file and store the new filename, and then define the blob field as the 
associated image storage field. Then, assuming the 'images' object in your 
view is a set of records from the 'imgtbl' table, the URL would be:

URL("show_image", args=img.image)

Then, the show_image function would just be:

def show_image():
return response.download(request, db)

Anthony
 

On Monday, February 27, 2012 5:48:58 PM UTC-5, BrendanC wrote:
>
> Peter,
> I was trying to get this to work last week and this is what finally worked 
> for me. 
> Here's a link to my earlier thread on the same topic.
> https://groups.google.com/forum/?fromgroups#!topic/web2py/1h3Nd3_T9Js
>
> In my case I'm storing small blobs in the table/model - although that's 
> not the best approach.
> However I was surprised that I has to make an explicit reference to the 
> blob field, as I expected 
> that to be handled implicitly.
>
> If there's a better way here, plaese let me know. The following should 
> work for you:
>
> def show_image():
> """
> return image - this method is referenced from the view - see below
> """
> if not request.args[0]:  return None
> id = request.args[0]
> image=db(db.imgtbl.id==id).select()
> return image[0].image_blob
> 
> my view code
>   {{extend 'layout.html'}}
>   
>   Display Jpeg Images
>   
>   
> 
>Image Title
>Image 
> 
> {{for img in images:}}
> 
> {{= TD(img.title)}}
> {{= TD(IMG(_src=URL("show_image", args=img.id), 
> _alt=img.title)) }}
> 
> {{pass}}
>  
>
> On Monday, February 27, 2012 12:01:55 PM UTC-8, howesc wrote:
>>
>> i'm using the blobstore so i can upload images larger than 1mb.  because 
>> of that i have access to 
>> http://code.google.com/appengine/docs/python/images/functions.html#Image_get_serving_urlwhich
>>  gives a URL that google serves up the image (and does not count 
>> against CPU for your app engine app).
>>
>> my image upload is a variant of 
>> http://www.web2pyslices.com/slices/take_slice/63
>>
>> cfh.
>>
>> On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>>>
>>> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:

 How would one obtain the URL to a image blob stored on GAE's 
 datastore? A lot of the threads I've looked at were all for generating 
 an download output for views, but I need this for the Controller since 
 I'm returning this as a JSON element. 

 For example, the auth_user table has a field 'avatar' and another blob 
 field 'avatar_blob'. Ideally I can simply return a JSON like: 
 { "avatar": "http:avatars/username_avatar.gif" } 

 Where username_avatar.gif would map to the stored blob image for that 
 user's avatar.
>>>
>>>
>>> Assuming you use web2py's standard "upload" field type to upload the 
>>> images, then you would still use the standard download process as well. See 
>>> the "Uploading files in database" section in 
>>> http://web2py.com/books/default/chapter/29/13 for details on setting up 
>>> database storage of uploads. And for downloading, see the 
>>> response.download description here: 
>>> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
>>> would be something like:
>>>
>>> db.define_table('auth_user',
>>> ...,
>>> Field('avatar', 'upload', uploadfield='avatar_blob'),
>>> Field('avatar_blob', 'blob'), ...)
>>>
>>> def download():
>>> return response.download(request, db)
>>>
>>> URL for a particular user's avatar:
>>>
>>> URL('default', 'download', args=auth.user.avatar)
>>>
>>> Anthony
>>>
>>>
>> On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>>>
>>> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:

 How would one obtain the URL to a image blob stored on GAE's 
 datastore? A lot of the threads I've looked at were all for generating 
 an download output for views, but I need this for the Controller since 
 I'm returning this as a JSON element. 

 For example, the auth_user table has a field 'avatar' and another blob 
 field 'avatar_blob'. Ideally I can simply

[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Anthony

>
> I am not convinced that 
>
> rows = db().select(db.table.field1.sum() as foo) 
> +  {{=row.foo}} 
>
> is any simpler than 
>
> foo = db.table.field1.sum() 
> rows = db().select(foo) 
> +  {{=row[foo]}}
>

The problem is in the latter case, you have to pass foo to the view -- not 
a big deal with just foo, but more cumbersome with multiple expressions.

Anthony 


[web2py] V199.4 Error when define table in module and import it?

2012-02-27 Thread IVINH
HI,

Please help me for this error:

Traceback (most recent call last):
  File "E:\web2py1994\gluon\restricted.py", line 204, in restricted
exec ccode in environment
  File "E:/web2py1994/applications/app/controllers/plugin_attach.py" 
, 
line 29, in 
  File "E:\web2py1994\gluon\globals.py", line 172, in 
self._caller = lambda f: f()
  File "E:/web2py1994/applications/app/controllers/plugin_attach.py" 
, 
line 9, in index
a = define('object_attachment')
  File "applications\app\modules\plugin_attach.py", line 28, in define
migrate=True)
  File "E:\web2py1994\gluon\dal.py", line 5084, in define_table
common_filter=common_filter))
  File "E:\web2py1994\gluon\dal.py", line 5344, in __init__
'define_table argument is not a Field or Table: %s' % field
SyntaxError: define_table argument is not a Field or Table: .object



My module:

from gluon import current
from html import *
from dal import Field
import os
T = current.T

def define(table_name):
db = current.globalenv['db']
auth= current.globalenv['auth']
if table_name not in db.tables:
db.define_table(table_name,
Field('object',writable=False,readable=False),
Field('object_id','integer',writable=False,readable=False),
Field('othet_object',writable=False,readable=False),
Field('other_id','integer',writable=False,readable=False),
Field('name',default=T('Attachment')),
Field('type'),
Field('extension'),
Field('file','upload',autodelete=True),
Field('created_by','integer',default=auth.user_id or 
1,writable=False,readable=False),

Field('created_on','datetime',default=current.request.now,writable=False,readable=False),
migrate=True)
return db[table_name]



my controller:

from plugin_attach import define
def index():
a = define('object_attachment')
return dict(f=a.fields)


[web2py] Re: Time Substraction

2012-02-27 Thread Sanjeet Kumar



 showing AttributeError: 'datetime.timedelta' object has no attribute 'minutes'



On Tuesday, February 28, 2012 1:47:40 AM UTC+5:30, Ross Peoples wrote:
>
> Well, one of the issues is going to be that you are using 'date' for your 
> fields instead of 'datetime'. When using 'datetime', it becomes easy to do 
> something like this:
>
> delta = row.employee_logout_date - row.employee_login_date
> minutes = delta.minutes + (delta.hours * 60)
>
> On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>>
>> I am going to develop the time management sheet for that i have the one 
>> table name employee table and i am allready taken the login and logout time 
>> and i want to substract the time when i substract the time it show me in 
>> nanoseconds when i convert this nanosecond to the minute it totally 
>> confused me so if any one have solution please help me following is my 
>> controller and database :-
>> *
>> Table:-*
>>
>> db.define_table('employee_detail',
>> Field('employee_id'),
>> Field('employee_name'),
>> Field('employee_login_date','date'),
>> Field('employee_logout_date','date'),
>> Field('employee_login_time'),
>> Field('employee_logout_time'),
>> Field('total_time'))*
>>
>> Controller:-*
>>
>> def lgin(form):
>> import datetime
>> import time
>> currentdate=datetime.date.today()
>> now = time.localtime(time.time())
>> session.sttime=time.time()
>> currenttime = time.strftime("%H:%M:%S", now)
>> session.time = currenttime
>> #response.flash=currentdate
>> for row in db(db.auth_user.email == 
>> auth.user.email).select(db.auth_user.first_name):
>> firstname=row.first_name
>> db.employee_detail.insert(employee_id = auth.user.email, 
>> employee_name=firstname, employee_login_date=currentdate, 
>> employee_login_time=currenttime)
>> return '' 
>>  
>> def lgout(usr): 
>> import datetime
>> import time
>> currentdate=datetime.date.today()
>> now = time.localtime(time.time())
>> ettime=time.time()
>> duration = ettime-session.sttime
>> du = str(duration / 600)
>> currenttime = time.strftime("%H:%M:%S", now) 
>> db((db.employee_detail.employee_id == auth.user.email) & 
>> (db.employee_detail.employee_login_date == currentdate) & 
>> (db.employee_detail.employee_login_time == 
>> session.time)).update(employee_logout_date=currentdate, 
>> employee_logout_time=currenttime, total_time=du)  
>> return '' 
>>
>>
>>
> On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>>
>> I am going to develop the time management sheet for that i have the one 
>> table name employee table and i am allready taken the login and logout time 
>> and i want to substract the time when i substract the time it show me in 
>> nanoseconds when i convert this nanosecond to the minute it totally 
>> confused me so if any one have solution please help me following is my 
>> controller and database :-
>> *
>> Table:-*
>>
>> db.define_table('employee_detail',
>> Field('employee_id'),
>> Field('employee_name'),
>> Field('employee_login_date','date'),
>> Field('employee_logout_date','date'),
>> Field('employee_login_time'),
>> Field('employee_logout_time'),
>> Field('total_time'))*
>>
>> Controller:-*
>>
>> def lgin(form):
>> import datetime
>> import time
>> currentdate=datetime.date.today()
>> now = time.localtime(time.time())
>> session.sttime=time.time()
>> currenttime = time.strftime("%H:%M:%S", now)
>> session.time = currenttime
>> #response.flash=currentdate
>> for row in db(db.auth_user.email == 
>> auth.user.email).select(db.auth_user.first_name):
>> firstname=row.first_name
>> db.employee_detail.insert(employee_id = auth.user.email, 
>> employee_name=firstname, employee_login_date=currentdate, 
>> employee_login_time=currenttime)
>> return '' 
>>  
>> def lgout(usr): 
>> import datetime
>> import time
>> currentdate=datetime.date.today()
>> now = time.localtime(time.time())
>> ettime=time.time()
>> duration = ettime-session.sttime
>> du = str(duration / 600)
>> currenttime = time.strftime("%H:%M:%S", now) 
>> db((db.employee_detail.employee_id == auth.user.email) & 
>> (db.employee_detail.employee_login_date == currentdate) & 
>> (db.employee_detail.employee_login_time == 
>> session.time)).update(employee_logout_date=currentdate, 
>> employee_logout_time=currenttime, total_time=du)  
>> return '' 
>>
>>
>>
> On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>>
>> I am going to develop the time management sheet for that i have the one 
>> table name employee table and i am allready taken the login and logout time 
>> and i want to substract the time wh

[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Massimo Di Pierro
I am not convinced that

rows = db().select(db.table.field1.sum() as foo)
+  {{=row.foo}}

is any simpler than

foo = db.table.field1.sum()
rows = db().select(foo)
+  {{=row[foo]}}

The latter has the advantage that does not generate conflicts at the
DB level.

As far as I know the book is almost ready.

Massimo

On Feb 27, 5:33 pm, Paul  wrote:
> OK, I can get this to work in the view now, but it seems to be overly
> complicated, I have one dal statement to generate some rows, but if I
> want lots of sums, mins and max etc I then need to pass all these
> additional objects via the dict to the view!, when surely all this
> data should be just part of the result set from the sql (and therefore
> available by iterating over the 'rows' object), Web2py is great for
> some things but this part seems a bit 'cluttered', I expected the
> syntax to be cleaner/simpler e.g.
>
> rows = db().select(db.table.field1.sum() as foo, db.table.field2.sum()
> as bar)
> return dict(rows=rows)
> ...
> ...
> {{for row in rows:}}
>     {{=row.foo}}  {{=row.bar}}
>
> p.s. Any idea when the Packt book will be published?, mines been on
> pre-order for 3 months now.
>
> On Feb 27, 9:12 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > you need to put it in the dict so the view can see it.
>
> > On Feb 27, 2:57 pm, Paul  wrote:
>
> > > One last part of the puzzle, this all works ok at the command line
> > > with print row[mysum] but I cannot get the syntax for using this in a
> > > view
>
> > > for example:-
>
> > > controller DAL query:-
> > > def mileage():
> > >     mysum = db.t_appointment.miles_to.sum()
> > > +db.t_appointment.miles_from.sum()
> > >     groupmm = db.t_appointment.f_start_time.year()|
> > > db.t_appointment.f_start_time.month()
> > >     rows = db().select(
> > >         mysum,
> > >         db.t_appointment.f_start_time.year(),
> > >         db.t_appointment.f_start_time.month(),
> > >     groupby=groupmm)
>
> > >     return dict(rows=rows, sql = db._lastsql)
>
> > > IN VIEW:
> > > {{for row in rows:}}
> > >  {{=row[mysum]}}
> > >  {{pass}}
>
> > > I get NameError: name 'mysum' is not defined
>
> > > If I try:
>
> > > {{for row in rows:}}
> > >  {{=row['mysum']}}
> > >  {{pass}}
>
> > > I get:
>
> > > Traceback (most recent call last):
> > >   File "D:\web2py-src\web2py\gluon\restricted.py", line 194, in
> > > restricted
> > >     exec ccode in environment
> > >   File "D:\web2py-src\web2py\applications\caltest\views\info/
> > > mileage.html", line 105, in 
> > >   File "D:\web2py-src\web2py\gluon\dal.py", line 4331, in __getitem__
> > >     return dict.__getitem__(self, key)
> > > KeyError: 'mysum'
>
> > > On Feb 27, 2:08 pm, Anthony  wrote:
>
> > > > > That syntax works and I can use that to refer to the data, I could see
> > > > > that a row object had an '_extra' dict for the selected expressions
> > > > > but could not see that the data could be referred to be the name of
> > > > > the expression 'mysum' (its in there somewhere but not sure where!!)
>
> > > > The book example does show that usage:
>
> > > > >>> sum = db.log.severity.sum()
> > > > >>> print db().select(sum).first()[sum]
>
> > > > Actually, when you do row[mysum], the __getitem__ method of the Row 
> > > > object
> > > > automatically does row[str(mysum)]. Since mysum is a DAL Expression 
> > > > object,
> > > > its __str__ method converts it to the SQL syntax for the particular
> > > > database adapter you are using, which in this case is 
> > > > "(SUM(t_appointment.miles_to)
> > > > + SUM(t_appointment.miles_from))". The Row __getitem__ method first 
> > > > looks
> > > > for that key in its _extra dict and returns the value if found. So, when
> > > > you do:
>
> > > > row[mysum]
>
> > > > This is essentially what is happening behind the scenes:
>
> > > >    1. row[str(mysum)]
> > > >    2. row['(SUM(t_appointment.miles_to) + 
> > > > SUM(t_appointment.miles_from))']
> > > >    3. row['_extra']['(SUM(t_appointment.miles_to) +
> > > >    SUM(t_appointment.miles_from))']
>
> > > > Anthony


[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Paul
OK, I can get this to work in the view now, but it seems to be overly
complicated, I have one dal statement to generate some rows, but if I
want lots of sums, mins and max etc I then need to pass all these
additional objects via the dict to the view!, when surely all this
data should be just part of the result set from the sql (and therefore
available by iterating over the 'rows' object), Web2py is great for
some things but this part seems a bit 'cluttered', I expected the
syntax to be cleaner/simpler e.g.

rows = db().select(db.table.field1.sum() as foo, db.table.field2.sum()
as bar)
return dict(rows=rows)
...
...
{{for row in rows:}}
{{=row.foo}}  {{=row.bar}}


p.s. Any idea when the Packt book will be published?, mines been on
pre-order for 3 months now.


On Feb 27, 9:12 pm, Massimo Di Pierro 
wrote:
> you need to put it in the dict so the view can see it.
>
> On Feb 27, 2:57 pm, Paul  wrote:
>
>
>
>
>
>
>
> > One last part of the puzzle, this all works ok at the command line
> > with print row[mysum] but I cannot get the syntax for using this in a
> > view
>
> > for example:-
>
> > controller DAL query:-
> > def mileage():
> >     mysum = db.t_appointment.miles_to.sum()
> > +db.t_appointment.miles_from.sum()
> >     groupmm = db.t_appointment.f_start_time.year()|
> > db.t_appointment.f_start_time.month()
> >     rows = db().select(
> >         mysum,
> >         db.t_appointment.f_start_time.year(),
> >         db.t_appointment.f_start_time.month(),
> >     groupby=groupmm)
>
> >     return dict(rows=rows, sql = db._lastsql)
>
> > IN VIEW:
> > {{for row in rows:}}
> >  {{=row[mysum]}}
> >  {{pass}}
>
> > I get NameError: name 'mysum' is not defined
>
> > If I try:
>
> > {{for row in rows:}}
> >  {{=row['mysum']}}
> >  {{pass}}
>
> > I get:
>
> > Traceback (most recent call last):
> >   File "D:\web2py-src\web2py\gluon\restricted.py", line 194, in
> > restricted
> >     exec ccode in environment
> >   File "D:\web2py-src\web2py\applications\caltest\views\info/
> > mileage.html", line 105, in 
> >   File "D:\web2py-src\web2py\gluon\dal.py", line 4331, in __getitem__
> >     return dict.__getitem__(self, key)
> > KeyError: 'mysum'
>
> > On Feb 27, 2:08 pm, Anthony  wrote:
>
> > > > That syntax works and I can use that to refer to the data, I could see
> > > > that a row object had an '_extra' dict for the selected expressions
> > > > but could not see that the data could be referred to be the name of
> > > > the expression 'mysum' (its in there somewhere but not sure where!!)
>
> > > The book example does show that usage:
>
> > > >>> sum = db.log.severity.sum()
> > > >>> print db().select(sum).first()[sum]
>
> > > Actually, when you do row[mysum], the __getitem__ method of the Row object
> > > automatically does row[str(mysum)]. Since mysum is a DAL Expression 
> > > object,
> > > its __str__ method converts it to the SQL syntax for the particular
> > > database adapter you are using, which in this case is 
> > > "(SUM(t_appointment.miles_to)
> > > + SUM(t_appointment.miles_from))". The Row __getitem__ method first looks
> > > for that key in its _extra dict and returns the value if found. So, when
> > > you do:
>
> > > row[mysum]
>
> > > This is essentially what is happening behind the scenes:
>
> > >    1. row[str(mysum)]
> > >    2. row['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))']
> > >    3. row['_extra']['(SUM(t_appointment.miles_to) +
> > >    SUM(t_appointment.miles_from))']
>
> > > Anthony


Re: [web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Bruce Wade
Thanks

On Mon, Feb 27, 2012 at 2:58 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I am treating this as a bug. now fixed in trunk.
>
> On Feb 27, 2:07 pm, Anthony  wrote:
> > In
> >
> > URL('adviewer', 'savesettings/location', user_signature=True)
> >
> > the URL() function sees function='savesettings/location' and args=None.
> > However, when a request is made to the URL generated by the above, the
> > function that verifies the signature sees function='savesettings' and
> > args='location'. The problem is, function='savesettings' and
> > args='location' does not generate the same signature as
> > function='savesettings/location' and args=None. The reason is that when
> > generating the signature, the extension is first added to the function
> > before concatenating the args, so when the signature is first generated,
> it
> > is a hash of a URL that includes "/savesettings/location.html", but when
> > verified, the signature is a hash of a URL that includes
> > "/savesettings.html/location". Therefore, the hashes won't match because
> > they are created from different strings.
> >
> > Is there any reason you are using the above rather than:
> >
> > URL('adviewer', 'savesettings', args='location', user_signature=True)
> >
> > which is really the correct way to use the URL() function? If you
> > explicitly specify "location" as the args argument to URL(), I think it
> > should work.
> >
> > Anthony
> >
> >
> >
> >
> >
> >
> >
> > On Monday, February 27, 2012 1:22:25 PM UTC-5, Detectedstealth wrote:
> >
> > > Ok it looks like the bug is related to:
> >
> > > URL('action/additional_parms', user_signature=True) if you have
> something
> > > in addition to the action @auth.requires_signature fails.
> >
> > > When using: FORM(_action=URL('adviewer','savesettings/location',
> > > user_signature=True)) or redirect(URL('payment/%s' %
> > > has_unpaid_orders.access_key, user_signature=True)) with
> > > @auth.requires_signature() on the action it fails with access denied.
> >
> > > On Wed, Feb 22, 2012 at 3:19 PM, Bruce Wade 
> wrote:
> >
> > >> When using user_signature=True in a form that action goes to another
> > >> method and that method has @auth.requires_signature I am getting
> access
> > >> denied, if I remove the @auth.requires_signature I still see the
> signature
> > >> but don't have the access denied message.
> >
> > >> FORM:
> > >> # adviewer.viewads();
> >
> > >> locationform=FORM(
> > >> DIV(
> > >> SELECT(countries_options,_id='by-country',_name='country',
> > >> _onchange="updateProvinces(this)", value=selected_country),
> > >> _id='country_options', _class='filter-selects'
> > >> ),
> > >> DIV(
> > >> SELECT(provinces_options,_id='by-province',
> > >> _name='province_state',_onchange="updateCities(this)",
> > >> value=selected_province),
> > >> _id='province_options', _class='filter-selects'
> > >> ),
> > >> DIV(SELECT(
> > >> cities_options,_id='by-province', _name='city',
> > >> value=selected_city),
> > >> _id='city_options', _class='filter-selects'
> > >> ),
> > >> DIV(_class='clear'),
> > >> INPUT(_type='submit', _value='Save', _class='filter-btn'),
> > >> _name='locationform',
> > >> _action=URL('adviewer','savesettings/location',
> > >> user_signature=True)
> > >> )
> >
> > >> Capture Method:
> > >> # adviewer.savesettings()
> > >> // URL submitted to this method:
> > >>http://127.0.0.1:8000/zh/adviewer/savesettings/location?_signature=82.
> ..
> > >> @auth.requires_login()
> > >> @auth.requires_signature()  # If I remove this there is no access
> denied.
> > >> def savesettings():
> > >> print request.vars
> > >> print request.args(0)
> > >> from youadAPI.adviewer_api import AdViewerEngine
> > >> if request.args(0) == 'location':
> > >> adviewer_engine.update_or_create_adviewer_settings(
> > >> AdViewerEngine.location,
> > >> dict(
> > >>  country=request.vars['country'],
> > >>  province=request.vars['province_state'],
> > >>  city=request.vars['city']
> > >> )
> > >> )
> > >> elif request.args(0) == 'language':
> > >> adviewer_engine.update_or_create_adviewer_settings(
> > >> AdViewerEngine.language,
> > >> dict(
> > >> language = request.vars['language']
> > >> )
> > >> )
> > >> elif request.args(0) == 'keywords':
> > >> adviewer_engine.update_or_create_adviewer_settings(
> > >> AdViewerEngine.keywords,
> > >> dict(
> > >> keywords = request.vars['keywords']
> > >> )
> > >> )
> >
> > >> --
> > >> --
> > >> Regards,
> > >> Bruce Wade
> > >>http://ca.linkedin.com/in/brucelwade
> > >>http://www.wadecybertech.com
> > >>http://www.warplydesigned.com
> > >>http://www.

[web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Massimo Di Pierro
I am treating this as a bug. now fixed in trunk.

On Feb 27, 2:07 pm, Anthony  wrote:
> In
>
> URL('adviewer', 'savesettings/location', user_signature=True)
>
> the URL() function sees function='savesettings/location' and args=None.
> However, when a request is made to the URL generated by the above, the
> function that verifies the signature sees function='savesettings' and
> args='location'. The problem is, function='savesettings' and
> args='location' does not generate the same signature as
> function='savesettings/location' and args=None. The reason is that when
> generating the signature, the extension is first added to the function
> before concatenating the args, so when the signature is first generated, it
> is a hash of a URL that includes "/savesettings/location.html", but when
> verified, the signature is a hash of a URL that includes
> "/savesettings.html/location". Therefore, the hashes won't match because
> they are created from different strings.
>
> Is there any reason you are using the above rather than:
>
> URL('adviewer', 'savesettings', args='location', user_signature=True)
>
> which is really the correct way to use the URL() function? If you
> explicitly specify "location" as the args argument to URL(), I think it
> should work.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, February 27, 2012 1:22:25 PM UTC-5, Detectedstealth wrote:
>
> > Ok it looks like the bug is related to:
>
> > URL('action/additional_parms', user_signature=True) if you have something
> > in addition to the action @auth.requires_signature fails.
>
> > When using: FORM(_action=URL('adviewer','savesettings/location',
> > user_signature=True)) or redirect(URL('payment/%s' %
> > has_unpaid_orders.access_key, user_signature=True)) with
> > @auth.requires_signature() on the action it fails with access denied.
>
> > On Wed, Feb 22, 2012 at 3:19 PM, Bruce Wade  wrote:
>
> >> When using user_signature=True in a form that action goes to another
> >> method and that method has @auth.requires_signature I am getting access
> >> denied, if I remove the @auth.requires_signature I still see the signature
> >> but don't have the access denied message.
>
> >> FORM:
> >> # adviewer.viewads();
>
> >> locationform=FORM(
> >>         DIV(
> >>             SELECT(countries_options,_id='by-country',_name='country',
> >> _onchange="updateProvinces(this)", value=selected_country),
> >>             _id='country_options', _class='filter-selects'
> >>         ),
> >>         DIV(
> >>             SELECT(provinces_options,_id='by-province',
> >> _name='province_state',_onchange="updateCities(this)",
> >> value=selected_province),
> >>             _id='province_options', _class='filter-selects'
> >>         ),
> >>         DIV(SELECT(
> >>             cities_options,_id='by-province', _name='city',
> >> value=selected_city),
> >>             _id='city_options', _class='filter-selects'
> >>         ),
> >>         DIV(_class='clear'),
> >>         INPUT(_type='submit', _value='Save', _class='filter-btn'),
> >>         _name='locationform',
> >>         _action=URL('adviewer','savesettings/location',
> >> user_signature=True)
> >>     )
>
> >> Capture Method:
> >> # adviewer.savesettings()
> >> // URL submitted to this method:
> >>http://127.0.0.1:8000/zh/adviewer/savesettings/location?_signature=82...
> >> @auth.requires_login()
> >> @auth.requires_signature()  # If I remove this there is no access denied.
> >> def savesettings():
> >>     print request.vars
> >>     print request.args(0)
> >>     from youadAPI.adviewer_api import AdViewerEngine
> >>     if request.args(0) == 'location':
> >>         adviewer_engine.update_or_create_adviewer_settings(
> >>             AdViewerEngine.location,
> >>             dict(
> >>                  country=request.vars['country'],
> >>                  province=request.vars['province_state'],
> >>                  city=request.vars['city']
> >>             )
> >>         )
> >>     elif request.args(0) == 'language':
> >>         adviewer_engine.update_or_create_adviewer_settings(
> >>             AdViewerEngine.language,
> >>             dict(
> >>                 language = request.vars['language']
> >>             )
> >>         )
> >>     elif request.args(0) == 'keywords':
> >>         adviewer_engine.update_or_create_adviewer_settings(
> >>             AdViewerEngine.keywords,
> >>             dict(
> >>                 keywords = request.vars['keywords']
> >>             )
> >>         )
>
> >> --
> >> --
> >> Regards,
> >> Bruce Wade
> >>http://ca.linkedin.com/in/brucelwade
> >>http://www.wadecybertech.com
> >>http://www.warplydesigned.com
> >>http://www.fitnessfriendsfinder.com
>
> > --
> > --
> > Regards,
> > Bruce Wade
> >http://ca.linkedin.com/in/brucelwade
> >http://www.wadecybertech.com
> >http://www.warplydesigned.com
> >http://www.fitnessfriendsfinder.com


[web2py] Re: Obtaining URL to image blob in GAE

2012-02-27 Thread BrendanC
Peter,
I was trying to get this to work last week and this is what finally worked 
for me. 
Here's a link to my earlier thread on the same topic.
https://groups.google.com/forum/?fromgroups#!topic/web2py/1h3Nd3_T9Js

In my case I'm storing small blobs in the table/model - although that's not 
the best approach.
However I was surprised that I has to make an explicit reference to the 
blob field, as I expected 
that to be handled implicitly.

If there's a better way here, plaese let me know. The following should work 
for you:

def show_image():
"""
return image - this method is referenced from the view - see below
"""
if not request.args[0]:  return None
id = request.args[0]
image=db(db.imgtbl.id==id).select()
return image[0].image_blob

my view code
  {{extend 'layout.html'}}
  
  Display Jpeg Images
  
  

   Image Title
   Image 

{{for img in images:}}

{{= TD(img.title)}}
{{= TD(IMG(_src=URL("show_image", args=img.id), 
_alt=img.title)) }}

{{pass}}
 

On Monday, February 27, 2012 12:01:55 PM UTC-8, howesc wrote:
>
> i'm using the blobstore so i can upload images larger than 1mb.  because 
> of that i have access to 
> http://code.google.com/appengine/docs/python/images/functions.html#Image_get_serving_urlwhich
>  gives a URL that google serves up the image (and does not count 
> against CPU for your app engine app).
>
> my image upload is a variant of 
> http://www.web2pyslices.com/slices/take_slice/63
>
> cfh.
>
> On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>>
>> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>>
>>> How would one obtain the URL to a image blob stored on GAE's 
>>> datastore? A lot of the threads I've looked at were all for generating 
>>> an download output for views, but I need this for the Controller since 
>>> I'm returning this as a JSON element. 
>>>
>>> For example, the auth_user table has a field 'avatar' and another blob 
>>> field 'avatar_blob'. Ideally I can simply return a JSON like: 
>>> { "avatar": "http:avatars/username_avatar.gif" } 
>>>
>>> Where username_avatar.gif would map to the stored blob image for that 
>>> user's avatar.
>>
>>
>> Assuming you use web2py's standard "upload" field type to upload the 
>> images, then you would still use the standard download process as well. See 
>> the "Uploading files in database" section in 
>> http://web2py.com/books/default/chapter/29/13 for details on setting up 
>> database storage of uploads. And for downloading, see the 
>> response.download description here: 
>> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
>> would be something like:
>>
>> db.define_table('auth_user',
>> ...,
>> Field('avatar', 'upload', uploadfield='avatar_blob'),
>> Field('avatar_blob', 'blob'), ...)
>>
>> def download():
>> return response.download(request, db)
>>
>> URL for a particular user's avatar:
>>
>> URL('default', 'download', args=auth.user.avatar)
>>
>> Anthony
>>
>>
> On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>>
>> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>>
>>> How would one obtain the URL to a image blob stored on GAE's 
>>> datastore? A lot of the threads I've looked at were all for generating 
>>> an download output for views, but I need this for the Controller since 
>>> I'm returning this as a JSON element. 
>>>
>>> For example, the auth_user table has a field 'avatar' and another blob 
>>> field 'avatar_blob'. Ideally I can simply return a JSON like: 
>>> { "avatar": "http:avatars/username_avatar.gif" } 
>>>
>>> Where username_avatar.gif would map to the stored blob image for that 
>>> user's avatar.
>>
>>
>> Assuming you use web2py's standard "upload" field type to upload the 
>> images, then you would still use the standard download process as well. See 
>> the "Uploading files in database" section in 
>> http://web2py.com/books/default/chapter/29/13 for details on setting up 
>> database storage of uploads. And for downloading, see the 
>> response.download description here: 
>> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
>> would be something like:
>>
>> db.define_table('auth_user',
>> ...,
>> Field('avatar', 'upload', uploadfield='avatar_blob'),
>> Field('avatar_blob', 'blob'), ...)
>>
>> def download():
>> return response.download(request, db)
>>
>> URL for a particular user's avatar:
>>
>> URL('default', 'download', args=auth.user.avatar)
>>
>> Anthony
>>
>>
> On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>>
>> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>>
>>> How would one obtain the URL to a image blob stored on GAE's 
>>> datastore? A lot of the threads I've looked at were all for generating 
>>> an download output for views, but I need this for the Controller since 
>>> I'm returning t

[web2py] web2py hosting on dotcloud

2012-02-27 Thread cyan

Hi everyone,

I'm new to web2py framework, and would like to host some app on
dotcloud (dotcloud.com).

Apparently, people have managed to done this successfully, and I
wonder if someone could share their experience/procedure to deploy a
web2py app on dotcloud.

I've been trying to use dotcloud's CLI 0.4 to deploy just the plain
off-the-shelf web2py, but keep getting "uWSGI Error wsgi application
not found" when I go to the app url. I have the following setup:

funback/
  backend/
web2py/
wsgi.py -> ./web2py/wsgihandler.py
  dotcloud.yml
  README

and inside dotcloud.yml:

funback:
  approot: backend
  type: python
db:
  type: postgresql

Can anyone suggest a possible cause of the problem and the remedy to
fix it? Thanks a lot.


[web2py] Re: GaeGoogleAccount - error ?

2012-02-27 Thread howesc
i just had a client report this issue to me today as well.  sometime this 
week i'll be digging in to it - but it might not be today.

On Monday, February 27, 2012 11:40:46 AM UTC-8, Lazarof wrote:
>
> Hello group! 
> In application that worked well over a year I used: 
>
> # If running on Google App Engine 
> if request.env.web2py_runtime_gae: 
>gluon.contrib.login_methods.gae_google_account import from 
> GaeGoogleAccount 
>GaeGoogleAccount auth.settings.login_form = () 
>
> Now it is returning this error: 
> File "/ base/python_runtime/python_lib/versions/1/google/appengine/api/ 
> user_service_pb.py", line 236, in _CEncode 
>  _net_proto___parse__python.Encode return (self, 
> 'apphosting.CreateLoginURLRequest') 
> TypeError: expected string or Unicode object, XML found 
>
> Please who knows about this with GAE. 
> Lazaro.



Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Anthony
Also, keep in mind that "model-less" can mean many things. It doesn't 
necessarily entail the highly class-based approach you see in Bruno's 
Movuca. It could mean simply moving some standard table definitions from 
model files into functions in modules. In fact, I think Bruno's class-based 
design and the notion of "model-less" are largely orthogonal -- you can 
define classes in model files, and you can use a non-classed-based approach 
in modules.

Anthony

On Monday, February 27, 2012 4:14:09 PM UTC-5, rochacbruno wrote:
>
>
>
> On Mon, Feb 27, 2012 at 5:31 PM, pbreit  wrote:
>
>> I feel like if I'm going to try and learn model-less app development, 
>> it's time to re-evaluate other frameworks.
>
>
> I do not agree, web2py has a lot of features, executed "models" and global 
> scope are not the only good feature of web2py, we can have a very great 
> experience with all the web2py API even working with other frameworks. i.e: 
> I am using DAL with Tkinter and there are people using template engine with 
> bottle and wxhtml.
>
> Being self contained, having no need for configurations and the easy of 
> deployment + the best DAL, the best template engine, very great 
> documentation and a lot of helpers have *better value* than the executed 
> models approach.
>
> If you think the only good thing in web2py is the "models" approach, I 
> think its time to re-evaluate web2py to see all the other good features it 
> has.
>
> There are nothing strange or hard-to-learn in model less approach, it is 
> only object oriented programming and pure Python, I think experienced 
> web2py developers have to know Python O.O at some stage.
>
> O.O, modules, Classes, Methods, Inheritance, Instances, Namespaces etc.. 
> what is strange on this programming approach?
>
> IMO: if you think that the use of modules is difficulty, it is time to 
> re-evaluate Python as a language.
>
> BTW, It is always the time to evaluate other frameworks, you do not have 
> to rely in only one tool, web2py is great and for me is the best! but 
> Pyramid is also great, Django is great and Flask, Bottle etc.. all good 
> frameworks, It is very nice to give a try to everyone of them!
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

Re: [web2py] oauth 2.0 and facebook "expires" parameter

2012-02-27 Thread Michele Comitini
Hi Can,

FB used to send a non standard parameter "expires_in", did they change it?
Here is the code that should handle "expires_in":

https://github.com/mdipierro/web2py/blob/master/gluon/contrib/login_methods/oauth20_account.py#L124

mic


Il giorno 26 febbraio 2012 12:15, Can Candan  ha
scritto:

> It appears facebook does not return the 'expires' parameter for web
> page sign on, however the code in
> oauth20_account.py does not take into account this case. Should it
> handle that or am I missing something?


Re: [web2py] Re: db select with left but concatenated orderby fields?

2012-02-27 Thread Richard Vézina
Forget about that my mistakes... I should use field proper type (integer)...

Richard

On Mon, Feb 27, 2012 at 3:42 PM, Richard Vézina  wrote:

> I think there is problem with orderby here too...
>
> I have a field that contain those data :
>
> f1
> row1 : 172
> row2 : 1212
>
> Then
>
> db.table2.fied1table2.requires = IS_IN_DB(db,
> 'table.f1','%(f1)s',orderby=('f1'))
>
> I never get the proper order of table1 rows...
>
> 1212, 172 in my dropbox instead of 172, 1212...
>
> Richard
>
>
>
> On Sun, Jan 22, 2012 at 6:57 PM, Carlos  wrote:
>
>> It now accepts that operator (without errors), but it's not ordering the
>> rows correctly.
>>
>> Any ideas?, thanks.
>>
>>
>


Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Bruno Rocha
On Mon, Feb 27, 2012 at 5:31 PM, pbreit  wrote:

> I feel like if I'm going to try and learn model-less app development, it's
> time to re-evaluate other frameworks.


I do not agree, web2py has a lot of features, executed "models" and global
scope are not the only good feature of web2py, we can have a very great
experience with all the web2py API even working with other frameworks. i.e:
I am using DAL with Tkinter and there are people using template engine with
bottle and wxhtml.

Being self contained, having no need for configurations and the easy of
deployment + the best DAL, the best template engine, very great
documentation and a lot of helpers have *better value* than the executed
models approach.

If you think the only good thing in web2py is the "models" approach, I
think its time to re-evaluate web2py to see all the other good features it
has.

There are nothing strange or hard-to-learn in model less approach, it is
only object oriented programming and pure Python, I think experienced
web2py developers have to know Python O.O at some stage.

O.O, modules, Classes, Methods, Inheritance, Instances, Namespaces etc..
what is strange on this programming approach?

IMO: if you think that the use of modules is difficulty, it is time to
re-evaluate Python as a language.

BTW, It is always the time to evaluate other frameworks, you do not have to
rely in only one tool, web2py is great and for me is the best! but Pyramid
is also great, Django is great and Flask, Bottle etc.. all good frameworks,
It is very nice to give a try to everyone of them!

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Massimo Di Pierro
you need to put it in the dict so the view can see it.

On Feb 27, 2:57 pm, Paul  wrote:
> One last part of the puzzle, this all works ok at the command line
> with print row[mysum] but I cannot get the syntax for using this in a
> view
>
> for example:-
>
> controller DAL query:-
> def mileage():
>     mysum = db.t_appointment.miles_to.sum()
> +db.t_appointment.miles_from.sum()
>     groupmm = db.t_appointment.f_start_time.year()|
> db.t_appointment.f_start_time.month()
>     rows = db().select(
>         mysum,
>         db.t_appointment.f_start_time.year(),
>         db.t_appointment.f_start_time.month(),
>     groupby=groupmm)
>
>     return dict(rows=rows, sql = db._lastsql)
>
> IN VIEW:
> {{for row in rows:}}
>  {{=row[mysum]}}
>  {{pass}}
>
> I get NameError: name 'mysum' is not defined
>
> If I try:
>
> {{for row in rows:}}
>  {{=row['mysum']}}
>  {{pass}}
>
> I get:
>
> Traceback (most recent call last):
>   File "D:\web2py-src\web2py\gluon\restricted.py", line 194, in
> restricted
>     exec ccode in environment
>   File "D:\web2py-src\web2py\applications\caltest\views\info/
> mileage.html", line 105, in 
>   File "D:\web2py-src\web2py\gluon\dal.py", line 4331, in __getitem__
>     return dict.__getitem__(self, key)
> KeyError: 'mysum'
>
> On Feb 27, 2:08 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > > That syntax works and I can use that to refer to the data, I could see
> > > that a row object had an '_extra' dict for the selected expressions
> > > but could not see that the data could be referred to be the name of
> > > the expression 'mysum' (its in there somewhere but not sure where!!)
>
> > The book example does show that usage:
>
> > >>> sum = db.log.severity.sum()
> > >>> print db().select(sum).first()[sum]
>
> > Actually, when you do row[mysum], the __getitem__ method of the Row object
> > automatically does row[str(mysum)]. Since mysum is a DAL Expression object,
> > its __str__ method converts it to the SQL syntax for the particular
> > database adapter you are using, which in this case is 
> > "(SUM(t_appointment.miles_to)
> > + SUM(t_appointment.miles_from))". The Row __getitem__ method first looks
> > for that key in its _extra dict and returns the value if found. So, when
> > you do:
>
> > row[mysum]
>
> > This is essentially what is happening behind the scenes:
>
> >    1. row[str(mysum)]
> >    2. row['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))']
> >    3. row['_extra']['(SUM(t_appointment.miles_to) +
> >    SUM(t_appointment.miles_from))']
>
> > Anthony


[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Anthony
The view only sees what you explicitly pass to it from the controller via 
the returned dictionary, so you would need to do:

def mileage():
[snip]
return dict(rows=rows, mysum=mysum, sql=db._lastsql) 

Or you could just do:

return locals()

which returns a dictionary of all the local variables defined in mileage().

Anthony

On Monday, February 27, 2012 3:57:25 PM UTC-5, Paul wrote:
>
> One last part of the puzzle, this all works ok at the command line 
> with print row[mysum] but I cannot get the syntax for using this in a 
> view 
>
> for example:- 
>
> controller DAL query:- 
> def mileage(): 
> mysum = db.t_appointment.miles_to.sum() 
> +db.t_appointment.miles_from.sum() 
> groupmm = db.t_appointment.f_start_time.year()| 
> db.t_appointment.f_start_time.month() 
> rows = db().select( 
> mysum, 
> db.t_appointment.f_start_time.year(), 
> db.t_appointment.f_start_time.month(), 
> groupby=groupmm) 
>
> return dict(rows=rows, sql = db._lastsql) 
>
> IN VIEW: 
> {{for row in rows:}} 
>  {{=row[mysum]}} 
>  {{pass}} 
>
> I get NameError: name 'mysum' is not defined 
>
> If I try: 
>
> {{for row in rows:}} 
>  {{=row['mysum']}} 
>  {{pass}} 
>
> I get: 
>
> Traceback (most recent call last): 
>   File "D:\web2py-src\web2py\gluon\restricted.py", line 194, in 
> restricted 
> exec ccode in environment 
>   File "D:\web2py-src\web2py\applications\caltest\views\info/ 
> mileage.html", line 105, in  
>   File "D:\web2py-src\web2py\gluon\dal.py", line 4331, in __getitem__ 
> return dict.__getitem__(self, key) 
> KeyError: 'mysum' 
>
> On Feb 27, 2:08 pm, Anthony  wrote: 
> > > That syntax works and I can use that to refer to the data, I could see 
> > > that a row object had an '_extra' dict for the selected expressions 
> > > but could not see that the data could be referred to be the name of 
> > > the expression 'mysum' (its in there somewhere but not sure where!!) 
> > 
> > The book example does show that usage: 
> > 
> > >>> sum = db.log.severity.sum() 
> > >>> print db().select(sum).first()[sum] 
> > 
> > Actually, when you do row[mysum], the __getitem__ method of the Row 
> object 
> > automatically does row[str(mysum)]. Since mysum is a DAL Expression 
> object, 
> > its __str__ method converts it to the SQL syntax for the particular 
> > database adapter you are using, which in this case is 
> "(SUM(t_appointment.miles_to) 
> > + SUM(t_appointment.miles_from))". The Row __getitem__ method first 
> looks 
> > for that key in its _extra dict and returns the value if found. So, when 
> > you do: 
> > 
> > row[mysum] 
> > 
> > This is essentially what is happening behind the scenes: 
> > 
> >1. row[str(mysum)] 
> >2. row['(SUM(t_appointment.miles_to) + 
> SUM(t_appointment.miles_from))'] 
> >3. row['_extra']['(SUM(t_appointment.miles_to) + 
> >SUM(t_appointment.miles_from))'] 
> > 
> > Anthony



[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Paul
One last part of the puzzle, this all works ok at the command line
with print row[mysum] but I cannot get the syntax for using this in a
view

for example:-

controller DAL query:-
def mileage():
mysum = db.t_appointment.miles_to.sum()
+db.t_appointment.miles_from.sum()
groupmm = db.t_appointment.f_start_time.year()|
db.t_appointment.f_start_time.month()
rows = db().select(
mysum,
db.t_appointment.f_start_time.year(),
db.t_appointment.f_start_time.month(),
groupby=groupmm)

return dict(rows=rows, sql = db._lastsql)

IN VIEW:
{{for row in rows:}}
 {{=row[mysum]}}
 {{pass}}

I get NameError: name 'mysum' is not defined

If I try:

{{for row in rows:}}
 {{=row['mysum']}}
 {{pass}}

I get:

Traceback (most recent call last):
  File "D:\web2py-src\web2py\gluon\restricted.py", line 194, in
restricted
exec ccode in environment
  File "D:\web2py-src\web2py\applications\caltest\views\info/
mileage.html", line 105, in 
  File "D:\web2py-src\web2py\gluon\dal.py", line 4331, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'mysum'

On Feb 27, 2:08 pm, Anthony  wrote:
> > That syntax works and I can use that to refer to the data, I could see
> > that a row object had an '_extra' dict for the selected expressions
> > but could not see that the data could be referred to be the name of
> > the expression 'mysum' (its in there somewhere but not sure where!!)
>
> The book example does show that usage:
>
> >>> sum = db.log.severity.sum()
> >>> print db().select(sum).first()[sum]
>
> Actually, when you do row[mysum], the __getitem__ method of the Row object
> automatically does row[str(mysum)]. Since mysum is a DAL Expression object,
> its __str__ method converts it to the SQL syntax for the particular
> database adapter you are using, which in this case is 
> "(SUM(t_appointment.miles_to)
> + SUM(t_appointment.miles_from))". The Row __getitem__ method first looks
> for that key in its _extra dict and returns the value if found. So, when
> you do:
>
> row[mysum]
>
> This is essentially what is happening behind the scenes:
>
>    1. row[str(mysum)]
>    2. row['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))']
>    3. row['_extra']['(SUM(t_appointment.miles_to) +
>    SUM(t_appointment.miles_from))']
>
> Anthony


Re: [web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Bruce Wade
User is logged in, it works on other URLs.

Anthony, thanks for explaining how URL works, changing the URL to use args
has solved the problem.

On Mon, Feb 27, 2012 at 12:07 PM, Anthony  wrote:

> In
>
> URL('adviewer', 's**avesettings/location', user_signature=True)
>
> the URL() function sees function='savesettings/location' and args=None.
> However, when a request is made to the URL generated by the above, the
> function that verifies the signature sees function='savesettings' and
> args='location'. The problem is, function='savesettings' and
> args='location' does not generate the same signature as
> function='savesettings/location' and args=None. The reason is that when
> generating the signature, the extension is first added to the function
> before concatenating the args, so when the signature is first generated, it
> is a hash of a URL that includes "/savesettings/location.html", but when
> verified, the signature is a hash of a URL that includes
> "/savesettings.html/location". Therefore, the hashes won't match because
> they are created from different strings.
>
> Is there any reason you are using the above rather than:
>
> URL('adviewer', 's**avesettings', args='location', user_signature=True)
>
> which is really the correct way to use the URL() function? If you
> explicitly specify "location" as the args argument to URL(), I think it
> should work.
>
> Anthony
>
>
> On Monday, February 27, 2012 1:22:25 PM UTC-5, Detectedstealth wrote:
>>
>> Ok it looks like the bug is related to:
>>
>> URL('action/additional_parms', user_signature=True) if you have something
>> in addition to the action @auth.requires_signature fails.
>>
>> When using: FORM(_action=URL('adviewer','s**avesettings/location',
>> user_signature=True)) or redirect(URL('payment/%s' %
>> has_unpaid_orders.access_key, user_signature=True)) with
>> @auth.requires_signature() on the action it fails with access denied.
>>
>> On Wed, Feb 22, 2012 at 3:19 PM, Bruce Wade  wrote:
>>
>>> When using user_signature=True in a form that action goes to another
>>> method and that method has @auth.requires_signature I am getting access
>>> denied, if I remove the @auth.requires_signature I still see the signature
>>> but don't have the access denied message.
>>>
>>> FORM:
>>> # adviewer.viewads();
>>>
>>> locationform=FORM(
>>> DIV(
>>> SELECT(countries_options,_id='**by-country',_name='country',
>>> _onchange="updateProvinces(**this)", value=selected_country),
>>> _id='country_options', _class='filter-selects'
>>> ),
>>> DIV(
>>> SELECT(provinces_options,_id='**by-province',
>>> _name='province_state',_**onchange="updateCities(this)",
>>> value=selected_province),
>>> _id='province_options', _class='filter-selects'
>>> ),
>>> DIV(SELECT(
>>> cities_options,_id='by-**province', _name='city',
>>> value=selected_city),
>>> _id='city_options', _class='filter-selects'
>>> ),
>>> DIV(_class='clear'),
>>> INPUT(_type='submit', _value='Save', _class='filter-btn'),
>>> _name='locationform',
>>> _action=URL('adviewer','**savesettings/location',
>>> user_signature=True)
>>> )
>>>
>>> Capture Method:
>>> # adviewer.savesettings()
>>> // URL submitted to this method: http://127.0.0.1:8000/**
>>> zh/adviewer/savesettings/**location?_signature=**
>>> 82ef7150a3c6eaac57032c8bd943b4**2789828025
>>> @auth.requires_login()
>>> @auth.requires_signature()  # If I remove this there is no access denied.
>>> def savesettings():
>>> print request.vars
>>> print request.args(0)
>>> from youadAPI.adviewer_api import AdViewerEngine
>>> if request.args(0) == 'location':
>>> adviewer_engine.update_or_**create_adviewer_settings(
>>> AdViewerEngine.location,
>>> dict(
>>>  country=request.vars['**country'],
>>>  province=request.vars['**province_state'],
>>>  city=request.vars['city']
>>> )
>>> )
>>> elif request.args(0) == 'language':
>>> adviewer_engine.update_or_**create_adviewer_settings(
>>> AdViewerEngine.language,
>>> dict(
>>> language = request.vars['language']
>>> )
>>> )
>>> elif request.args(0) == 'keywords':
>>> adviewer_engine.update_or_**create_adviewer_settings(
>>> AdViewerEngine.keywords,
>>> dict(
>>> keywords = request.vars['keywords']
>>> )
>>> )
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade
>>> http://www.wadecybertech.com
>>> http://www.warplydesigned.com
>>> http://www.**fitnessfriendsfinder.com
>>>
>>
>>
>>
>> --
>> --
>> Re

Re: [web2py] Re: db select with left but concatenated orderby fields?

2012-02-27 Thread Richard Vézina
I think there is problem with orderby here too...

I have a field that contain those data :

f1
row1 : 172
row2 : 1212

Then

db.table2.fied1table2.requires = IS_IN_DB(db,
'table.f1','%(f1)s',orderby=('f1'))

I never get the proper order of table1 rows...

1212, 172 in my dropbox instead of 172, 1212...

Richard



On Sun, Jan 22, 2012 at 6:57 PM, Carlos  wrote:

> It now accepts that operator (without errors), but it's not ordering the
> rows correctly.
>
> Any ideas?, thanks.
>
>


Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread pbreit
I feel like if I'm going to try and learn model-less app development, it's 
time to re-evaluate other frameworks.

[web2py] Re: Time Substraction

2012-02-27 Thread Ross Peoples
Well, one of the issues is going to be that you are using 'date' for your 
fields instead of 'datetime'. When using 'datetime', it becomes easy to do 
something like this:

delta = row.employee_logout_date - row.employee_login_date
minutes = delta.minutes + (delta.hours * 60)

On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>
> I am going to develop the time management sheet for that i have the one 
> table name employee table and i am allready taken the login and logout time 
> and i want to substract the time when i substract the time it show me in 
> nanoseconds when i convert this nanosecond to the minute it totally 
> confused me so if any one have solution please help me following is my 
> controller and database :-
> *
> Table:-*
>
> db.define_table('employee_detail',
> Field('employee_id'),
> Field('employee_name'),
> Field('employee_login_date','date'),
> Field('employee_logout_date','date'),
> Field('employee_login_time'),
> Field('employee_logout_time'),
> Field('total_time'))*
>
> Controller:-*
>
> def lgin(form):
> import datetime
> import time
> currentdate=datetime.date.today()
> now = time.localtime(time.time())
> session.sttime=time.time()
> currenttime = time.strftime("%H:%M:%S", now)
> session.time = currenttime
> #response.flash=currentdate
> for row in db(db.auth_user.email == 
> auth.user.email).select(db.auth_user.first_name):
> firstname=row.first_name
> db.employee_detail.insert(employee_id = auth.user.email, 
> employee_name=firstname, employee_login_date=currentdate, 
> employee_login_time=currenttime)
> return '' 
>  
> def lgout(usr): 
> import datetime
> import time
> currentdate=datetime.date.today()
> now = time.localtime(time.time())
> ettime=time.time()
> duration = ettime-session.sttime
> du = str(duration / 600)
> currenttime = time.strftime("%H:%M:%S", now) 
> db((db.employee_detail.employee_id == auth.user.email) & 
> (db.employee_detail.employee_login_date == currentdate) & 
> (db.employee_detail.employee_login_time == 
> session.time)).update(employee_logout_date=currentdate, 
> employee_logout_time=currenttime, total_time=du)  
> return '' 
>
>
>
On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>
> I am going to develop the time management sheet for that i have the one 
> table name employee table and i am allready taken the login and logout time 
> and i want to substract the time when i substract the time it show me in 
> nanoseconds when i convert this nanosecond to the minute it totally 
> confused me so if any one have solution please help me following is my 
> controller and database :-
> *
> Table:-*
>
> db.define_table('employee_detail',
> Field('employee_id'),
> Field('employee_name'),
> Field('employee_login_date','date'),
> Field('employee_logout_date','date'),
> Field('employee_login_time'),
> Field('employee_logout_time'),
> Field('total_time'))*
>
> Controller:-*
>
> def lgin(form):
> import datetime
> import time
> currentdate=datetime.date.today()
> now = time.localtime(time.time())
> session.sttime=time.time()
> currenttime = time.strftime("%H:%M:%S", now)
> session.time = currenttime
> #response.flash=currentdate
> for row in db(db.auth_user.email == 
> auth.user.email).select(db.auth_user.first_name):
> firstname=row.first_name
> db.employee_detail.insert(employee_id = auth.user.email, 
> employee_name=firstname, employee_login_date=currentdate, 
> employee_login_time=currenttime)
> return '' 
>  
> def lgout(usr): 
> import datetime
> import time
> currentdate=datetime.date.today()
> now = time.localtime(time.time())
> ettime=time.time()
> duration = ettime-session.sttime
> du = str(duration / 600)
> currenttime = time.strftime("%H:%M:%S", now) 
> db((db.employee_detail.employee_id == auth.user.email) & 
> (db.employee_detail.employee_login_date == currentdate) & 
> (db.employee_detail.employee_login_time == 
> session.time)).update(employee_logout_date=currentdate, 
> employee_logout_time=currenttime, total_time=du)  
> return '' 
>
>
>
On Monday, February 27, 2012 11:54:56 AM UTC-5, Sanjeet Kumar wrote:
>
> I am going to develop the time management sheet for that i have the one 
> table name employee table and i am allready taken the login and logout time 
> and i want to substract the time when i substract the time it show me in 
> nanoseconds when i convert this nanosecond to the minute it totally 
> confused me so if any one have solution please help me following is my 
> controller and database :-
> *
> Table:-*
>
> db.define_table('employee_detail',
> Field('e

[web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Anthony
In

URL('adviewer', 'savesettings/location', user_signature=True)

the URL() function sees function='savesettings/location' and args=None. 
However, when a request is made to the URL generated by the above, the 
function that verifies the signature sees function='savesettings' and 
args='location'. The problem is, function='savesettings' and 
args='location' does not generate the same signature as 
function='savesettings/location' and args=None. The reason is that when 
generating the signature, the extension is first added to the function 
before concatenating the args, so when the signature is first generated, it 
is a hash of a URL that includes "/savesettings/location.html", but when 
verified, the signature is a hash of a URL that includes 
"/savesettings.html/location". Therefore, the hashes won't match because 
they are created from different strings.

Is there any reason you are using the above rather than:

URL('adviewer', 'savesettings', args='location', user_signature=True) 

which is really the correct way to use the URL() function? If you 
explicitly specify "location" as the args argument to URL(), I think it 
should work.

Anthony

On Monday, February 27, 2012 1:22:25 PM UTC-5, Detectedstealth wrote:
>
> Ok it looks like the bug is related to:
>
> URL('action/additional_parms', user_signature=True) if you have something 
> in addition to the action @auth.requires_signature fails.
>
> When using: FORM(_action=URL('adviewer','savesettings/location', 
> user_signature=True)) or redirect(URL('payment/%s' % 
> has_unpaid_orders.access_key, user_signature=True)) with 
> @auth.requires_signature() on the action it fails with access denied. 
>
> On Wed, Feb 22, 2012 at 3:19 PM, Bruce Wade  wrote:
>
>> When using user_signature=True in a form that action goes to another 
>> method and that method has @auth.requires_signature I am getting access 
>> denied, if I remove the @auth.requires_signature I still see the signature 
>> but don't have the access denied message.
>>
>> FORM: 
>> # adviewer.viewads();
>>
>> locationform=FORM(
>> DIV(
>> SELECT(countries_options,_id='by-country',_name='country', 
>> _onchange="updateProvinces(this)", value=selected_country),
>> _id='country_options', _class='filter-selects'
>> ),
>> DIV(
>> SELECT(provinces_options,_id='by-province', 
>> _name='province_state',_onchange="updateCities(this)", 
>> value=selected_province),
>> _id='province_options', _class='filter-selects' 
>> ),
>> DIV(SELECT(
>> cities_options,_id='by-province', _name='city', 
>> value=selected_city),
>> _id='city_options', _class='filter-selects' 
>> ),
>> DIV(_class='clear'),
>> INPUT(_type='submit', _value='Save', _class='filter-btn'),
>> _name='locationform',
>> _action=URL('adviewer','savesettings/location', 
>> user_signature=True)
>> )
>>
>> Capture Method:
>> # adviewer.savesettings()
>> // URL submitted to this method: 
>> http://127.0.0.1:8000/zh/adviewer/savesettings/location?_signature=82ef7150a3c6eaac57032c8bd943b42789828025
>> @auth.requires_login()
>> @auth.requires_signature()  # If I remove this there is no access denied.
>> def savesettings():
>> print request.vars
>> print request.args(0)
>> from youadAPI.adviewer_api import AdViewerEngine
>> if request.args(0) == 'location':
>> adviewer_engine.update_or_create_adviewer_settings(
>> AdViewerEngine.location, 
>> dict(
>>  country=request.vars['country'], 
>>  province=request.vars['province_state'],
>>  city=request.vars['city']
>> )
>> )
>> elif request.args(0) == 'language':
>> adviewer_engine.update_or_create_adviewer_settings(
>> AdViewerEngine.language,
>> dict(
>> language = request.vars['language']
>> ) 
>> )
>> elif request.args(0) == 'keywords':
>> adviewer_engine.update_or_create_adviewer_settings(
>> AdViewerEngine.keywords,
>> dict(
>> keywords = request.vars['keywords'] 
>> )
>> )
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>  
>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  


[web2py] Re: Obtaining URL to image blob in GAE

2012-02-27 Thread howesc
i'm using the blobstore so i can upload images larger than 1mb.  because of 
that i have access to 
http://code.google.com/appengine/docs/python/images/functions.html#Image_get_serving_url
 
which gives a URL that google serves up the image (and does not count 
against CPU for your app engine app).

my image upload is a variant of 
http://www.web2pyslices.com/slices/take_slice/63

cfh.

On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>
> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>
>> How would one obtain the URL to a image blob stored on GAE's 
>> datastore? A lot of the threads I've looked at were all for generating 
>> an download output for views, but I need this for the Controller since 
>> I'm returning this as a JSON element. 
>>
>> For example, the auth_user table has a field 'avatar' and another blob 
>> field 'avatar_blob'. Ideally I can simply return a JSON like: 
>> { "avatar": "http:avatars/username_avatar.gif" } 
>>
>> Where username_avatar.gif would map to the stored blob image for that 
>> user's avatar.
>
>
> Assuming you use web2py's standard "upload" field type to upload the 
> images, then you would still use the standard download process as well. See 
> the "Uploading files in database" section in 
> http://web2py.com/books/default/chapter/29/13 for details on setting up 
> database storage of uploads. And for downloading, see the 
> response.download description here: 
> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
> would be something like:
>
> db.define_table('auth_user',
> ...,
> Field('avatar', 'upload', uploadfield='avatar_blob'),
> Field('avatar_blob', 'blob'), ...)
>
> def download():
> return response.download(request, db)
>
> URL for a particular user's avatar:
>
> URL('default', 'download', args=auth.user.avatar)
>
> Anthony
>
>
On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>
> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>
>> How would one obtain the URL to a image blob stored on GAE's 
>> datastore? A lot of the threads I've looked at were all for generating 
>> an download output for views, but I need this for the Controller since 
>> I'm returning this as a JSON element. 
>>
>> For example, the auth_user table has a field 'avatar' and another blob 
>> field 'avatar_blob'. Ideally I can simply return a JSON like: 
>> { "avatar": "http:avatars/username_avatar.gif" } 
>>
>> Where username_avatar.gif would map to the stored blob image for that 
>> user's avatar.
>
>
> Assuming you use web2py's standard "upload" field type to upload the 
> images, then you would still use the standard download process as well. See 
> the "Uploading files in database" section in 
> http://web2py.com/books/default/chapter/29/13 for details on setting up 
> database storage of uploads. And for downloading, see the 
> response.download description here: 
> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
> would be something like:
>
> db.define_table('auth_user',
> ...,
> Field('avatar', 'upload', uploadfield='avatar_blob'),
> Field('avatar_blob', 'blob'), ...)
>
> def download():
> return response.download(request, db)
>
> URL for a particular user's avatar:
>
> URL('default', 'download', args=auth.user.avatar)
>
> Anthony
>
>
On Sunday, February 26, 2012 6:13:14 AM UTC-8, Anthony wrote:
>
> On Sunday, February 26, 2012 12:19:17 AM UTC-5, Peter G. wrote:
>>
>> How would one obtain the URL to a image blob stored on GAE's 
>> datastore? A lot of the threads I've looked at were all for generating 
>> an download output for views, but I need this for the Controller since 
>> I'm returning this as a JSON element. 
>>
>> For example, the auth_user table has a field 'avatar' and another blob 
>> field 'avatar_blob'. Ideally I can simply return a JSON like: 
>> { "avatar": "http:avatars/username_avatar.gif" } 
>>
>> Where username_avatar.gif would map to the stored blob image for that 
>> user's avatar.
>
>
> Assuming you use web2py's standard "upload" field type to upload the 
> images, then you would still use the standard download process as well. See 
> the "Uploading files in database" section in 
> http://web2py.com/books/default/chapter/29/13 for details on setting up 
> database storage of uploads. And for downloading, see the 
> response.download description here: 
> http://web2py.com/books/default/chapter/29/4#response. In your case, it 
> would be something like:
>
> db.define_table('auth_user',
> ...,
> Field('avatar', 'upload', uploadfield='avatar_blob'),
> Field('avatar_blob', 'blob'), ...)
>
> def download():
> return response.download(request, db)
>
> URL for a particular user's avatar:
>
> URL('default', 'download', args=auth.user.avatar)
>
> Anthony
>
>

[web2py] GaeGoogleAccount - error ?

2012-02-27 Thread Lazarof
Hello group!
In application that worked well over a year I used:

# If running on Google App Engine
if request.env.web2py_runtime_gae:
   gluon.contrib.login_methods.gae_google_account import from
GaeGoogleAccount
   GaeGoogleAccount auth.settings.login_form = ()

Now it is returning this error:
File "/ base/python_runtime/python_lib/versions/1/google/appengine/api/
user_service_pb.py", line 236, in _CEncode
 _net_proto___parse__python.Encode return (self,
'apphosting.CreateLoginURLRequest')
TypeError: expected string or Unicode object, XML found

Please who knows about this with GAE.
Lazaro.


[web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Massimo Di Pierro
Is the user logged in? If the user is not logged in this is the
intended behavior.

Massimo

On Feb 22, 5:19 pm, Bruce Wade  wrote:
> When using user_signature=True in a form that action goes to another method
> and that method has @auth.requires_signature I am getting access denied, if
> I remove the @auth.requires_signature I still see the signature but don't
> have the access denied message.
>
> FORM:
> # adviewer.viewads();
>
> locationform=FORM(
>         DIV(
>             SELECT(countries_options,_id='by-country',_name='country',
> _onchange="updateProvinces(this)", value=selected_country),
>             _id='country_options', _class='filter-selects'
>         ),
>         DIV(
>             SELECT(provinces_options,_id='by-province',
> _name='province_state',_onchange="updateCities(this)",
> value=selected_province),
>             _id='province_options', _class='filter-selects'
>         ),
>         DIV(SELECT(
>             cities_options,_id='by-province', _name='city',
> value=selected_city),
>             _id='city_options', _class='filter-selects'
>         ),
>         DIV(_class='clear'),
>         INPUT(_type='submit', _value='Save', _class='filter-btn'),
>         _name='locationform',
>         _action=URL('adviewer','savesettings/location', user_signature=True)
>     )
>
> Capture Method:
> # adviewer.savesettings()
> // URL submitted to this 
> method:http://127.0.0.1:8000/zh/adviewer/savesettings/location?_signature=82...
> @auth.requires_login()
> @auth.requires_signature()  # If I remove this there is no access denied.
> def savesettings():
>     print request.vars
>     print request.args(0)
>     from youadAPI.adviewer_api import AdViewerEngine
>     if request.args(0) == 'location':
>         adviewer_engine.update_or_create_adviewer_settings(
>             AdViewerEngine.location,
>             dict(
>                  country=request.vars['country'],
>                  province=request.vars['province_state'],
>                  city=request.vars['city']
>             )
>         )
>     elif request.args(0) == 'language':
>         adviewer_engine.update_or_create_adviewer_settings(
>             AdViewerEngine.language,
>             dict(
>                 language = request.vars['language']
>             )
>         )
>     elif request.args(0) == 'keywords':
>         adviewer_engine.update_or_create_adviewer_settings(
>             AdViewerEngine.keywords,
>             dict(
>                 keywords = request.vars['keywords']
>             )
>         )
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: compute on update

2012-02-27 Thread Massimo Di Pierro
Please open a ticket. I may fix this later today.

On Feb 27, 4:10 am, Mirek Zvolský  wrote:
> > I think the behaviour of "compute=" is not good. Most people need
> > calculated field which ALWAYS follow the source values and not just ONCE.
> > So I have found in google group, lot of people fall through the time in
> > same problem and there is still no clear solution.
>
> > I now need this for Markmin source and calculated Html output (both fields
> > in same table)
> > I have solved this so:
> > ...Field('html', compute = lambda row: MARKMIN(row.markmin).xml())...
> > and in addition I use "onaccept" method in form:
> > def post_forcecompute(form):
> >     row = db.post(form.vars.id)
> >     row.update_record(html=db.post.html.compute(row))
> > crud_post.settings.update_onaccept = post_forcecompute
>
> > This works, however it is not very good workaround, because it is
> > neccessary to solve it in form, instead of in the model :(
>
> > Mirek


[web2py] Re: Web2py Scheduler

2012-02-27 Thread Massimo Di Pierro
web2py has a built-in scheduler:
http://web2py.com/books/default/chapter/29/4?search=scheduler#Scheduler-(experimental)

On Feb 27, 3:43 am, VIREN PATEL  wrote:
> Hi,
>
> I need to implement the Scheduler and Job Queues at the application level.
> Please suggest some good Schedulers.
> Also if any one has implemented the schedulers in web2py
>
> Thanks,
> Viren


[web2py] Re: Markmin small problems

2012-02-27 Thread Massimo Di Pierro
Please open ticket on google code. I agree this should be fixed.

On Feb 27, 3:34 am, Mirek Zvolský  wrote:
> I'm using markmin2html.py.
>
> Tables & Blockquotes need to have at least one \n before and one \n after.
>
> When the table or blockquote is on the begin or end of the source string,
> workaround is easy:
> markmin2html("\n" + src + "\n")
> will recognize the table properly.
>
> But inside the text, if 2 blockqutes, 2 tables, or 1table/1blockquote
> follow immediately, the second one is not recognized.
> Easy to test this, if you have Instantpress installed:
> 
> aaa
> 
> 
> bbb
> 
> generates: aaabbb
>
> For developer there is no problem to add one Enter between. But I think
> Markmin is designed for standard users (like in Instantpress), who can have
> problems.
>
> Mirek


Re: [web2py] Re: cron setup

2012-02-27 Thread Bruno Rocha
thanks Luciano! I will migrate your recipe to the new web2pyslices website.

http://zerp.ly/rochacbruno
Em 27/02/2012 09:16, "Luciano Pacheco"  escreveu:

> Example:
>
> http://movu.ca/demo/article/show/31/web2py-cron-task
>
> My first try in movu.ca :-)
>
> On Mon, Feb 27, 2012 at 2:32 PM, Sanjeet Kumar wrote:
>
>> Exactly I need the examples
>>
>>
>> On Mon, Feb 27, 2012 at 4:56 AM, Luciano Pacheco wrote:
>>
>>> I think Sanjeet means, I example of the task.
>>>
>>> What is a good practice in the task, or what kind of variables are
>>> present in the local namespace "automagically", etc. A task should be a
>>> class a function, a python module?
>>>
>>> I had the same question last week when I was reading this chapter. :-)
>>>
>>> Regards,
>>> --
>>> Luciano Pacheco
>>> blog.lucmult.com.br
>>>
>>> On Mon, Feb 27, 2012 at 10:08 AM, Alan Etkin  wrote:
>>>
 It's all in the book (if you haven't seen yet)

 http://web2py.com/books/default/chapter/29/4#Cron

 By the way, The link in web2py to cron (http://web2py.com/books/
 default/reference/29/cron)
 is broken (returns an invalid function
 message)

 On 26 feb, 13:09, Sanjeet Kumar  wrote:
 > Can anyone give me the brief description to how I set the cron to run
 the
 > task in background with example.

>>>
>>>
>>>
>>>
>>
>
>
> --
> Luciano Pacheco
> blog.lucmult.com.br
>


[web2py] Re: Possible bug with user_signature?

2012-02-27 Thread Bruce Wade
Ok it looks like the bug is related to:

URL('action/additional_parms', user_signature=True) if you have something
in addition to the action @auth.requires_signature fails.

When using: FORM(_action=URL('adviewer','savesettings/location',
user_signature=True)) or redirect(URL('payment/%s' %
has_unpaid_orders.access_key, user_signature=True)) with
@auth.requires_signature() on the action it fails with access denied.

On Wed, Feb 22, 2012 at 3:19 PM, Bruce Wade  wrote:

> When using user_signature=True in a form that action goes to another
> method and that method has @auth.requires_signature I am getting access
> denied, if I remove the @auth.requires_signature I still see the signature
> but don't have the access denied message.
>
> FORM:
> # adviewer.viewads();
>
> locationform=FORM(
> DIV(
> SELECT(countries_options,_id='by-country',_name='country',
> _onchange="updateProvinces(this)", value=selected_country),
> _id='country_options', _class='filter-selects'
> ),
> DIV(
> SELECT(provinces_options,_id='by-province',
> _name='province_state',_onchange="updateCities(this)",
> value=selected_province),
> _id='province_options', _class='filter-selects'
> ),
> DIV(SELECT(
> cities_options,_id='by-province', _name='city',
> value=selected_city),
> _id='city_options', _class='filter-selects'
> ),
> DIV(_class='clear'),
> INPUT(_type='submit', _value='Save', _class='filter-btn'),
> _name='locationform',
> _action=URL('adviewer','savesettings/location',
> user_signature=True)
> )
>
> Capture Method:
> # adviewer.savesettings()
> // URL submitted to this method:
> http://127.0.0.1:8000/zh/adviewer/savesettings/location?_signature=82ef7150a3c6eaac57032c8bd943b42789828025
> @auth.requires_login()
> @auth.requires_signature()  # If I remove this there is no access denied.
> def savesettings():
> print request.vars
> print request.args(0)
> from youadAPI.adviewer_api import AdViewerEngine
> if request.args(0) == 'location':
> adviewer_engine.update_or_create_adviewer_settings(
> AdViewerEngine.location,
> dict(
>  country=request.vars['country'],
>  province=request.vars['province_state'],
>  city=request.vars['city']
> )
> )
> elif request.args(0) == 'language':
> adviewer_engine.update_or_create_adviewer_settings(
> AdViewerEngine.language,
> dict(
> language = request.vars['language']
> )
> )
> elif request.args(0) == 'keywords':
> adviewer_engine.update_or_create_adviewer_settings(
> AdViewerEngine.keywords,
> dict(
> keywords = request.vars['keywords']
> )
> )
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Time Substraction

2012-02-27 Thread Sanjeet Kumar
I am going to develop the time management sheet for that i have the one 
table name employee table and i am allready taken the login and logout time 
and i want to substract the time when i substract the time it show me in 
nanoseconds when i convert this nanosecond to the minute it totally 
confused me so if any one have solution please help me following is my 
controller and database :-
*
Table:-*

db.define_table('employee_detail',
Field('employee_id'),
Field('employee_name'),
Field('employee_login_date','date'),
Field('employee_logout_date','date'),
Field('employee_login_time'),
Field('employee_logout_time'),
Field('total_time'))*

Controller:-*

def lgin(form):
import datetime
import time
currentdate=datetime.date.today()
now = time.localtime(time.time())
session.sttime=time.time()
currenttime = time.strftime("%H:%M:%S", now)
session.time = currenttime
#response.flash=currentdate
for row in db(db.auth_user.email == 
auth.user.email).select(db.auth_user.first_name):
firstname=row.first_name
db.employee_detail.insert(employee_id = auth.user.email, 
employee_name=firstname, employee_login_date=currentdate, 
employee_login_time=currenttime)
return '' 
 
def lgout(usr): 
import datetime
import time
currentdate=datetime.date.today()
now = time.localtime(time.time())
ettime=time.time()
duration = ettime-session.sttime
du = str(duration / 600)
currenttime = time.strftime("%H:%M:%S", now) 
db((db.employee_detail.employee_id == auth.user.email) & 
(db.employee_detail.employee_login_date == currentdate) & 
(db.employee_detail.employee_login_time == 
session.time)).update(employee_logout_date=currentdate, 
employee_logout_time=currenttime, total_time=du)  
return '' 




[web2py] Re: Setup Needed For web2py book examples to work

2012-02-27 Thread Alok
Thank you very very much for a quick and complete response.

On Feb 27, 5:51 am, Anthony  wrote:
> > First, I want to learn what Setup is needed for me to try out web2py
> > examples like the following shown in the web2py book
> > >>> print str(DIV("hello world"))
> > hello world
> > I tried using
> > >>>import gluon
> > but that did not work. I added web2py in sys.path but the above import
> > still did not work.
> > I found gluon in library.zip folder. Am I supposed to add web2py/
> > library.zip to the sys.path? If not, how can I get the web2py example
> > statements to work?
>
> If you have library.zip, that means you are using the web2py binary version
> for Windows. That version includes its own Python interpreter, so when you
> run web2py, it is not using your computer's installation of Python, and if
> you run your computer's Python shell, it won't have access to web2py. If
> you've already got Python installed, you're probably better off running
> web2py from source -- just download and unzip the source version (on
> Windows, make sure you also havehttp://sourceforge.net/projects/pywin32/
> installed). It's just as easy as running the binary -- instead of
> web2py.exe, you'll see web2py.py -- you can either double click that, or
> run from shell with "python web2py.py".
>
> To run the examples in the book, the best method is to start a web2py shell:
>
> python web2py.py -S appname -M -N
>
> That starts a Python shell in the environment of the web2py app named
> "appname", including the entire web2py API. The -M tells it to run the
> app's model files, and the -N turns off cron (which you don't need in the
> shell). In place of "appname", you can put "appname/mycontroller", which
> will expose the functions/objects in the mycontroller.py controller as
> well. For more,
> seehttp://web2py.com/books/default/chapter/29/4#Command-line-options.
>
> Anthony


Re: [web2py] Re: [w2py-dev] model less apps (a blog example)

2012-02-27 Thread Bruce Wade
I am using a very similar concept now however I am storing all my modules
that require access to multiple app's in a different location. At the same
level ass gluon

For example:
web2py
-- gluon
-- customAPIs
- my_api

Now in any action where you want to use your api:
from customAPIs.my_api import custom_class_etc

Or if you want it global to the app you can do the same. This approach
all's for very easy sharing of code across applications.

On Mon, Feb 27, 2012 at 12:55 AM, Johann Spies wrote:

>
>
> On 25 February 2012 08:42, Johann Spies  wrote:
>
>>
>>
>> The tables show up in appadmin but not the content and  I cannot do csv
>> import or export:
>>
>>  __call__() got an unexpected keyword
>> argument 'ignore_common_filters'
>>
>
> On a different computer today I do not get this error.  So it might be a
> local problem.  I will have to check the web2py version on the other
> computer to which I do not have access on the moment.
>
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Workflow engine for web2py

2012-02-27 Thread Richard Vézina
No progress here I didn't have time for that... I involve in any
initiative, but we need orientation. I think we should try something
(anything) that could work and see what are the limitation of the approach
and try other approach (trial and error)...

Richard

2012/2/27 António Ramos 

> Any evolution in this issue.
> I need it bad.
>
> I was thinking in workflow as a service.
> Instead of changing dal i would submit the record to a webservice
> verification service that returns a new record, changed according to the
> rules.
> Is this a good thinking? and easier to do?
>
> Thank you
> António
>
>
>
>
> 2012/2/8 Richard Vézina 
>
>> For my self I am interresting to workflow in context of LIMS and here a
>> article about kind of workflows in LIMS :
>>
>> http://www.scientificcomputing.com/workflow-perspectives-in-lims.aspx
>>
>> Richard
>>
>>
>> On Tue, Feb 7, 2012 at 11:12 PM, mart  wrote:
>>
>>> I think features such as those you already implemented in your bug
>>> tracking app hold some importance here as well Ie. the good use of
>>> groups, permissions & ability to modify things like ownership - as an
>>> example, a corporate accounting department should still have the
>>> ability to  reimburse employee expenses even though the said
>>> employee's accounting contact's position has been terminated (maybe
>>> along with 875 other poor employees that same day)... Doh! did I write
>>> that out loud? ;) oh well, it still holds true, the wf should still be
>>> able to handle any kind of changes like work item ownership and re-
>>> route accordingly (this also serves as an example of a good use of
>>> roles in a wf :) )
>>>
>>> here is a example of implementation details of a workflow. Granted,
>>> probably a little too large in scale (especially in light of its new
>>> future), but... the idea is there none the less. I think the doc
>>> should also contain a blurb on how it makes use of databases
>>>
>>> http://help.adobe.com/en_US/livecycle/9.0/overview.pdf
>>>
>>> ** for those who followed the thread on the use of the word
>>> "Enterprise", notice the acronym 'ES' in the product's name.
>>>
>>> Mart :)
>>>
>>> On Feb 8, 3:07 am, Massimo Di Pierro 
>>> wrote:
>>> > That's a finite state machine. It is nice and simple but too simple.
>>> > Anyway, the problem in using that with web2py (or any other web
>>> > framework) it is not designed to maintain its state using the
>>> > database.
>>> >
>>> > Anyway, it should be possible to modify it so that state and rules are
>>> > stored in the database. Do we expect more from a workflow system? I am
>>> > not sure convinced every workflow I need can be modeled finite state
>>> > machine. I will give this some more thought.
>>> >
>>> > massimo
>>> >
>>> > On Feb 7, 4:25 pm, Richard Vézina  wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > There is no ubuntu official package as far as I can see, so you will
>>> have
>>> > > to follow the installation information explain into the tar ball
>>> available
>>> > > here :http://www.hforge.org/itools/
>>> >
>>> > > Then :
>>> >
>>> > > from itools.workflow import Workflow
>>> >
>>> > > And the rest is explained in the docs :
>>> >
>>> > >http://www.hforge.org/itools/docs/workflow/
>>> >
>>> > > I think you will pretty much have to build your own logic to make
>>> use of
>>> > > workflow for given objects (tables and rows)...
>>> >
>>> > > But there is surely a way that this lib could be included into
>>> web2py core
>>> > > so we can make use of workflow utility readily.
>>> >
>>> > > Richard
>>> >
>>> > > 2012/2/7 António Ramos 
>>> >
>>> > > > How to use this in web2py ?
>>> > > > dummies tutorial?
>>> >
>>> > > > 2012/2/7 omicron 
>>> >
>>> > > >> This library is small and easy to use:
>>> > > >>http://www.hforge.org/itools/docs/workflow/
>>>
>>
>>
>


[web2py] Re: How do you define a column name on summed field (i.e. how to do the equivalent of an sql 'select ..... as colname'

2012-02-27 Thread Anthony

>
> That syntax works and I can use that to refer to the data, I could see 
> that a row object had an '_extra' dict for the selected expressions 
> but could not see that the data could be referred to be the name of 
> the expression 'mysum' (its in there somewhere but not sure where!!) 
>

The book example does show that usage:

>>> sum = db.log.severity.sum()
>>> print db().select(sum).first()[sum]


Actually, when you do row[mysum], the __getitem__ method of the Row object 
automatically does row[str(mysum)]. Since mysum is a DAL Expression object, 
its __str__ method converts it to the SQL syntax for the particular 
database adapter you are using, which in this case is 
"(SUM(t_appointment.miles_to) 
+ SUM(t_appointment.miles_from))". The Row __getitem__ method first looks 
for that key in its _extra dict and returns the value if found. So, when 
you do:

row[mysum]

This is essentially what is happening behind the scenes:

   1. row[str(mysum)]
   2. row['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))']
   3. row['_extra']['(SUM(t_appointment.miles_to) + 
   SUM(t_appointment.miles_from))']
   
Anthony


[web2py] Re: Setup Needed For web2py book examples to work

2012-02-27 Thread Anthony

>
> First, I want to learn what Setup is needed for me to try out web2py 
> examples like the following shown in the web2py book 
> >>> print str(DIV("hello world")) 
> hello world 
> I tried using 
> >>>import gluon 
> but that did not work. I added web2py in sys.path but the above import 
> still did not work. 
> I found gluon in library.zip folder. Am I supposed to add web2py/ 
> library.zip to the sys.path? If not, how can I get the web2py example 
> statements to work? 
>

If you have library.zip, that means you are using the web2py binary version 
for Windows. That version includes its own Python interpreter, so when you 
run web2py, it is not using your computer's installation of Python, and if 
you run your computer's Python shell, it won't have access to web2py. If 
you've already got Python installed, you're probably better off running 
web2py from source -- just download and unzip the source version (on 
Windows, make sure you also have http://sourceforge.net/projects/pywin32/ 
installed). It's just as easy as running the binary -- instead of 
web2py.exe, you'll see web2py.py -- you can either double click that, or 
run from shell with "python web2py.py".

To run the examples in the book, the best method is to start a web2py shell:

python web2py.py -S appname -M -N

That starts a Python shell in the environment of the web2py app named 
"appname", including the entire web2py API. The -M tells it to run the 
app's model files, and the -N turns off cron (which you don't need in the 
shell). In place of "appname", you can put "appname/mycontroller", which 
will expose the functions/objects in the mycontroller.py controller as 
well. For more, 
see http://web2py.com/books/default/chapter/29/4#Command-line-options.

Anthony



[web2py] Re: Web2py and SSLH

2012-02-27 Thread Ross Peoples
I would be interested to see if SSH can actually be forwarded without 
triggering a main-in-the-middle error.

I'm not sure on the first question, but I would guess that you would want 
to disable everything except your app.

At the bottom of the db.py model, just put "session.forget(request)". This 
will still create cookies, I think but will not actually use them. Not sure 
on this one. Maybe someone else has a better answer for turning cookies off 
completely.

In your model, I would also disable anything you don't need: db, mail, 
auth, etc.

On Sunday, February 26, 2012 1:09:21 PM UTC-5, t13one wrote:
>
> I'm thinking about setting up SSLH on my personal server.
>
> From http://freecode.com/projects/sslh:
> 
>
> > sslh accepts HTTPS, SSH, OpenVPN, tinc, and XMPP connections on the
> > same port. This makes it possible to connect to any of these servers
> > on port 443 (e.g., from inside a corporate firewall, which almost
> > never blocks port 443) while still serving HTTPS on that port.
>
> In short summary (and to my limited understanding), SSLH works by
> forwarding the connection from the sslh daemon to either the ssh server
> or the web-server (among other options). This means all SSL connections
> will ultimately appear to be connecting to apache/web2py via 127.0.0.1.
>
> Are there any security concerns with this? Should I disable admin and
> appadmin completely?
>
> How are session cookies affected?
>
> Would any other functionality be affected?
>
>
On Sunday, February 26, 2012 1:09:21 PM UTC-5, t13one wrote:
>
> I'm thinking about setting up SSLH on my personal server.
>
> From http://freecode.com/projects/sslh:
> 
>
> > sslh accepts HTTPS, SSH, OpenVPN, tinc, and XMPP connections on the
> > same port. This makes it possible to connect to any of these servers
> > on port 443 (e.g., from inside a corporate firewall, which almost
> > never blocks port 443) while still serving HTTPS on that port.
>
> In short summary (and to my limited understanding), SSLH works by
> forwarding the connection from the sslh daemon to either the ssh server
> or the web-server (among other options). This means all SSL connections
> will ultimately appear to be connecting to apache/web2py via 127.0.0.1.
>
> Are there any security concerns with this? Should I disable admin and
> appadmin completely?
>
> How are session cookies affected?
>
> Would any other functionality be affected?
>
>

[web2py] Re: request.user_agent() dumping

2012-02-27 Thread Ross Peoples
Glad you like the feature! I don't think dimensions are available in the 
user-agent string that the browser passes to the server. So your only 
option is to use jQuery or CSS media queries.

On Sunday, February 26, 2012 11:13:42 PM UTC-5, weheh wrote:
>
> And, I might add, this is simply awesome. It would also be very cool 
> if it could give me the dimensions of the browser window. I know I can 
> get it via jQuery, but it would save a step. 
>
> On Feb 22, 10:15 pm, Massimo Di Pierro  
> wrote: 
> > I think this was fixed in a later version. 
> > 
> > On Feb 21, 9:52 pm, weheh  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > I'm trying to detect the browser being used to access my web2py app. 
> > > The literature seems to recommend reading request.env.http_user_agent. 
> > > But the results are a little confusing, so I'm trying 
> > > request.user_agent(), which uses "gluon/contrib/ 
> > > user_agent_parser.py" (as per the doc). This throws the following 
> > > ticket: 
> > 
> > > Traceback (most recent call last): 
> > >   File "N:\web2py\gluon\main.py", line 518, in wsgibase 
> > > session._try_store_on_disk(request, response) 
> > >   File "N:\web2py\gluon\globals.py", line 528, in _try_store_on_disk 
> > > cPickle.dump(dict(self), response.session_file) 
> > > PicklingError: Can't pickle : it's not the 
> > > same object as storage.Storage 
> > 
> > > I'm on web2py v1.99.2 
> > 
> > > Thanks.


On Sunday, February 26, 2012 11:13:42 PM UTC-5, weheh wrote:
>
> And, I might add, this is simply awesome. It would also be very cool 
> if it could give me the dimensions of the browser window. I know I can 
> get it via jQuery, but it would save a step. 
>
> On Feb 22, 10:15 pm, Massimo Di Pierro  
> wrote: 
> > I think this was fixed in a later version. 
> > 
> > On Feb 21, 9:52 pm, weheh  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > I'm trying to detect the browser being used to access my web2py app. 
> > > The literature seems to recommend reading request.env.http_user_agent. 
> > > But the results are a little confusing, so I'm trying 
> > > request.user_agent(), which uses "gluon/contrib/ 
> > > user_agent_parser.py" (as per the doc). This throws the following 
> > > ticket: 
> > 
> > > Traceback (most recent call last): 
> > >   File "N:\web2py\gluon\main.py", line 518, in wsgibase 
> > > session._try_store_on_disk(request, response) 
> > >   File "N:\web2py\gluon\globals.py", line 528, in _try_store_on_disk 
> > > cPickle.dump(dict(self), response.session_file) 
> > > PicklingError: Can't pickle : it's not the 
> > > same object as storage.Storage 
> > 
> > > I'm on web2py v1.99.2 
> > 
> > > Thanks.



Re: [web2py] Re: Workflow engine for web2py

2012-02-27 Thread António Ramos
Any evolution in this issue.
I need it bad.

I was thinking in workflow as a service.
Instead of changing dal i would submit the record to a webservice
verification service that returns a new record, changed according to the
rules.
Is this a good thinking? and easier to do?

Thank you
António




2012/2/8 Richard Vézina 

> For my self I am interresting to workflow in context of LIMS and here a
> article about kind of workflows in LIMS :
>
> http://www.scientificcomputing.com/workflow-perspectives-in-lims.aspx
>
> Richard
>
>
> On Tue, Feb 7, 2012 at 11:12 PM, mart  wrote:
>
>> I think features such as those you already implemented in your bug
>> tracking app hold some importance here as well Ie. the good use of
>> groups, permissions & ability to modify things like ownership - as an
>> example, a corporate accounting department should still have the
>> ability to  reimburse employee expenses even though the said
>> employee's accounting contact's position has been terminated (maybe
>> along with 875 other poor employees that same day)... Doh! did I write
>> that out loud? ;) oh well, it still holds true, the wf should still be
>> able to handle any kind of changes like work item ownership and re-
>> route accordingly (this also serves as an example of a good use of
>> roles in a wf :) )
>>
>> here is a example of implementation details of a workflow. Granted,
>> probably a little too large in scale (especially in light of its new
>> future), but... the idea is there none the less. I think the doc
>> should also contain a blurb on how it makes use of databases
>>
>> http://help.adobe.com/en_US/livecycle/9.0/overview.pdf
>>
>> ** for those who followed the thread on the use of the word
>> "Enterprise", notice the acronym 'ES' in the product's name.
>>
>> Mart :)
>>
>> On Feb 8, 3:07 am, Massimo Di Pierro 
>> wrote:
>> > That's a finite state machine. It is nice and simple but too simple.
>> > Anyway, the problem in using that with web2py (or any other web
>> > framework) it is not designed to maintain its state using the
>> > database.
>> >
>> > Anyway, it should be possible to modify it so that state and rules are
>> > stored in the database. Do we expect more from a workflow system? I am
>> > not sure convinced every workflow I need can be modeled finite state
>> > machine. I will give this some more thought.
>> >
>> > massimo
>> >
>> > On Feb 7, 4:25 pm, Richard Vézina  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > There is no ubuntu official package as far as I can see, so you will
>> have
>> > > to follow the installation information explain into the tar ball
>> available
>> > > here :http://www.hforge.org/itools/
>> >
>> > > Then :
>> >
>> > > from itools.workflow import Workflow
>> >
>> > > And the rest is explained in the docs :
>> >
>> > >http://www.hforge.org/itools/docs/workflow/
>> >
>> > > I think you will pretty much have to build your own logic to make use
>> of
>> > > workflow for given objects (tables and rows)...
>> >
>> > > But there is surely a way that this lib could be included into web2py
>> core
>> > > so we can make use of workflow utility readily.
>> >
>> > > Richard
>> >
>> > > 2012/2/7 António Ramos 
>> >
>> > > > How to use this in web2py ?
>> > > > dummies tutorial?
>> >
>> > > > 2012/2/7 omicron 
>> >
>> > > >> This library is small and easy to use:
>> > > >>http://www.hforge.org/itools/docs/workflow/
>>
>
>


[web2py] Setup Needed For web2py book examples to work

2012-02-27 Thread Alok
Friends I am a beginner trying to learn web2py. I have a windows
computer. I have 2 questions.

First, I want to learn what Setup is needed for me to try out web2py
examples like the following shown in the web2py book
>>> print str(DIV("hello world"))
hello world
I tried using
>>>import gluon
but that did not work. I added web2py in sys.path but the above import
still did not work.
I found gluon in library.zip folder. Am I supposed to add web2py/
library.zip to the sys.path? If not, how can I get the web2py example
statements to work?

My second question is to understand the role of Library.zip in the
web2py install folder.
Thanks


Re: [web2py] Re: cron setup

2012-02-27 Thread Luciano Pacheco
Example:

http://movu.ca/demo/article/show/31/web2py-cron-task

My first try in movu.ca :-)

On Mon, Feb 27, 2012 at 2:32 PM, Sanjeet Kumar wrote:

> Exactly I need the examples
>
>
> On Mon, Feb 27, 2012 at 4:56 AM, Luciano Pacheco wrote:
>
>> I think Sanjeet means, I example of the task.
>>
>> What is a good practice in the task, or what kind of variables are
>> present in the local namespace "automagically", etc. A task should be a
>> class a function, a python module?
>>
>> I had the same question last week when I was reading this chapter. :-)
>>
>> Regards,
>> --
>> Luciano Pacheco
>> blog.lucmult.com.br
>>
>> On Mon, Feb 27, 2012 at 10:08 AM, Alan Etkin  wrote:
>>
>>> It's all in the book (if you haven't seen yet)
>>>
>>> http://web2py.com/books/default/chapter/29/4#Cron
>>>
>>> By the way, The link in web2py to cron (http://web2py.com/books/
>>> default/reference/29/cron)
>>> is broken (returns an invalid function
>>> message)
>>>
>>> On 26 feb, 13:09, Sanjeet Kumar  wrote:
>>> > Can anyone give me the brief description to how I set the cron to run
>>> the
>>> > task in background with example.
>>>
>>
>>
>>
>>
>


-- 
Luciano Pacheco
blog.lucmult.com.br


Re: [web2py] Re: Method to interactively experiment with web2py

2012-02-27 Thread Phyo Arkar
My version is 1.98.2 , i updated to 1.99.4 and works fine now! sorry
for mis info.

On 2/26/12, Luciano Pacheco  wrote:
> Hi Phyo,
>
> I'm using web2py and ipython 0.12 normally.
>
> $ ./web2py.py -S instore
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2011
> Version 1.99.4 (2011-12-14 14:46:14) stable
> Database drivers available: SQLite3, pymysql
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.12 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help  -> Python's own help system.
> object?   -> Details about 'object', use 'object??' for extra details.
>
> In [1]:
>
> What's the error you're getting ?
>
> [],
> --
> Luciano Pacheco
> blog.lucmult.com.br
>
> On Sun, Feb 26, 2012 at 7:56 PM, Phyo Arkar wrote:
>
>> web2py shell no longer works with latest ipython 0.11 +
>>
>> On 2/20/12, Massimo Di Pierro  wrote:
>> > What you use
>> >
>> > python web2py.py -S app -M -N
>> >
>> > make sure to db.commit() your changes.
>> >
>> > On Feb 19, 5:45 pm, davidkw  wrote:
>> >> I'm wondering if there's some kind of way to use a shell or other IDE
>> >> to quickly run lines of web2py code and see the result.
>> >>
>> >> For example, just entering db(query).select().first() and being able
>> >> to see the result.
>> >>
>> >> I'm learning right now, and it's a little difficult to pick up the
>> >> syntax without being able to play around. Any advice?
>> >>
>> >> Thanks.
>>
>


Re: [web2py] compute on update

2012-02-27 Thread Mirek Zvolský

>
> I think the behaviour of "compute=" is not good. Most people need 
> calculated field which ALWAYS follow the source values and not just ONCE. 
> So I have found in google group, lot of people fall through the time in 
> same problem and there is still no clear solution.
>
> I now need this for Markmin source and calculated Html output (both fields 
> in same table)
> I have solved this so:
> ...Field('html', compute = lambda row: MARKMIN(row.markmin).xml())...
> and in addition I use "onaccept" method in form:
> def post_forcecompute(form):
> row = db.post(form.vars.id)
> row.update_record(html=db.post.html.compute(row))
> crud_post.settings.update_onaccept = post_forcecompute
>
> This works, however it is not very good workaround, because it is 
> neccessary to solve it in form, instead of in the model :(
>
> Mirek
>


Re: [web2py] compute on update

2012-02-27 Thread Mirek Zvolský
I think the behaviour of "compute=" is not good. Most people need 
calculated field which ALWAYS follow the source values and not just ONCE. 
So I have found in google group, lot of people fall through the time in 
same problem and there is still no clear solution.

I now need this for Markmin source and calculated Html output (both fields 
in same table)
I have solved this so:
...Field('html', compute = lambda row: MARKMIN(row.markmin).xml())...
and in addition I use "onaccept" method in form:
def post_forcecompute(form):
row = db.post(form.vars.id)
row.update_record(html=db.post.html.compute(row))
crud_post.settings.update_onaccept = post_forcecompute

This works, however it is not very good workaround, because it is 
neccessary to solve it in form, instead of in the model :(

Mirek

 

Dne čtvrtek, 29. prosince 2011 21:36:35 UTC+1 Richard napsal(a):
>
> Ping!
>
> computed field not compute on update... What should I check?
>
> Thanks
>
> Richard
>
> On Wed, Dec 28, 2011 at 4:50 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Hello,
>>
>> I would like to compute a field on update, but I think all the 
>> request.vars needed to my lambda compute function are not passed to 
>> form.vars...
>>
>> What I should do to make sure all the needed vars are available to the 
>> lambda compute function?
>>
>> form.vars.varname = request.vars.varname ??
>>
>> Thanks 
>>
>> Richard
>>
>
>
Dne čtvrtek, 29. prosince 2011 21:36:35 UTC+1 Richard napsal(a):
>
> Ping!
>
> computed field not compute on update... What should I check?
>
> Thanks
>
> Richard
>
> On Wed, Dec 28, 2011 at 4:50 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Hello,
>>
>> I would like to compute a field on update, but I think all the 
>> request.vars needed to my lambda compute function are not passed to 
>> form.vars...
>>
>> What I should do to make sure all the needed vars are available to the 
>> lambda compute function?
>>
>> form.vars.varname = request.vars.varname ??
>>
>> Thanks 
>>
>> Richard
>>
>
>
Dne čtvrtek, 29. prosince 2011 21:36:35 UTC+1 Richard napsal(a):
>
> Ping!
>
> computed field not compute on update... What should I check?
>
> Thanks
>
> Richard
>
> On Wed, Dec 28, 2011 at 4:50 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Hello,
>>
>> I would like to compute a field on update, but I think all the 
>> request.vars needed to my lambda compute function are not passed to 
>> form.vars...
>>
>> What I should do to make sure all the needed vars are available to the 
>> lambda compute function?
>>
>> form.vars.varname = request.vars.varname ??
>>
>> Thanks 
>>
>> Richard
>>
>
>

[web2py] Web2py Scheduler

2012-02-27 Thread VIREN PATEL
Hi,

I need to implement the Scheduler and Job Queues at the application level.
Please suggest some good Schedulers.
Also if any one has implemented the schedulers in web2py

Thanks,
Viren


[web2py] Markmin small problems

2012-02-27 Thread Mirek Zvolský
I'm using markmin2html.py.

Tables & Blockquotes need to have at least one \n before and one \n after.

When the table or blockquote is on the begin or end of the source string, 
workaround is easy:
markmin2html("\n" + src + "\n")
will recognize the table properly.

But inside the text, if 2 blockqutes, 2 tables, or 1table/1blockquote 
follow immediately, the second one is not recognized.
Easy to test this, if you have Instantpress installed:

aaa


bbb

generates: aaabbb

For developer there is no problem to add one Enter between. But I think 
Markmin is designed for standard users (like in Instantpress), who can have 
problems.

Mirek


Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Johann Spies
On 27 February 2012 10:49, Bruno Rocha  wrote:

> Massimo and Mariano are developing a conditional model_map, so you will be
> able to choose which model files to run for each requested controller, it
> will be a very good add to web2py.
>
> Maybe it will be included only in web2py 2.0.
>
>
Good news!  Thanks.

Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Re: [w2py-dev] model less apps (a blog example)

2012-02-27 Thread Johann Spies
On 25 February 2012 08:42, Johann Spies  wrote:

>
>
> The tables show up in appadmin but not the content and  I cannot do csv
> import or export:
>
>  __call__() got an unexpected keyword
> argument 'ignore_common_filters'
>

On a different computer today I do not get this error.  So it might be a
local problem.  I will have to check the web2py version on the other
computer to which I do not have access on the moment.


Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: checklist plugin with templates

2012-02-27 Thread szimszon
There is now a locking functionality on checklist items...

You can mark a checklist field as work in progress. If you click on the 
name of the field and it'll be marked as locked (green).

You can unlock it with a next click on the name of the field.

If somebody else locked the field it is displayed in red. You can still 
obtain a lock by double click on the name of the field. It'll clear the 
other lock and will lock by you
Legend Green row - Locked by you (Lock / Unlock by 1 click) Red row - 
Locked by other (Obtain the lock by double click)



Re: [web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Bruno Rocha
Massimo and Mariano are developing a conditional model_map, so you will be
able to choose which model files to run for each requested controller, it
will be a very good add to web2py.

Maybe it will be included only in web2py 2.0.

I still think we need a model-less approach using modules, and it needs to
be documented, but appadmin was not designed to wotk with that, so it is
better to have it as a plugin (a new appadmin)

Even with the new model map I will still use the modules approach because
it has some advantages, it looks more like Python, it works well with my
code editor auto conplete and linter without hacks, and it is more reusable
in terms of Object Oriented programming. BTW I am not using appadmin for
database. I am replacing it with a simple plugin called badmin.

wait web2py 2.0 to see the new model mapping feature.

http://zerp.ly/rochacbruno
Em 27/02/2012 05:18, "Johann Spies"  escreveu:

> The thread in this mailing list with the subject "*model less apps (a
> blog example)"  *and some other remarks about using model-less
> applications for better speed and memory usage is the background of this
> email. I would be glad if the guidelines (not necessarily recipes) on
> this can become part of the official Web2py documentation.
>
> I am working on a long term app which currently have 93 tables in the
> database.  The database will develop into a multilevel database with many
> more tables and in the end probably several millions or records.
>
> I have started to migrate some of the less used tables to modules and it
> is working in the normal app, but I have problems with appadmin as I have
> described in the thread I refer to in the first paragraph.  Even in Bruno's
> blog example using appadmin produces tickets.
>
> This is because web2py was not originally designed for this type of setup.
>
> So my request is:
>
> If the way to go for large databases (many tables) is to move the table
> definitions to modules, please make it  part of the Web2py design, adapt
> appadmin to handle it and provide official documentation about it.
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


[web2py] Request for some formal guidelines on models in modules

2012-02-27 Thread Johann Spies
 The thread in this mailing list with the subject "*model less apps (a blog
example)"  *and some other remarks about using model-less applications for
better speed and memory usage is the background of this email.I would be
glad if the guidelines (not necessarily recipes) on this can become part of
the official Web2py documentation.

I am working on a long term app which currently have 93 tables in the
database.  The database will develop into a multilevel database with many
more tables and in the end probably several millions or records.

I have started to migrate some of the less used tables to modules and it is
working in the normal app, but I have problems with appadmin as I have
described in the thread I refer to in the first paragraph.  Even in Bruno's
blog example using appadmin produces tickets.

This is because web2py was not originally designed for this type of setup.

So my request is:

If the way to go for large databases (many tables) is to move the table
definitions to modules, please make it  part of the Web2py design, adapt
appadmin to handle it and provide official documentation about it.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)