[web2py] Re: sum the query result from other table

2013-12-05 Thread 黄祥
i've tried it but returned an error :
expr = (db.dvd.acquisition_price * db.rent_detail.quantity).sum() # you can 
build any expression!
grand_total = db(db.rent_detail.id.belongs(ids))(db.dvd.id == 
db.rent_detail.dvd).select(expr).first()[expr]
 *Traceback :* 
table.grand_total.represent = lambda grand_total, field: 
format(grand_total, ",d")
ValueError: Unknown format code 'd' for object of type 'str'

i think the above code is work (the row status of rent detail is change), 
since i can't access the database adminstration for table compensation with 
the same error too.
 
expr = (db.dvd.acquisition_price * db.rent_detail.quantity).sum() # you can 
build any expression!
total = db(db.rent_detail.id.belongs(ids))(db.dvd.id == 
db.rent_detail.dvd).select(expr).first()[expr]
grand_total = int(total)
 *Traceback :* 
grand_total = int(total)
TypeError: int() argument must be a string or a number, not 'NoneType'

my suspect is ids can not work on belongs, since it passed from selectable 
values from 2 previous function.

thanks and best regards,
stifan

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


[web2py] Re: uploading files on GAE - 404 NOT FOUND

2013-12-05 Thread James Burke
Hi Christian,

Thanks for your help.

Unfortunately no ticket is created I just get a new page with the 404 error 
message on it.

url when uploading the file: http://gic-test.appspot.com/admin/file/new/file
url after uploading the 
file: http://gic-test.appspot.com/admin/file/new/file#

I've located the code that is causing the error in:

db.define_table('file',
Field('name', unique=True, compute=lambda r: db.file.file.retrieve(r.
file)[0]),
Field('file', 'upload'),
Field('created_on', 'datetime', default=request.now),
Field('created_by', 'reference auth_user', default=auth.user_id),
format='%(name)s')


the compute function for name lambda r: db.file.file.retrieve(r.file)[0] when 
removed fixes the error. Although this code works with rocket web server.

Cheers

-James



On Thursday, December 5, 2013 7:29:20 PM UTC+13, Christian Foster Howes 
wrote:
>
> Can you share the log/stack trace from when that happens?  does the form 
> post to the same function that generated it?
>
> i have not tried upload in grid()wonder if there is something there 
> that doesn't quite work on app engine?
>
> On Tuesday, December 3, 2013 10:49:47 AM UTC-8, James Burke wrote:
>>
>> Hi,
>>
>> Uploading files into my table on GAE, when I hit submit I'm presented 
>> with a "404 NOT FOUND" error message.
>>
>> Works fine using Rocket, but not in GAE SDK or when uploaded to GAE.
>>
>> _tables.py - in models
>> db.define_table('file',
>> Field('name', unique=True, compute=lambda r: db.file.file.retrieve(r.
>> file)[0]),
>> Field('file', 'upload'),
>> Field('created_on', 'datetime', default=request.now),
>> Field('created_by', 'reference auth_user', default=auth.user_id),
>> format='%(name)s')
>>
>>
>> admin.py - in controllers
>> @auth.requires_membership("admin")
>> def file():
>>  links = [dict(header='URL', body=lambda row: '/init/default/download/%s' 
>> %(db.file.file.retrieve(row.file)[0]))]
>>  form = SQLFORM.grid(db.file, links=links, searchable=False, 
>> csv=False,user_signature
>> =False)
>>
>>
>>  return dict(form=form)
>>
>>
>>
>> Cheers
>>
>> -James
>>
>

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


Re: [web2py] Re: Scheduler-related database tables created on sqLite but NOT on MySQL

2013-12-05 Thread Yassen Damyanov
Thanks, Massimo, that was it. Niphlod answered that in another thread
and I just got the problem solved.

Again, I would suggest showing the migration status somewhere in the
application header of the db administration page, of that sounds
reasonable and not hard to do. Would help to newcomers like me :)

Cheers,
Yassen

On Friday, December 6, 2013 7:08:05 AM UTC+2, Yassen D. wrote:Niphlod,
HUGE THANKS! I'll check that right now and post back.

On Thu, Dec 5, 2013 at 11:53 PM, Niphlod  wrote:
> check for
> db = DAL(migrate_enabled=False)
>
> either this prevented the creation of the table, or some another
> migrate-related glitch.
> To create scheduler's tables, you just need to do (as you did)
>
> Scheduler(db, ...)
>
> NB: (just a naming-convention advice) use
> from gluon.scheduler import Scheduler
> mysched = Scheduler(db, )
> instead of
> scheduler = Scheduler(db, ...)
>
> to clearly state the difference between the module and the object that is
> used by your app ^_^
>
> If your tables are in the admin interface but not on the backend, check that
> your migrations are enabled and delete any pre-existing *scheduler*.table
> files in the databases/ folder. This will trigger the creation both of the
> new .table files and the tables on the backend.
>
> BTW: for tasks that needs **immediate** care from the scheduler, instead of
> lowering the heartbeat (and such having all workers to "hammer" the database
> asking for new tasks) just let the heartbeat as it is and use
> mysched.queue_task(., immediate=True)
> for any user needing that task to run.
> In a few sec the first available worker will pick up the task
> Plan your workers number according on how many concurrent users will need in
> your app a task to be processed: a worker can only be processing one single
> task.
>
> for @all: if you have the need of 20 or 30 concurrent tasks (and such need
> 20 or 30 workers ) test the scheduler carefully: you may find a dedicated
> database more performant and you may also need to put workers in a sleeping
> state (DISABLED) to "alleviate" the db pressure when they are not needed.
> Then you'll need to set them to ACTIVE (or just delete all the records in
> the scheduler_workers table) before queueing a new task...they'll resume
> their (working) state in a heartbeat.
> If you need more than 30 workers. use a different task processor:
> unfortunately the polling nature of the scheduler makes a "bad usecase" for
> such high demands.

On Fri, Dec 6, 2013 at 7:29 AM, Massimo Di Pierro
 wrote:
> Are you sure you have not set DAL(...,migrate_enabled=False)?
>
>
> On Thursday, 5 December 2013 16:10:34 UTC-6, Yassen D. wrote:
>>
>> Hello all,
>>
>> I follow a simple video-tutorial (http://vimeo.com/27478796); so I create
>> a model scheduler.py with this content:
>>
>> def f():
>> t = time.ctime()
>> open('/tmp/tasks', 'w').write(t + '\n')
>> return f
>>
>> from gluon.scheduler import Scheduler
>> Scheduler(db, dict(our_func=f))
>>
>>
>> After saving it, I go to the database administration of that same
>> application and can see db.scheduler_task, db.scheduler_run,
>> db.scheduler_worker links; when I click on db.scheduler_task, the form is
>> there and I can fill in the data, however, on saving, it spits this error:
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/restricted.py", line 217, in
>> restricted
>> exec ccode in environment
>>   File
>> "/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py",
>> line 236, in 
>>   File "/home/www-data/web2py/gluon/globals.py", line 372, in 
>> self._caller = lambda f: f()
>>   File "/home/www-data/web2py/gluon/tools.py", line 3239, in f
>> return action(*a, **b)
>>   File
>> "/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py",
>> line 54, in importcontacts
>> scheduler.queue_task(testfunc, pargs=[request.vars.sna],
>> kwargs=task_kwargs)
>>   File "/home/www-data/web2py/gluon/scheduler.py", line 983, in queue_task
>> **kwargs)
>>   File "/home/www-data/web2py/gluon/dal.py", line 9114, in
>> validate_and_insert
>> value,error = self[key].validate(value)
>>   File "/home/www-data/web2py/gluon/dal.py", line 10036, in validate
>> (value, error) = validator(value)
>>   File "/home/www-data/web2py/gluon/validators.py", line 668, in __call__
>> row = subset.select(table._id, field, limitby=(0, 1),
>> orderby_on_limitby=False).first()
>>   File "/home/www-data/web2py/gluon/dal.py", line 10450, in select
>> return adapter.select(self.query,fields,attributes)
>>   File "/home/www-data/web2py/gluon/dal.py", line 1861, in select
>> return self._select_aux(sql,fields,attributes)
>>   File "/home/www-data/web2py/gluon/dal.py", line 1826, in _select_aux
>> self.execute(sql)
>>   File "/home/www-data/web2py/gluon/dal.py", line 1948, in execute
>> return self.log_execute(*a, **b)
>>   File "/home/www-data/web2py/gluon/dal.py", line 1942

[web2py] Re: Spawning a thread or a process for a long-running task [urgent!]

2013-12-05 Thread Yassen D.

Niphlod, yes, that was it !!

It was not in the db.py but there was a 0.py with 'settings.migrate = True' 
(this is not my app, I was just asked to hack there to fix an issue).

An easy workaround might be to also set fake_migrations to True 
(fake_migrate_all=True in DAL() creation) and copy and execute the proper 
statements from databases/sql.log. That's what I did because just turning 
that settings.migrate into True brought me issues with tables already 
existing.

I was digging in this half a day. An idea: showing the migration status of 
the app somewhere in the header of the database admin page.

Huge thanks again for your great help!
Yassen


On Thursday, December 5, 2013 11:53:43 PM UTC+2, Niphlod wrote:
>
> check for 
> db = DAL(migrate_enabled=False)
>
> either this prevented the creation of the table, or some another 
> migrate-related glitch.
> To create scheduler's tables, you just need to do (as you did)
>
> Scheduler(db, ...)
>

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


Re: [web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread Massimo Di Pierro
Looking at this in more detail. This is a bug that was fixed some time ago. 
I believe in 2.4.2. You are using a very old version of web2py. :-(

Massimo


On Thursday, 5 December 2013 23:42:10 UTC-6, Massimo Di Pierro wrote:
>
> When posting a comment the last 5 lines are usually sufficient:
>
> 'Traceback (most recent call last):\n File "/base/data/home/apps/s~pv-4-
> vp/1.372124618390164258/gluon/main.py", line 551, in wsgibase\n 
> session._try_store_in_db(request, response)\n File 
> "/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/globals.py", 
> line 728, in _try_store_in_db\n record_id = table.insert(**dd)\n File 
> "/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py", line 
> 7806, in insert\n ret = 
> self._db._adapter.insert(self,self._listify(fields))\n 
> File "/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py", 
> line 4618, in insert\n rid = Reference(tmp.key().id())\nOverflowError: 
> Python int too large to convert to C long\n' p6570 s.
>
> This looks like a bug in DAL but what web2py version are you using?
>

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


Re: [web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread Christian Foster Howes
this strikes me as an old version of web2py.  GAE upgraded IDs to be 
longs a few months back and i know we made sure the DAL in the latest 
version supports that, yet this looks like such an error. :(


On 12/5/13, 21:42 , Massimo Di Pierro wrote:

When posting a comment the last 5 lines are usually sufficient:

'Traceback (most recent call last):\n File "/base/data/home/apps/s~pv-4-
vp/1.372124618390164258/gluon/main.py", line 551, in wsgibase\n
session._try_store_in_db(request, response)\n File
"/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/globals.py",
line 728, in _try_store_in_db\n record_id = table.insert(**dd)\n File
"/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py", line
7806, in insert\n ret = self._db._adapter.insert(self,self._listify(fields))\n
File "/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py",
line 4618, in insert\n rid = Reference(tmp.key().id())\nOverflowError:
Python int too large to convert to C long\n' p6570 s.

This looks like a bug in DAL but what web2py version are you using?



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread Massimo Di Pierro
When posting a comment the last 5 lines are usually sufficient:

'Traceback (most recent call last):\n File "/base/data/home/apps/s~pv-4-
vp/1.372124618390164258/gluon/main.py", line 551, in wsgibase\n 
session._try_store_in_db(request, response)\n File 
"/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/globals.py", 
line 728, in _try_store_in_db\n record_id = table.insert(**dd)\n File 
"/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py", line 
7806, in insert\n ret = self._db._adapter.insert(self,self._listify(fields))\n 
File "/base/data/home/apps/s~pv-4-vp/1.372124618390164258/gluon/dal.py", 
line 4618, in insert\n rid = Reference(tmp.key().id())\nOverflowError: 
Python int too large to convert to C long\n' p6570 s.

This looks like a bug in DAL but what web2py version are you using?

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


[web2py] Re: sum the query result from other table

2013-12-05 Thread Massimo Di Pierro
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
dvd = db(db.dvd.id == detail.dvd).select().first()
total_price = dvd.acquisition_price * detail.quantity
grand_total += total_price


can be done as follows:

expr = (db.dvd.acquisition_price * db.rent_detail.quantity).sum() # you can 
build any expression!
grand_total = db(db.rent_detail.id.belongs(itds))(db.dvd.id == 
db.rent_
detail.dvd).select(expr).first()[expr]


n Thursday, 5 December 2013 21:07:17 UTC-6, 黄祥 wrote:

> i know i can do it manually like :
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> dvd = db(db.dvd.id == detail.dvd).select().first()
> total_price = dvd.acquisition_price * detail.quantity
> grand_total += total_price
>
> but i want to make it simple like on pos appliance.
> any other idea how to achieve it?
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: Scheduler-related database tables created on sqLite but NOT on MySQL

2013-12-05 Thread Massimo Di Pierro
Are you sure you have not set DAL(...,migrate_enabled=False)?

On Thursday, 5 December 2013 16:10:34 UTC-6, Yassen D. wrote:
>
> Hello all,
>
> I follow a simple video-tutorial (http://vimeo.com/27478796); so I create 
> a model scheduler.py with this content:
>
> def f():
> t = time.ctime()
> open('/tmp/tasks', 'w').write(t + '\n')
> return f
>
> from gluon.scheduler import Scheduler
> Scheduler(db, dict(our_func=f))
>
>
> After saving it, I go to the database administration of that same 
> application and can see db.scheduler_task, db.scheduler_run, 
> db.scheduler_worker links; when I click on db.scheduler_task, the form is 
> there and I can fill in the data, however, on saving, it spits this error:
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
> exec ccode in environment
>   File 
> "/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py" 
> ,
>  line 236, in 
>   File "/home/www-data/web2py/gluon/globals.py", line 372, in 
> self._caller = lambda f: f()
>   File "/home/www-data/web2py/gluon/tools.py", line 3239, in f
> return action(*a, **b)
>   File 
> "/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py" 
> ,
>  line 54, in importcontacts
> scheduler.queue_task(testfunc, pargs=[request.vars.sna], 
> kwargs=task_kwargs)
>   File "/home/www-data/web2py/gluon/scheduler.py", line 983, in queue_task
> **kwargs)
>   File "/home/www-data/web2py/gluon/dal.py", line 9114, in validate_and_insert
> value,error = self[key].validate(value)
>   File "/home/www-data/web2py/gluon/dal.py", line 10036, in validate
> (value, error) = validator(value)
>   File "/home/www-data/web2py/gluon/validators.py", line 668, in __call__
> row = subset.select(table._id, field, limitby=(0, 1), 
> orderby_on_limitby=False).first()
>   File "/home/www-data/web2py/gluon/dal.py", line 10450, in select
> return adapter.select(self.query,fields,attributes)
>   File "/home/www-data/web2py/gluon/dal.py", line 1861, in select
> return self._select_aux(sql,fields,attributes)
>   File "/home/www-data/web2py/gluon/dal.py", line 1826, in _select_aux
> self.execute(sql)
>   File "/home/www-data/web2py/gluon/dal.py", line 1948, in execute
> return self.log_execute(*a, **b)
>   File "/home/www-data/web2py/gluon/dal.py", line 1942, in log_execute
> ret = self.cursor.execute(command, *a[1:], **b)
>   File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in 
> execute
> self.errorhandler(self, exc, value)
>   File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in 
> defaulterrorhandler
> raise errorclass, errorvalue
> ProgrammingError: (1146, "Table 'socialjack.scheduler_task' doesn't exist")
>
>
> If I do the same for the welcome application, it all works as expected.
>
> Can anyone tell what is wrong here? The tables are indeed non-existent 
> when inspecting the MySQL database. This is web2py 2.8.2., updated from 
> mercurial repo, VERSION: 2.8.2-stable+timestamp.2013.12.04.19.34.45.
>
> Thanks,
> YD
>

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


Re: [web2py] Re: Spawning a thread or a process for a long-running task [urgent!]

2013-12-05 Thread Yassen Damyanov
Niphlod, HUGE THANKS! I'll check that right now and post back.

On Thu, Dec 5, 2013 at 11:53 PM, Niphlod  wrote:
> check for
> db = DAL(migrate_enabled=False)
>
> either this prevented the creation of the table, or some another
> migrate-related glitch.
> To create scheduler's tables, you just need to do (as you did)
>
> Scheduler(db, ...)
>
> NB: (just a naming-convention advice) use
> from gluon.scheduler import Scheduler
> mysched = Scheduler(db, )
> instead of
> scheduler = Scheduler(db, ...)
>
> to clearly state the difference between the module and the object that is
> used by your app ^_^
>
> If your tables are in the admin interface but not on the backend, check that
> your migrations are enabled and delete any pre-existing *scheduler*.table
> files in the databases/ folder. This will trigger the creation both of the
> new .table files and the tables on the backend.
>
> BTW: for tasks that needs **immediate** care from the scheduler, instead of
> lowering the heartbeat (and such having all workers to "hammer" the database
> asking for new tasks) just let the heartbeat as it is and use
> mysched.queue_task(., immediate=True)
> for any user needing that task to run.
> In a few sec the first available worker will pick up the task
> Plan your workers number according on how many concurrent users will need in
> your app a task to be processed: a worker can only be processing one single
> task.
>
> for @all: if you have the need of 20 or 30 concurrent tasks (and such need
> 20 or 30 workers ) test the scheduler carefully: you may find a dedicated
> database more performant and you may also need to put workers in a sleeping
> state (DISABLED) to "alleviate" the db pressure when they are not needed.
> Then you'll need to set them to ACTIVE (or just delete all the records in
> the scheduler_workers table) before queueing a new task...they'll resume
> their (working) state in a heartbeat.
> If you need more than 30 workers. use a different task processor:
> unfortunately the polling nature of the scheduler makes a "bad usecase" for
> such high demands.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/qZ_RUAfqaOY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


[web2py] Re: sum the query result from other table

2013-12-05 Thread 黄祥
i know i can do it manually like :
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
dvd = db(db.dvd.id == detail.dvd).select().first()
total_price = dvd.acquisition_price * detail.quantity
grand_total += total_price

but i want to make it simple like on pos appliance.
any other idea how to achieve it?

thanks and best regards,
stifan

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


[web2py] Out of nowhere a starnge error...

2013-12-05 Thread george3825
I was adding to my controllers and views and all of a sudden the error 
below, any ideas?

Only occurs to logged in users.
I remove extend layout from any view and this error goes away...

* need more than 1 value to unpack*
*Version**web2py™ Version 2.7.4-stable+timestamp.2013.10.14.15.16.29**Python 
Python 2.7.4: /usr/bin/python (prefix: /usr)**Traceback**1.**2.**3.**4.**5.*
*6.**7.**8.**9.**10.**11.**12.**13.**14.**15.**16.**17.**18.**Traceback 
(most recent call last):**  File 
"/home/www-data/web2py/gluon/restricted.py", line 217, in restricted**
exec ccode in environment**  File 
"/home/www-data/web2py/applications/DSM/views/default/index.html", line 71, 
in **  File "/home/www-data/web2py/gluon/globals.py", line 381, in 
write**self.body.write(xmlescape(data))**  File 
"/home/www-data/web2py/gluon/html.py", line 120, in xmlescape**return 
data.xml()**  File "/home/www-data/web2py/gluon/html.py", line 2488, in xml**  
  return self.serialize(self.data, 0).xml()**  File 
"/home/www-data/web2py/gluon/html.py", line 2453, in serialize**
li.append(self.serialize(item[3], level + 1))**  File 
"/home/www-data/web2py/gluon/html.py", line 2453, in serialize**
li.append(self.serialize(item[3], level + 1))**  File 
"/home/www-data/web2py/gluon/html.py", line 2433, in serialize**(name, 
active, link) = item[:3]**ValueError: need more than 1 value to unpack*

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


[web2py] Re: Running instantpress in GAE: Internal error Ticket issued: unrecoverable

2013-12-05 Thread Christian Foster Howes
i suspect that instapress needs to use a relational database and that if 
you use google cloud SQL you are more likely to get it to work.

the traceback from the logs would be most helpful in debugging.

On Thursday, December 5, 2013 2:55:36 AM UTC-8, peibol wrote:
>
> No, I didn't find any solution...
>
>
> El jueves, 5 de diciembre de 2013 07:51:07 UTC+1, PRACHI VAKHARIA escribió:
>>
>>
>>  
>>
>> *Did you find a Solution?*
>>
>> *If yes, what is the Solution?*
>>
>>  
>>
>> Thank you.
>>
>>
>>
>>
>>
>> On Thursday, June 13, 2013 11:29:35 AM UTC-4, peibol wrote:
>>>
>>> Hi all:
>>>
>>> Everything is running smoothly at localhost, but when deploying a raw 
>>> instantpress on GAE I get Internal error Ticket issued: unrecoverable when 
>>> trying to register or login. I'm using python 2.7, but the same thing 
>>> happens with 2.5.
>>>
>>> Any hints there?
>>>
>>> Thanks!
>>>
>>

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


Re: [web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread Christian Foster Howes
also Prachi, can you visit the GAE logs and paste in the error you are 
getting?  that might make it even quicker for us to help you sort it out.

On Thursday, December 5, 2013 1:07:37 PM UTC-8, James Burke wrote:
>
> Hi Prachi
>
> When I ran the code the form appeared. 
>
> I didn't try the form. Will do so when I get home
>
> James Burke 
>
>
> On 6/12/2013, at 8:28 am, PRACHI VAKHARIA > 
> wrote:
>
>
>
>
> Dear James,
>
> First, thank you very much for the response, and taking the effort to try 
> out the application on GAE.
>
>
>
> The *app.yaml* file I am using is configured just as you have stated.
>
>  
> runtime: python27
> threadsafe: true
>
>  
>
>  
> - url: .*
>   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
>   secure: optional
>
>  
>
>
>  
>
> I also have the *wsgihandler.py* and *gaehandler.py* in the *root web2py 
> folder* — *I think it was already there to begin with and I did not 
> tamper with it at all.*
>
>
> I have used the same application and app.yaml file to upload the 
> application to GAE before. Since I got a new computer, installed python2.7 
> and the latest w2p and GAE-launcher, I was trying to see if everything is 
> set up right and working. But it seems that it is not working once uploaded 
> to GAE, whether it is from my new computer or even my old computer.
>
>
>
> QUESTION
>
> Were you able to upload and run the application on GAE? Did the Forms 
> appear and insert-append records properly?
>
>
>
> Eagerly awaiting your reply.
>
>
>
> Gratefully,
>
> PRACHI 
>
>  
>
>  
>
>  
>
>  
>
>  
>
>
>
> On Thursday, December 5, 2013 1:44:56 PM UTC-5, James Burke wrote:
>>
>> Hi Prachi,
>>
>> Your code works fine for me, uploading to GAE.
>>
>> It may be that your app.yaml file is configured incorrectly. Do you have 
>> it setup to use python 2.5 or 2.7?
>>
>> # use this line for Python 2.5
>> #
>> #runtime: python
>>
>>
>> # use these lines for Python 2.7
>> # upload app with: appcfg.py update web2py (where 'web2py' is web2py's 
>> root directory)
>> #
>> runtime: python27
>> threadsafe: true# true for WSGI & concurrent requests (Python 2.7 
>> only)
>>
>>
>> - url: .*
>>   #script: gaehandler.py # CGI
>>   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
>>   secure: optional
>>
>> Is how mine is setup, if you don't have wsgihandler.py or gaehandler.py 
>> in your root web2py folder then you will also need to copy them from the 
>> examples folder.
>>
>  -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/ms87Y02KlIg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+un...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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


[web2py] apk for web2py application

2013-12-05 Thread 黄祥
hi, 

i'm interested in web2py apk like on web2py slices, yet during googling i 
found this :
http://www.appsgeyser.com/

already tested for web2py website and browser app apk.

best regards,
stifan

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


[web2py] Re: How would you implement paging on a google-results-like page?

2013-12-05 Thread Christian Foster Howes
can you create a module and/or a base template that you can put the 
"boilerplate" code in so you don't have to duplicate the stuffs in each 
individual controller and view?  or can you write a generic controller that 
based on parameters/POST data adjusts its queries.

On Thursday, December 5, 2013 12:32:06 PM UTC-8, Jim S wrote:
>
> Looking for advice here.
>
> Traditionally I've used SQLFORM.grid when I want to have a list where 
> people can select what record they want to work with.  That works fine for 
> me but a new app on working on has a requirement to have it's list pages 
> look more like a google search results page.  No table like features like 
> headings, columns, etc.  Just one list with a header row and a variable 
> amount of data below it.
>
> I don't have a problem creating the page, but am not sure the best way to 
> implement the paging controls.  I've got the functionality all working 
> based on 
> http://web2py.com/books/default/chapter/29/14/other-recipes#Paginationfrom 
> the book.  However, seems like a lot of boilerplate code I need to put 
> in each of my list controllers (there around 20 of these list controllers). 
>  
>
> Wondering how others have handled similar requirements and would 
> appreciate comments from anyone who wishes to share.
>
> Thanks!
>
> -Jim
>

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


[web2py] urllib2.URLError

2013-12-05 Thread sonu kumar
Hi All,

In my application I am trying to call external weblink to map data but it 
always gives me   error.

I am using several times urllib for calling same weblinks for different 
mappingWill this cause problem??? 

params = {'from':'ID', 'to':'MEROPS_ID', 'format':'tab', 'query':'P22894'}
 data = urllib.urlencode(params)
 request1 = urllib2.Request('http://www.uniprot.org/mapping/', data)
 response = urllib2.urlopen(request1, timeout=30)

params3 = {'from':'ID', 'to':'P_ENTREZGENEID', 'format':'tab', 
'query':'P22894'}
 coexdata = urllib.urlencode(params3)
 coexrequest = urllib2.Request('http://www.uniprot.org/mapping/', 
coexdata)
 coexresponse = urllib2.urlopen(coexrequest, timeout=30)

params4 = {'from':'ID', 'to':'P_ENTREZGENEID', 'format':'tab', 'query':
'P22894'}
 data6 = urllib.urlencode(params4)
 requestmmpn = urllib2.Request('http://www.uniprot.org/mapping/', data6)
 responsemmpn = urllib2.urlopen(requestmmpn, timeout=30)


I have seen one http_error_302 

611.
612.
613.
614.
615.
616.

617.
618.
619.
620.

# Don't close the fp until we are sure that we won't use it
# with HTTPError.
fp.read()
fp.close()

return self.parent.open(new, timeout=req.timeout)


http_error_301 = http_error_303 = http_error_307 = http_error_302

inf_msg = "The HTTP server returned a redirect error that would " \


any suggestion to solve this issue

Thanks


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


[web2py] Re: Prevent multiple submit buttons from showing "Working..." on submit

2013-12-05 Thread Mark Li
Hey Niphlod,

The 2 submit buttons have different names, here's the resulting HTML.










However, clicking on either results in both having the "working..." 
message. Is this not intended behavior?

One of the form submit buttons is from the SQLFORM (i add a _name attribute 
later), and the other one I insert into the form.

On Thursday, December 5, 2013 12:50:00 PM UTC-8, Niphlod wrote:
>
> uhm, you're right. However, usually with different submit buttons you'd 
> likely have one of them having a "name" attribute (and those are "excluded" 
> from being put in the "working..." state) is this your case ?
>
> How are you handling different "posts" based on the fact that the user 
> clicks on one instead of the other ?
>
> BTW2: if any "clickable-something" has a data-w2p_disable_with attribute, 
> that one is used instead of the default "Working..." message  
>
>
>
>

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


Re: [web2py] session cookie for two subdomains

2013-12-05 Thread Marin Pranjić
^bump


On Thu, Dec 5, 2013 at 8:22 PM, Marin Pranjić wrote:

> Hi,
>
> I have two subdomains for one app, and I need to use both.
> So I have to set "Domain" header in session cookie to the domain root (.
> domain.com).
> Where should I put that code? Not sure how exactly to do it for session
> cookie.
>
> Marin
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


[web2py] Re: sum the query result from other table

2013-12-05 Thread 黄祥
yes, you are right, i know where is the root cause, btw, it's funny the 
length of db(db.rent_detail.id.belongs(ids)) is return 0, yet i still can 
insert the value to other table.
e.g.
def outstanding_rent():
grid = SQLFORM.grid(db.rent_detail.status == 'Rent', 
selectable = lambda ids : redirect(URL('checkout', vars = dict(ids = ids) ) 
) )
return locals()

def checkout():
ids = request.vars.ids
return dict(ids = ids)

def compensation():
ids = request.vars.ids
 #grand_total = sum(item.dvd.acquisition_price * item.quantity for item in 
db(db.rent_detail.id.belongs(ids) ).select(db.rent_detail.dvd, 
db.rent_detail.quantity) ) ## result 0
#grand_total = sum(2 * 2 for item in db(db.rent_detail.id.belongs(ids) 
).select(db.rent_detail.dvd, db.rent_detail.quantity) ) ## result 0
grand_total = len(db(db.rent_detail.id.belongs(ids) ).select() ) ## result 0
 db.compensation_header.insert(grand_total = grand_total)
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
dvd = db(db.dvd.id == detail.dvd).select().first()
db.compensation_detail.insert(rent_no = detail.rent_no, 
  customer = detail.customer, 
  dvd = detail.dvd, 
  quantity = detail.quantity, 
  price = dvd.acquisition_price, 
  grand_total = grand_total)
redirect(URL('report', 'report_compensation') )

in code above the grand_total result is 0 (base on print length of 
db(db.rent_detail.id.belongs(ids)), but i still can insert the 
compensation_detail table with the correct value got from rent_detail value.

i'm not sure where my error on code above, because no traceback occured.

is there any way to achieve it?

thanks and best regards,
stifan

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


Re: [web2py] PostgreSQL lower case id seq values

2013-12-05 Thread Michele Comitini
Test with trunk. We have done some improvements about case sensitivity.
 And now lastval() is used in place of curval() i.e. safer and faster.





2013/12/5 Alan Etkin 

> (translated from a message of Martin Miranda to web2py-usuarios)
>
> "... After upgrading to web2py 2.8.2-stable+timestamp.2013.11.28.13.54.07
> my app throws the following error:
>
> (relation "testSeq_id_seq" does not
> exist LINE 1: select currval('"testSeq_id_seq"') ^ )
>
> I've been using Postgres 9.1. While pgAdmin shows only lower case table
> names, web2py model tables are defined using upper and lower case, for
> example:
>
> WEB2PY: db.define_table('testSeq', Field(...))
> pgAdmin: Tables: testseq
>  Sequence: testseq_id_seq
>
> For avoiding the error shown above, an option was to add the argument
> sequence_name="%s_id_seq" % str(table).lower() (for each table defined).
>
> Another option, maybe that could be considered to be added to the dal
> module:
>
> In PostgreSQLAdapter class -> sequence_name method.
>
> def sequence_name(self,table):
> # return '%s_id_seq' % table -> before.
> return '%s_id_seq' % str(table).lower()
>
> So, I hope this is helpfull ..."
>
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: [web2py] Re: Suggestions for multiple files upload in form

2013-12-05 Thread Ruud Schroen
Works like a charm! Thanks alot :)


On Wed, Dec 4, 2013 at 11:55 PM, Ruud Schroen  wrote:

> Thanks alot! I'll check it out tommorow :) i'll let you know if it worked
>
>
> On Wed, Dec 4, 2013 at 9:54 PM, Paolo Caruccio  > wrote:
>
>> There are several  compatibility problems between foundation css and
>> multiupload. You'll find here attached the patched files. Now it should
>> work also with foundation (I tested the code with foundation 5.0.2) and
>> also with jquery > 1.9
>>
>> Il giorno martedì 3 dicembre 2013 00:01:21 UTC+1, Ruud Schroen ha scritto:
>>
>>> Hi,
>>>
>>> I know this is an old thread, but I have a question.
>>>
>>> The upload and everything is working fine, but for some reason it
>>> doesn't work when bootstrap.min.css (the default one by web2py) is NOT
>>> included. This is kinda stupid because i'm using Foundation. Any idea
>>> what's going on?
>>>
>>> On Friday, October 28, 2011 2:40:12 AM UTC+2, Paolo Caruccio wrote:

 I wasn't able to find in the web, even in this group, a multiple files
 upload system with the followings requirements:

 - upload the files together with form submit
 - no frame, no flash, no ajax form submit but only jquery and python
 - give a title to the uploading files
 - simple to integrate and control in web2py

 so, inspired by http://the-stickman.com/web-
 development/javascript/upload-multiple-files-with-a-single-
 file-element/, I wrote one by my self.
 It's minimalist and the code isn't optimized (I'm not a programmer),
 but it works for my purposes.

 If you would like to test it in default welcome web2py app:
  - put jquery.multiuploads.js in static/js folder
  - put multiuploads.css in static/css folder
  - append the functions to default.py in controllers folder
  - append the table definition to db.py in models folder
  - put upload_documents.html in views folder

 You'll find some comments in the code and also many errors.

 I look forward to your suggestions and opinions.

 Ciao.

 Paolo

>>>  --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/XpnUb2_MaRc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


[web2py] PostgreSQL lower case id seq values

2013-12-05 Thread Alan Etkin
(translated from a message of Martin Miranda to web2py-usuarios)

"... After upgrading to web2py 2.8.2-stable+timestamp.2013.11.28.13.54.07 
my app throws the following error:

(relation "testSeq_id_seq" does not 
exist LINE 1: select currval('"testSeq_id_seq"') ^ )

I've been using Postgres 9.1. While pgAdmin shows only lower case table 
names, web2py model tables are defined using upper and lower case, for 
example:

WEB2PY: db.define_table('testSeq', Field(...))
pgAdmin: Tables: testseq 
 Sequence: testseq_id_seq

For avoiding the error shown above, an option was to add the argument 
sequence_name="%s_id_seq" % str(table).lower() (for each table defined).

Another option, maybe that could be considered to be added to the dal 
module:

In PostgreSQLAdapter class -> sequence_name method.

def sequence_name(self,table):
# return '%s_id_seq' % table -> before.
return '%s_id_seq' % str(table).lower()

So, I hope this is helpfull ..."


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


[web2py] Scheduler-related database tables created on sqLite but NOT on MySQL

2013-12-05 Thread Yassen D.
Hello all,

I follow a simple video-tutorial (http://vimeo.com/27478796); so I create a 
model scheduler.py with this content:

def f():
t = time.ctime()
open('/tmp/tasks', 'w').write(t + '\n')
return f

from gluon.scheduler import Scheduler
Scheduler(db, dict(our_func=f))


After saving it, I go to the database administration of that same 
application and can see db.scheduler_task, db.scheduler_run, 
db.scheduler_worker links; when I click on db.scheduler_task, the form is 
there and I can fill in the data, however, on saving, it spits this error:

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
  File 
"/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py" 
,
 line 236, in 
  File "/home/www-data/web2py/gluon/globals.py", line 372, in 
self._caller = lambda f: f()
  File "/home/www-data/web2py/gluon/tools.py", line 3239, in f
return action(*a, **b)
  File 
"/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py" 
,
 line 54, in importcontacts
scheduler.queue_task(testfunc, pargs=[request.vars.sna], kwargs=task_kwargs)
  File "/home/www-data/web2py/gluon/scheduler.py", line 983, in queue_task
**kwargs)
  File "/home/www-data/web2py/gluon/dal.py", line 9114, in validate_and_insert
value,error = self[key].validate(value)
  File "/home/www-data/web2py/gluon/dal.py", line 10036, in validate
(value, error) = validator(value)
  File "/home/www-data/web2py/gluon/validators.py", line 668, in __call__
row = subset.select(table._id, field, limitby=(0, 1), 
orderby_on_limitby=False).first()
  File "/home/www-data/web2py/gluon/dal.py", line 10450, in select
return adapter.select(self.query,fields,attributes)
  File "/home/www-data/web2py/gluon/dal.py", line 1861, in select
return self._select_aux(sql,fields,attributes)
  File "/home/www-data/web2py/gluon/dal.py", line 1826, in _select_aux
self.execute(sql)
  File "/home/www-data/web2py/gluon/dal.py", line 1948, in execute
return self.log_execute(*a, **b)
  File "/home/www-data/web2py/gluon/dal.py", line 1942, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in 
execute
self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in 
defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'socialjack.scheduler_task' doesn't exist")


If I do the same for the welcome application, it all works as expected.

Can anyone tell what is wrong here? The tables are indeed non-existent when 
inspecting the MySQL database. This is web2py 2.8.2., updated from 
mercurial repo, VERSION: 2.8.2-stable+timestamp.2013.12.04.19.34.45.

Thanks,
YD

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


[web2py] Re: sum the query result from other table

2013-12-05 Thread Massimo Di Pierro
Are you sure you are selecting records:

print len(db(db.rent_detail.id.belongs(ids) ).select() )

On Thursday, 5 December 2013 15:46:01 UTC-6, 黄祥 wrote:
>
> hi,
>
> i learned from pos online store appliance about sum the session to acquire 
> the grand_total, when i tried to do the same to query result from other 
> table, is not work (no error appears, but the result always 0).
> e.g. not worked
> ids = request.vars.ids
> grand_total = sum(item.dvd.acquisition_price * item.quantity for item in 
> db(db.rent_detail.id.belongs(ids) ).select(db.rent_detail.dvd, 
> db.rent_detail.quantity) )
>
> even i put the exact number not variable, the result is same (no error 
> occured, but the result always 0)
> e.g. not worked
> ids = request.vars.ids
> grand_total = sum(2 * 2 for item in db(db.rent_detail.id.belongs(ids) 
> ).select(db.rent_detail.dvd, db.rent_detail.quantity) )
>
> is there a way i can achieve it?
>
> thanks and best regards,
> stifan
>

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


Re: [web2py] Re: bulk_upload to GAE development datastore no longer works?

2013-12-05 Thread Christian Foster Howes
ok, it must be a different error.  this is the bulkupload error that i 
am watching: https://code.google.com/p/googleappengine/issues/detail?id=9666


there are several issues logged against the bulkuploader though: 
https://code.google.com/p/googleappengine/issues/list?can=2&q=bulkloader&colspec=ID+Type+Component+Status+Stars+Summary+Language+Priority+Owner+Log&cells=tiles


On 12/5/13, 12:39 , David Manns wrote:

Do you have a reference for this? I went back to 1.8.0 and problem is same.
Also tried some 1.7x versions, higher versions with same result. Early 1.7x
versions I think ran only on Python 2.5 and probably because of other
changes in the yaml file and the --use_sqlite app parameter can't get these
to run at all.

Thanks!

On Thursday, December 5, 2013 1:39:37 AM UTC-5, Christian Foster Howes
wrote:


this is a documented GAE SDK bug.  you'll have to downgrade your GAE SDK
to the last working version of this.  i *think* the last working version is
1.8.1

On Wednesday, December 4, 2013 8:46:31 AM UTC-8, David Manns wrote:


My application runs on GAE. Using Google's bulk loader I make occasional
backups of the database. It used to be that I could use the GAE SDK (appcfg
tool in this case) to upload all the data into the development server on my
development machine, thus creating the full data context for the SDK.

This now fails. I'm not sure (or if) how the remote_api validates the
provided email/password, but the results are the same failure with all
sensible choices of password, e.g. the primary google account password (the
account owns the app on GAE), the application specific password used for
the bulk download for GAE (the gmail account uses 2 factor authentication),
or no password.

I attach the script used to run the development upload (which used to
work until recently) and the command window output from running it. Also
the app.yaml file.

Anyone have any idea what the problem might be?







--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: SQLite Integrity error after update to 2.8.2. => Widget problem?

2013-12-05 Thread Massimo Di Pierro
I understand and I do not understand why the problem arises there but your 
error is:

 foreign key constraint failed

So I would exclude it is a problem with the foreign key contraints.

On Thursday, 5 December 2013 09:46:59 UTC-6, Loïc wrote:
>
> I know Massimo, but my problem seems to be located in the Widget management
> And that's why I started my message with "
> *I have the same problem as the one explained here : 
> https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E 
> But 
> as I have more specific informations, I start a new thread...*"
>
> Do you have any hints about that?
> Thank you
>
> Le jeudi 5 décembre 2013 16:27:55 UTC+1, Massimo Di Pierro a écrit :
>>
>> The problem is discussed here: 
>> https://groups.google.com/forum/#!topic/web2py/klspqXpha4E
>>
>> On Thursday, 5 December 2013 05:04:17 UTC-6, Loïc wrote:
>>>
>>> Hello all-
>>>
>>> I have the same problem as the one explained here 
>>> :https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E
>>> But as I have more specific informations, I start a new thread...
>>>
>>> *My Model (simplified) : *
>>> db.define_table('page',
>>> Field('parent', 'reference page', label=T('Parent')),
>>> Field('title', unique=True, notnull=True, label=T('Title')))
>>>
>>> db.page.parent.requires = IS_EMPTY_OR(IS_IN_DB(db, db.page.id, 
>>> '%(title)s', zero=T('')))
>>> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.
>>> rank)
>>> db.page.parent.widget = pageSelector.widget
>>>
>>> The goal of the HierarchicalSelect widget is to have a "tree-view" of 
>>> all my pages. More elegant than the default selector
>>>
>>> *My Controller (simplified)*
>>> def edit_page():
>>> page = db.page(request.args(0))
>>> crud.settings.update_deletable = False
>>> form = crud.update(db.page,page,next=URL('show_page', args=page.id))
>>> return dict(form=form)
>>>
>>> From 2.8.2 update, when I update a page, I get an error : 
>>>  foreign key constraint failed
>>>
>>> This error *occurs only when I update a page and select "" value 
>>> for the "parent" field.*
>>> When I *remove the two following lines of my model definition, 
>>> everything works fine*
>>> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.
>>> rank)
>>> db.page.parent.widget = pageSelector.widget
>>>
>>>
>>> So the error seems to be in my HierarchicalSelect class.
>>> *Here is the code : *
>>> class HierarchicalSelect(object):
>>> def __init__(self, db, table_name, title_field, order_field):
>>> self.options=[]
>>> self.db = db
>>> self.tablename = table_name
>>> self.fieldname = None
>>> self.title = title_field
>>> self.order = order_field
>>> self.type = None
>>> self.rows=None
>>> self.hierarchyseparator = XML(" "*4)
>>>
>>> def _childs_list(self, field, depth):
>>> path = self.hierarchyseparator*depth
>>>
>>> path += self.hierarchyseparator
>>> self.options.append((field['id'], path+field[self.title]))
>>> [self._childs_list(child, (depth+1)) for child in self.rows.find
>>> (lambda row: row.parent == field.id)]   
>>>
>>> def widget(self, field, value):
>>> self.fieldname = field.name
>>> self.type = field.type
>>> self.rows = self.db(self.tablename).select(orderby=self.order)
>>> self.options.append(("", T(''))) #add root node
>>>
>>> [self._childs_list(field,0) for field in self.rows.find(lambdarow
>>> : row.parent < 1)] 
>>> opt=[OPTION(name, _value=key) for key,name in self.options]
>>> sel = SELECT(opt,_id="%s_%s" % (self.tablename, self.fieldname),
>>> _class="generic-widget", 
>>> _name=self.fieldname,
>>> value=value)
>>> return sel
>>>
>>> *HTML generated with the default SELECT helper for the first option (the 
>>> option that causes error)*
>>>
>>> >> value="">
>>>
>>>
>>> *HTML generated with my Widget* *for the first option (the option that 
>>> causes error)*
>>> >> value="">
>>>
>>>
>>> The HTML seems to be the same, so I don't understand what's wrong with my 
>>> widget...
>>>
>>>
>>> Can anybody help me with that?
>>> Thank you
>>>
>>

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


[web2py] Re: web2py real time apps

2013-12-05 Thread bharath
Hii massimo,

Can u help me out in real app development with web2py. Like 
integrating socketio and sockjs with web2py.

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


[web2py] Re: Using find on cached queries

2013-12-05 Thread Niphlod
peeerfect!

On Thursday, December 5, 2013 10:26:12 PM UTC+1, Anthony wrote:
>
>
> Yes, good point. I just wanted to make it clear that cacheable=True is not 
> *required* when using cache=, and in fact it reduces the functionality 
> normally available when using cache=. For pure speed, cacheable=True is a 
> good idea, though in that case, you can just directly cache the object if 
> you like.
>
> Anthony
>

 

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


[web2py] Re: Spawning a thread or a process for a long-running task [urgent!]

2013-12-05 Thread Niphlod
check for 
db = DAL(migrate_enabled=False)

either this prevented the creation of the table, or some another 
migrate-related glitch.
To create scheduler's tables, you just need to do (as you did)

Scheduler(db, ...)

NB: (just a naming-convention advice) use 
from gluon.scheduler import Scheduler
mysched = Scheduler(db, )
instead of
scheduler = Scheduler(db, ...)

to clearly state the difference between the module and the object that is 
used by your app ^_^

If your tables are in the admin interface but not on the backend, check 
that your migrations are enabled and delete any pre-existing 
*scheduler*.table files in the databases/ folder. This will trigger the 
creation both of the new .table files and the tables on the backend.

BTW: for tasks that needs **immediate** care from the scheduler, instead of 
lowering the heartbeat (and such having all workers to "hammer" the 
database asking for new tasks) just let the heartbeat as it is and use
mysched.queue_task(., immediate=True)
for any user needing that task to run.
In a few sec the first available worker will pick up the task
Plan your workers number according on how many concurrent users will need 
in your app a task to be processed: a worker can only be processing one 
single task.

for @all: if you have the need of 20 or 30 concurrent tasks (and such need 
20 or 30 workers ) test the scheduler carefully: you may find a dedicated 
database more performant and you may also need to put workers in a sleeping 
state (DISABLED) to "alleviate" the db pressure when they are not needed. 
Then you'll need to set them to ACTIVE (or just delete all the records in 
the scheduler_workers table) before queueing a new task...they'll resume 
their (working) state in a heartbeat.
If you need more than 30 workers. use a different task processor: 
unfortunately the polling nature of the scheduler makes a "bad usecase" for 
such high demands.

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


[web2py] sum the query result from other table

2013-12-05 Thread 黄祥
hi,

i learned from pos online store appliance about sum the session to acquire 
the grand_total, when i tried to do the same to query result from other 
table, is not work (no error appears, but the result always 0).
e.g. not worked
ids = request.vars.ids
grand_total = sum(item.dvd.acquisition_price * item.quantity for item in 
db(db.rent_detail.id.belongs(ids) ).select(db.rent_detail.dvd, 
db.rent_detail.quantity) )

even i put the exact number not variable, the result is same (no error 
occured, but the result always 0)
e.g. not worked
ids = request.vars.ids
grand_total = sum(2 * 2 for item in db(db.rent_detail.id.belongs(ids) 
).select(db.rent_detail.dvd, db.rent_detail.quantity) )

is there a way i can achieve it?

thanks and best regards,
stifan

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


[web2py] Re: Using find on cached queries

2013-12-05 Thread Anthony

>
> On Wednesday, December 4, 2013 4:57:03 PM UTC+1, Anthony wrote:
>>
>> First, if you are using cache=..., you do not also need to set 
>> cacheable=True. Using the former, the DAL automatically handles caching for 
>> you. Setting cacheable=True is only for cases where you want to manually 
>> cache the Rows object, so you wouldn't be using cache=... in that case.
>>
>
> Uhm... if I don't want auto-references, row.update_record() and 
> row.delete_record() I use cacheable=True AND cache=cache.ram (or 
> something). 
> cacheable=True brings a noticeable speedup for large datasets, however for 
> a small set, I completely agree
>

Yes, good point. I just wanted to make it clear the cacheable=True is not 
*required* when using cache=, and in fact it reduces the functionality 
normally available when using cache=. For pure speed, cacheable=True is a 
good idea, though in that case, you can just directly cache the object if 
you like.

Anthony

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


Re: [web2py] Re: Failure after upgrade to 2.8.2

2013-12-05 Thread Niphlod
it's not a "feature" per-se but DAL has suffered a complete overhaul to 
accomodate for new features and some bug squashing.
What used to be a "commodity" leading to "faulty" data models indeed put 
the developers (me and Michele Comitini) to face a really hard problem to 
solve to support those kinds of tunrarounds. 
Let's say its a bug but - at least - let me clearly state that referencing 
a table that doesn't exist yet is not a "normal thing to do" :D

On Thursday, December 5, 2013 10:08:33 PM UTC+1, Jim S wrote:
>
> Thanks Niphlod. I agree the model doesn't make sense.  Made sense at the 
> time only for simplicity of defining one and only one group a user could 
> belong to.  I understand it is not the right way to do things.  But, 
> working on a rewrite of that app and will be redesigning the auth_user 
> table to get rid of that.  If I'm the only one complaining then it isn't 
> worth filing a but report to keep a 'feature' that is not necessary.
>
>
> On Thu, Dec 5, 2013 at 2:42 PM, Niphlod >wrote:
>
>> I guess this is a problem due to out-of-order reference definitions.
>> it's quite a leap to require web2py to know about auth_group when it's 
>> not defined yet...
>> Frankly, it should be treated as a bug (so, file an issue on google code) 
>> only because of backwards compatibility
>>
>> BTW, 
>> auth_groups has a FK to auth_membership
>> auth_membership has a FK to auth_groups and a FK to auth_user
>> your model doesn't make any sense (and frankly, it's a waste of 
>> functionality and doesn't improve any performance) you're restricting a 
>> user to be part of only one group, jumping from auth_user to auth_groups 
>> without "passing" from auth_membership.
>>
>>
>> On Thursday, December 5, 2013 3:36:17 AM UTC+1, Jim S wrote:
>>>
>>> The following code is failing after update from 2.8.x to 2.8.2 (not 
>>> positive what version I came from)
>>>
>>>
>>> auth.settings.hmac_key = 'sha512:9d8d83af-4769-410b-9cf5-e01a163b498d'  # 
>>> before define_tables()
>>>
>>> auth.settings.extra_fields['auth_user']= [
>>> Field('auth_group', 'reference auth_group', label='Group', 
>>>   requires=IS_EMPTY_OR(IS_IN_DB(db, 'auth_group.id', 
>>> '%(group)s'))),
>>> Field('phone', 'string', length=20),
>>> Field('active', 'boolean', default=True),
>>> Field('image', 'upload'),
>>> Field('created', 'datetime', default=request.now, writable=False
>>> ),
>>> Field('supplier', 'reference supplier', requires=IS_EMPTY_OR(
>>> IS_IN_DB(db, 'supplier.id'))),
>>> Field('distributor', 'reference distributor', requires=
>>> IS_EMPTY_OR(IS_IN_DB(db, 'distributor.id'))),
>>> Field('fax', 'string', length=20)
>>> ]
>>>
>>> ## create all tables needed by auth if not custom tables
>>> auth.define_tables(username=True, signature=False)
>>>
>>>
>>>
>>> The following traceback is generated:
>>>
>>> Traceback (most recent call last):
>>>  File "C:\dev\web2py\gluon\restricted.py", line 217, in restricted
>>>  exec ccode in environment
>>>  File 
>>> "C:/dev/web2py/applications/ibc/models/db.py"
>>> , line 69, in 
>>>  auth.define_tables(username=True, signature=False)
>>>  File "C:\dev\web2py\gluon\tools.py", line 1707, in define_tables
>>>  format='%(username)s'))
>>>  File "C:\dev\web2py\gluon\dal.py", line 8226, in define_table
>>>  table = self.lazy_define_table(tablename,*fields,**args)
>>>  File "C:\dev\web2py\gluon\dal.py", line 8263, in lazy_define_table
>>>  polymodel=polymodel)
>>>  File "C:\dev\web2py\gluon\dal.py", line 908, in create_table
>>>  raise KeyError('Cannot resolve reference %s in %s definition' % (
>>> referenced, table._tablename))
>>> KeyError: 'Cannot resolve reference auth_group in auth_user definition'
>>>
>>>
>>>
>>>
>>>  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/T1kli0maSBE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


[web2py] Re: The procedure entry point wcspy_s could not be located in the dynamic link library msvcrt.dll

2013-12-05 Thread Niphlod
recent web2py version enforce FK integrity on SQLite (as any other 
relational backend does by default) to prevent users from working on the 
development with SQLite without realizing that there is some really faulty 
data in the database. Too many incurred in the problem too late to know... 
check your data and fix it before it's too late ^_^

On Monday, December 2, 2013 12:49:40 AM UTC+1, Alex Glaros wrote:
>
> When upgrading to 2.8.2  today on Windows Home XP, I get this error when 
> trying to boot W2P:
>
> The procedure entry point wcspy_s could not be located in the dynamiclink 
> library msvcrt
> .dll
>
> I restore to earlier Windows version to remove the DLL error and get W2P 
> working, but then get the following error when adding a record via a form:
>
>  foreign key constraint failed
>
> Same controller works for 7.2.4.  No DLL and no foreign key error.
>
> On another Windows 7 machine I don't get DLL error but get foreign key 
> constraint error on same app that works with W2P 7.2.4
>
> Alex Glaros
>

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


Re: [web2py] Re: Failure after upgrade to 2.8.2

2013-12-05 Thread Jim Steil
Thanks Niphlod. I agree the model doesn't make sense.  Made sense at the
time only for simplicity of defining one and only one group a user could
belong to.  I understand it is not the right way to do things.  But,
working on a rewrite of that app and will be redesigning the auth_user
table to get rid of that.  If I'm the only one complaining then it isn't
worth filing a but report to keep a 'feature' that is not necessary.


On Thu, Dec 5, 2013 at 2:42 PM, Niphlod  wrote:

> I guess this is a problem due to out-of-order reference definitions.
> it's quite a leap to require web2py to know about auth_group when it's not
> defined yet...
> Frankly, it should be treated as a bug (so, file an issue on google code)
> only because of backwards compatibility
>
> BTW,
> auth_groups has a FK to auth_membership
> auth_membership has a FK to auth_groups and a FK to auth_user
> your model doesn't make any sense (and frankly, it's a waste of
> functionality and doesn't improve any performance) you're restricting a
> user to be part of only one group, jumping from auth_user to auth_groups
> without "passing" from auth_membership.
>
>
> On Thursday, December 5, 2013 3:36:17 AM UTC+1, Jim S wrote:
>>
>> The following code is failing after update from 2.8.x to 2.8.2 (not
>> positive what version I came from)
>>
>>
>> auth.settings.hmac_key = 'sha512:9d8d83af-4769-410b-9cf5-e01a163b498d'   #
>> before define_tables()
>>
>> auth.settings.extra_fields['auth_user']= [
>> Field('auth_group', 'reference auth_group', label='Group',
>>   requires=IS_EMPTY_OR(IS_IN_DB(db, 'auth_group.id',
>> '%(group)s'))),
>> Field('phone', 'string', length=20),
>> Field('active', 'boolean', default=True),
>> Field('image', 'upload'),
>> Field('created', 'datetime', default=request.now, writable=False
>> ),
>> Field('supplier', 'reference supplier', requires=IS_EMPTY_OR(
>> IS_IN_DB(db, 'supplier.id'))),
>> Field('distributor', 'reference distributor', requires=
>> IS_EMPTY_OR(IS_IN_DB(db, 'distributor.id'))),
>> Field('fax', 'string', length=20)
>> ]
>>
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=True, signature=False)
>>
>>
>>
>> The following traceback is generated:
>>
>> Traceback (most recent call last):
>>  File "C:\dev\web2py\gluon\restricted.py", line 217, in restricted
>>  exec ccode in environment
>>  File 
>> "C:/dev/web2py/applications/ibc/models/db.py"
>> , line 69, in 
>>  auth.define_tables(username=True, signature=False)
>>  File "C:\dev\web2py\gluon\tools.py", line 1707, in define_tables
>>  format='%(username)s'))
>>  File "C:\dev\web2py\gluon\dal.py", line 8226, in define_table
>>  table = self.lazy_define_table(tablename,*fields,**args)
>>  File "C:\dev\web2py\gluon\dal.py", line 8263, in lazy_define_table
>>  polymodel=polymodel)
>>  File "C:\dev\web2py\gluon\dal.py", line 908, in create_table
>>  raise KeyError('Cannot resolve reference %s in %s definition' % (
>> referenced, table._tablename))
>> KeyError: 'Cannot resolve reference auth_group in auth_user definition'
>>
>>
>>
>>
>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/T1kli0maSBE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: [web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread James Burke
Hi Prachi

When I ran the code the form appeared. 

I didn't try the form. Will do so when I get home

James Burke 


> On 6/12/2013, at 8:28 am, PRACHI VAKHARIA  wrote:
> 
> 
> 
> 
> Dear James,
> First, thank you very much for the response, and taking the effort to try out 
> the application on GAE.
> 
> 
> The app.yaml file I am using is configured just as you have stated.
>  
> runtime: python27
> threadsafe: true
>  
>  
> - url: .*
>   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
>   secure: optional
>  
> 
>  
> I also have the wsgihandler.py and gaehandler.py in the root web2py folder — 
> I think it was already there to begin with and I did not tamper with it at 
> all.
> 
> I have used the same application and app.yaml file to upload the application 
> to GAE before. Since I got a new computer, installed python2.7 and the latest 
> w2p and GAE-launcher, I was trying to see if everything is set up right and 
> working. But it seems that it is not working once uploaded to GAE, whether it 
> is from my new computer or even my old computer.
> 
> 
> QUESTION
> Were you able to upload and run the application on GAE? Did the Forms appear 
> and insert-append records properly?
> 
> 
> Eagerly awaiting your reply.
> 
> 
> Gratefully,
> PRACHI 
>  
>  
>  
>  
>  
> 
> 
>> On Thursday, December 5, 2013 1:44:56 PM UTC-5, James Burke wrote:
>> Hi Prachi,
>> 
>> Your code works fine for me, uploading to GAE.
>> 
>> It may be that your app.yaml file is configured incorrectly. Do you have it 
>> setup to use python 2.5 or 2.7?
>> 
>> # use this line for Python 2.5
>> #
>> #runtime: python
>> 
>> 
>> # use these lines for Python 2.7
>> # upload app with: appcfg.py update web2py (where 'web2py' is web2py's root 
>> directory)
>> #
>> runtime: python27
>> threadsafe: true# true for WSGI & concurrent requests (Python 2.7 only)
>> 
>> 
>> - url: .*
>>   #script: gaehandler.py # CGI
>>   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
>>   secure: optional
>> 
>> Is how mine is setup, if you don't have wsgihandler.py or gaehandler.py in 
>> your root web2py folder then you will also need to copy them from the 
>> examples folder.
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/ms87Y02KlIg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


[web2py] Re: Using find on cached queries

2013-12-05 Thread Niphlod


On Wednesday, December 4, 2013 4:57:03 PM UTC+1, Anthony wrote:
>
> First, if you are using cache=..., you do not also need to set 
> cacheable=True. Using the former, the DAL automatically handles caching for 
> you. Setting cacheable=True is only for cases where you want to manually 
> cache the Rows object, so you wouldn't be using cache=... in that case.
>

Uhm... if I don't want auto-references, row.update_record() and 
row.delete_record() I use cacheable=True AND cache=cache.ram (or 
something). 
cacheable=True brings a noticeable speedup for large datasets, however for 
a small set, I completely agree
 

>
> Second, the .find() method is a method of the Rows object and has nothing 
> to do with caching. It loops through the records in the Rows object and 
> extracts just the Rows that satisfy the search criteria. In this case, your 
> filter function includes row.contato.site, which is a recursive select, so 
> it is doing an additional db select for every Row in reports. Furthermore, 
> you are not caching the testdrives object, so this happens on every 
> request, even if the reports object has been cached.
>
> Instead of using the .find() method to filter the reports objects, it 
> would probably be much more efficient to simply do an additional database 
> query to get the testdrives records, using either a join or a nested select.
>
>
+1000 . For any folk listening.be careful doing things like 
row.reference_field.referenced_table_field.  Use joins!

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


[web2py] Re: Prevent multiple submit buttons from showing "Working..." on submit

2013-12-05 Thread Niphlod
uhm, you're right. However, usually with different submit buttons you'd 
likely have one of them having a "name" attribute (and those are "excluded" 
from being put in the "working..." state) is this your case ?

How are you handling different "posts" based on the fact that the user 
clicks on one instead of the other ?

BTW2: if any "clickable-something" has a data-w2p_disable_with attribute, 
that one is used instead of the default "Working..." message  



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


[web2py] Re: compute not working on update

2013-12-05 Thread 黄祥
tested in 2.8.2 still got the problem, about compute field during updates, 
although the update is not related with the compute field.
e.g.
update the status field on rent table, when i insert the revert / 
compensation table using after insert callback. yet the compute i use is 
for total_price field on rent table.

how can i achieve it? or is this issue is not resolve yet?

thanks and best regards,
stifan

On Saturday, May 26, 2012 9:27:54 PM UTC+7, Massimo Di Pierro wrote:
>
> Can you please open an issue about the compute on update problem? I will 
> try reproduce and fix it.
>
> On Saturday, 26 May 2012 07:11:28 UTC-5, peter wrote:
>>
>> So
>>
>> def update_images():
>> rows=db(db.image).select()
>> for row in rows:
>> row.update(file=row.file)
>> db.commit()
>>
>> does work. I wrote (title=row.title) as I was a little loath to write 
>> (file=row.file) as I was not sure if this was okay with 'upload' fields. 
>> Clearly it is.
>>
>> Thinking about it more, a cleaner way of doing it is:
>>
>> def update_images():
>> rows=db(db.image).select()
>> for row in rows:
>> row.update(thumb=THUMB(row['file'])
>> db.commit()
>>
>> and bypass the compute altogether.
>>
>> HOWEVER I still have the strange situation that the compute gets executed 
>> when one creates a new record, but does not get executed when one edits a 
>> record, even when one changes the image which is stored in 'file'. the 
>> editing is done by clicking the 'edit' link in SQLFORM.grid.
>>
>> Peter
>>
>>
>>
>>
>>
>> On Friday, May 25, 2012 6:50:33 PM UTC+1, peter wrote:
>>>
>>> I am using web2py 1.99.7 
>>>
>>> I have a compute as
>>>
>>> db.image.thumb.compute=lambda r:THUMB(r['file'])
>>>
>>>
>>> I update the whole database 
>>>
>>> def update_images():
>>> rows=db(db.image).select()
>>> for row in rows:
>>> row.update(title=row.title)
>>> db.commit()
>>>
>>>
>>> Yet, the computes have not occurred.
>>>
>>> Similarly if I edit a record and submit, no compute. Yet if I add a 
>>> record, the compute does take place.
>>>
>>> Anyone any ideas why?
>>>
>>> Thanks
>>> Peter
>>>
>>

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


[web2py] Re: Failure after upgrade to 2.8.2

2013-12-05 Thread Niphlod
I guess this is a problem due to out-of-order reference definitions.
it's quite a leap to require web2py to know about auth_group when it's not 
defined yet...
Frankly, it should be treated as a bug (so, file an issue on google code) 
only because of backwards compatibility

BTW, 
auth_groups has a FK to auth_membership
auth_membership has a FK to auth_groups and a FK to auth_user
your model doesn't make any sense (and frankly, it's a waste of 
functionality and doesn't improve any performance) you're restricting a 
user to be part of only one group, jumping from auth_user to auth_groups 
without "passing" from auth_membership.


On Thursday, December 5, 2013 3:36:17 AM UTC+1, Jim S wrote:
>
> The following code is failing after update from 2.8.x to 2.8.2 (not 
> positive what version I came from)
>
>
> auth.settings.hmac_key = 'sha512:9d8d83af-4769-410b-9cf5-e01a163b498d'   # 
> before define_tables()
>
> auth.settings.extra_fields['auth_user']= [
> Field('auth_group', 'reference auth_group', label='Group', 
>   requires=IS_EMPTY_OR(IS_IN_DB(db, 'auth_group.id', 
> '%(group)s'))),
> Field('phone', 'string', length=20),
> Field('active', 'boolean', default=True),
> Field('image', 'upload'),
> Field('created', 'datetime', default=request.now, writable=False),
> Field('supplier', 'reference supplier', requires=IS_EMPTY_OR(
> IS_IN_DB(db, 'supplier.id'))),
> Field('distributor', 'reference distributor', requires=IS_EMPTY_OR
> (IS_IN_DB(db, 'distributor.id'))),
> Field('fax', 'string', length=20)
> ]
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=True, signature=False)
>
>
>
> The following traceback is generated:
>
> Traceback (most recent call last):
>  File "C:\dev\web2py\gluon\restricted.py", line 217, in restricted
>  exec ccode in environment
>  File 
> "C:/dev/web2py/applications/ibc/models/db.py"
> , line 69, in 
>  auth.define_tables(username=True, signature=False)
>  File "C:\dev\web2py\gluon\tools.py", line 1707, in define_tables
>  format='%(username)s'))
>  File "C:\dev\web2py\gluon\dal.py", line 8226, in define_table
>  table = self.lazy_define_table(tablename,*fields,**args)
>  File "C:\dev\web2py\gluon\dal.py", line 8263, in lazy_define_table
>  polymodel=polymodel)
>  File "C:\dev\web2py\gluon\dal.py", line 908, in create_table
>  raise KeyError('Cannot resolve reference %s in %s definition' % (
> referenced, table._tablename))
> KeyError: 'Cannot resolve reference auth_group in auth_user definition'
>
>
>
>
>

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


[web2py] Re: bulk_upload to GAE development datastore no longer works?

2013-12-05 Thread David Manns
Do you have a reference for this? I went back to 1.8.0 and problem is same. 
Also tried some 1.7x versions, higher versions with same result. Early 1.7x 
versions I think ran only on Python 2.5 and probably because of other 
changes in the yaml file and the --use_sqlite app parameter can't get these 
to run at all.

Thanks!

On Thursday, December 5, 2013 1:39:37 AM UTC-5, Christian Foster Howes 
wrote:
>
> this is a documented GAE SDK bug.  you'll have to downgrade your GAE SDK 
> to the last working version of this.  i *think* the last working version is 
> 1.8.1
>
> On Wednesday, December 4, 2013 8:46:31 AM UTC-8, David Manns wrote:
>>
>> My application runs on GAE. Using Google's bulk loader I make occasional 
>> backups of the database. It used to be that I could use the GAE SDK (appcfg 
>> tool in this case) to upload all the data into the development server on my 
>> development machine, thus creating the full data context for the SDK.
>>
>> This now fails. I'm not sure (or if) how the remote_api validates the 
>> provided email/password, but the results are the same failure with all 
>> sensible choices of password, e.g. the primary google account password (the 
>> account owns the app on GAE), the application specific password used for 
>> the bulk download for GAE (the gmail account uses 2 factor authentication), 
>> or no password.
>>
>> I attach the script used to run the development upload (which used to 
>> work until recently) and the command window output from running it. Also 
>> the app.yaml file.
>>
>> Anyone have any idea what the problem might be?
>>
>

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


[web2py] Re: The odd behavior of cacheable selects. Bug?

2013-12-05 Thread Leonel Câmara
Sure, I will open the bug later today.

Quinta-feira, 5 de Dezembro de 2013 20:05:38 UTC, Leonel Câmara escreveu:
>
> If I have this in my DB:
>
> db = DAL('sqlite://storage.sqlite', check_reserved=[])
>
> db.define_table('test_table',
> Field('value'),
> )
>
> if db(db.test_table.id > 0).count() == 0:
> db.test_table.bulk_insert([{'value': 'one'}, {'value': 'two'}, 
> {'value': 'three'}, {'value': 'four'}, {'value': 'five'}])
>
> And this in my default controller
>
> def index():
> test_table_rows = db(db.test_table.id>0).select(cache=(cache.ram, 
> 1800), cacheable=True)
> for record in test_table_rows:
> # Suppose I want to change the way the values are returned, here 
> I'm adding a # but I could be
> # doing something useful like turning them into an URL()
> record.value = record.value + '#'
> return {'values': test_table_rows}
>
> Then go to /default/index.json and keep refreshing. What you end up 
> getting will be something like:
>
> {"values": [{"id": 1, "value": "one##"}, {"id": 2, 
> "value": "two##"}, {"id": 3, "value": 
> "three##"}, {"id": 4, "value": 
> "four##"}, {"id": 5, "value": 
> "five##"}]}
>
>
>
> I find this behavior to be quite unexpected as I would think that the cached 
> rows would not be affected, what I would expect would be for the select to 
> always return me exactly the same cached Rows. This makes cacheable=True very 
> dangerous in a way that reminds me of using mutables as default function 
> arguments. 
>
>

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


[web2py] Re: did precion get implemented? decimal(7,3)

2013-12-05 Thread Niphlod
a) what do you need ?
b) what do you expect ?
c) what do you see instead ?
d) post a minimal app reproducing the wrong behaviour


^___^

On Thursday, December 5, 2013 2:06:49 PM UTC+1, Ivo wrote:
>
> hi did precision get implement? I can not seem to find it in the gluon 
> folder.
> do I need to import it explicitly?
>
> I found this thread:
> https://groups.google.com/forum/#!topic/web2py/PBlX2O10NRM
>
>

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


[web2py] Re: For web2py V2.8.2, how can I customize the default layout, changing colors and background images?

2013-12-05 Thread Niphlod
I guess that piece of the book needs an update. 
There is no .header nor .statusbar in the current scaffolding app.

However, given that is based on bootstrap 2.3.2, you can find a boatload of 
pointers in google on how to customize the color scheme .

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


[web2py] How would you implement paging on a google-results-like page?

2013-12-05 Thread Jim S
Looking for advice here.

Traditionally I've used SQLFORM.grid when I want to have a list where 
people can select what record they want to work with.  That works fine for 
me but a new app on working on has a requirement to have it's list pages 
look more like a google search results page.  No table like features like 
headings, columns, etc.  Just one list with a header row and a variable 
amount of data below it.

I don't have a problem creating the page, but am not sure the best way to 
implement the paging controls.  I've got the functionality all working 
based 
on http://web2py.com/books/default/chapter/29/14/other-recipes#Pagination 
from the book.  However, seems like a lot of boilerplate code I need to put 
in each of my list controllers (there around 20 of these list controllers). 
 

Wondering how others have handled similar requirements and would appreciate 
comments from anyone who wishes to share.

Thanks!

-Jim

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


[web2py] Re: The odd behavior of cacheable selects. Bug?

2013-12-05 Thread Niphlod
BTW: in my fast trial I get the same behaviour even with cacheable=True. 
This may be due to the fact that cache.ram stores a "pointer" of the rows. 
If you try with cache.disk or any other cache backend, it's ok.

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


[web2py] Re: The odd behavior of cacheable selects. Bug?

2013-12-05 Thread Niphlod
it surely counts for a bug. Would you mind opening an issue on google code 
so it gets tracked ?

On Thursday, December 5, 2013 9:05:38 PM UTC+1, Leonel Câmara wrote:
>
> If I have this in my DB:
>
> db = DAL('sqlite://storage.sqlite', check_reserved=[])
>
> db.define_table('test_table',
> Field('value'),
> )
>
> if db(db.test_table.id > 0).count() == 0:
> db.test_table.bulk_insert([{'value': 'one'}, {'value': 'two'}, 
> {'value': 'three'}, {'value': 'four'}, {'value': 'five'}])
>
> And this in my default controller
>
> def index():
> test_table_rows = db(db.test_table.id>0).select(cache=(cache.ram, 
> 1800), cacheable=True)
> for record in test_table_rows:
> # Suppose I want to change the way the values are returned, here 
> I'm adding a # but I could be
> # doing something useful like turning them into an URL()
> record.value = record.value + '#'
> return {'values': test_table_rows}
>
> Then go to /default/index.json and keep refreshing. What you end up 
> getting will be something like:
>
> {"values": [{"id": 1, "value": "one##"}, {"id": 2, 
> "value": "two##"}, {"id": 3, "value": 
> "three##"}, {"id": 4, "value": 
> "four##"}, {"id": 5, "value": 
> "five##"}]}
>
>
>
> I find this behavior to be quite unexpected as I would think that the cached 
> rows would not be affected, what I would expect would be for the select to 
> always return me exactly the same cached Rows. This makes cacheable=True very 
> dangerous in a way that reminds me of using mutables as default function 
> arguments. 
>
>

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


[web2py] The odd behavior of cacheable selects. Bug?

2013-12-05 Thread Leonel Câmara
If I have this in my DB:

db = DAL('sqlite://storage.sqlite', check_reserved=[])

db.define_table('test_table',
Field('value'),
)

if db(db.test_table.id > 0).count() == 0:
db.test_table.bulk_insert([{'value': 'one'}, {'value': 'two'}, 
{'value': 'three'}, {'value': 'four'}, {'value': 'five'}])

And this in my default controller

def index():
test_table_rows = db(db.test_table.id>0).select(cache=(cache.ram, 
1800), cacheable=True)
for record in test_table_rows:
# Suppose I want to change the way the values are returned, here 
I'm adding a # but I could be
# doing something useful like turning them into an URL()
record.value = record.value + '#'
return {'values': test_table_rows}

Then go to /default/index.json and keep refreshing. What you end up getting 
will be something like:

{"values": [{"id": 1, "value": "one##"}, {"id": 2, 
"value": "two##"}, {"id": 3, "value": 
"three##"}, {"id": 4, "value": 
"four##"}, {"id": 5, "value": 
"five##"}]}



I find this behavior to be quite unexpected as I would think that the cached 
rows would not be affected, what I would expect would be for the select to 
always return me exactly the same cached Rows. This makes cacheable=True very 
dangerous in a way that reminds me of using mutables as default function 
arguments. 

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


[web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread PRACHI VAKHARIA



Dear James,

First, thank you very much for the response, and taking the effort to try 
out the application on GAE.



The *app.yaml* file I am using is configured just as you have stated.

 
runtime: python27
threadsafe: true

 

 
- url: .*
  script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
  secure: optional

 


 

I also have the *wsgihandler.py* and *gaehandler.py* in the *root web2py 
folder* — *I think it was already there to begin with and I did not tamper 
with it at all.*


I have used the same application and app.yaml file to upload the 
application to GAE before. Since I got a new computer, installed python2.7 
and the latest w2p and GAE-launcher, I was trying to see if everything is 
set up right and working. But it seems that it is not working once uploaded 
to GAE, whether it is from my new computer or even my old computer.



QUESTION

Were you able to upload and run the application on GAE? Did the Forms 
appear and insert-append records properly?



Eagerly awaiting your reply.



Gratefully,

PRACHI 

 

 

 

 

 



On Thursday, December 5, 2013 1:44:56 PM UTC-5, James Burke wrote:
>
> Hi Prachi,
>
> Your code works fine for me, uploading to GAE.
>
> It may be that your app.yaml file is configured incorrectly. Do you have 
> it setup to use python 2.5 or 2.7?
>
> # use this line for Python 2.5
> #
> #runtime: python
>
>
> # use these lines for Python 2.7
> # upload app with: appcfg.py update web2py (where 'web2py' is web2py's 
> root directory)
> #
> runtime: python27
> threadsafe: true# true for WSGI & concurrent requests (Python 2.7 
> only)
>
>
> - url: .*
>   #script: gaehandler.py # CGI
>   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
>   secure: optional
>
> Is how mine is setup, if you don't have wsgihandler.py or gaehandler.py in 
> your root web2py folder then you will also need to copy them from the 
> examples folder.
>

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


[web2py] session cookie for two subdomains

2013-12-05 Thread Marin Pranjić
Hi,

I have two subdomains for one app, and I need to use both.
So I have to set "Domain" header in session cookie to the domain root 
(.domain.com).
Where should I put that code? Not sure how exactly to do it for session 
cookie.

Marin

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


Re: [web2py] Social Login

2013-12-05 Thread Michele Comitini
I have this old code that should work in db.py:

auth_table = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=""),
Field('last_name', length=128, default=""),
Field('username', length=128, default="", unique=True),
Field('password', 'password', length=256,
  readable=False, label='Password'),
Field('registration_key', length=128, default= "",
  writable=False, readable=False))

auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)

import twitter_oauth_data as toa # a file under
modules/twitter_oauth_data.py containing token_url, auth_url, client_id,
client_secret

CLIENT_ID=toa.CLIENT_ID
CLIENT_SECRET=toa.CLIENT_SECRET
AUTH_URL=toa.AUTH_URL
TOKEN_URL=toa.TOKEN_URL
ACCESS_TOKEN_URL=toa.ACCESS_TOKEN_URL
from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
import oauth2 as oauth
import gluon.contrib.simplejson as json
class TwitterAccount(OAuthAccount):
def get_user(self):
if self.accessToken() is not None:
client = oauth.Client(self.consumer, self.accessToken())
resp, content = client.request('
http://api.twitter.com/1/account/verify_credentials.json')
if resp['status'] != '200':
# cannot get user info. should check status
return None
u = json.loads(content)
return dict(username=u['screen_name'], name=u['name'],
registration_id=u['id'])

auth.settings.actions_disabled=['register','change_password','request_reset_password','profile']
auth.settings.login_form=TwitterAccount(globals(),CLIENT_ID,CLIENT_SECRET,
AUTH_URL, TOKEN_URL, ACCESS_TOKEN_URL)



2013/12/4 Cássio Botaro 

> What's the way to do login with twitter without using janrain? I've tried
> this solution but only works with facebook.
> https://github.com/r4bugento/web2social
>
> After authorization, I've been redirected to
> http://127.0.0.1:8000/web2social/default/user/login and show me this
> message: "This webpage has a redirect loop"
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: [web2py] Social Login

2013-12-05 Thread Michele Comitini
You also need this: https://pypi.python.org/pypi/oauth2




2013/12/5 Michele Comitini 

> I have this old code that should work in db.py:
>
> auth_table = db.define_table(
> auth.settings.table_user_name,
> Field('first_name', length=128, default=""),
> Field('last_name', length=128, default=""),
> Field('username', length=128, default="", unique=True),
> Field('password', 'password', length=256,
>   readable=False, label='Password'),
> Field('registration_key', length=128, default= "",
>   writable=False, readable=False))
>
> auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
>
> import twitter_oauth_data as toa # a file under
> modules/twitter_oauth_data.py containing token_url, auth_url, client_id,
> client_secret
>
> CLIENT_ID=toa.CLIENT_ID
> CLIENT_SECRET=toa.CLIENT_SECRET
> AUTH_URL=toa.AUTH_URL
> TOKEN_URL=toa.TOKEN_URL
> ACCESS_TOKEN_URL=toa.ACCESS_TOKEN_URL
> from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
> import oauth2 as oauth
> import gluon.contrib.simplejson as json
> class TwitterAccount(OAuthAccount):
> def get_user(self):
> if self.accessToken() is not None:
> client = oauth.Client(self.consumer, self.accessToken())
> resp, content = client.request('
> http://api.twitter.com/1/account/verify_credentials.json')
> if resp['status'] != '200':
> # cannot get user info. should check status
> return None
> u = json.loads(content)
> return dict(username=u['screen_name'], name=u['name'],
> registration_id=u['id'])
>
>
> auth.settings.actions_disabled=['register','change_password','request_reset_password','profile']
> auth.settings.login_form=TwitterAccount(globals(),CLIENT_ID,CLIENT_SECRET,
> AUTH_URL, TOKEN_URL, ACCESS_TOKEN_URL)
>
>
>
> 2013/12/4 Cássio Botaro 
>
>> What's the way to do login with twitter without using janrain? I've tried
>> this solution but only works with facebook.
>> https://github.com/r4bugento/web2social
>>
>> After authorization, I've been redirected to
>> http://127.0.0.1:8000/web2social/default/user/login and show me this
>> message: "This webpage has a redirect loop"
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


[web2py] Re: GAE - Not Working || Full Code Attached

2013-12-05 Thread James Burke
Hi Prachi,

Your code works fine for me, uploading to GAE.

It may be that your app.yaml file is configured incorrectly. Do you have it 
setup to use python 2.5 or 2.7?

# use this line for Python 2.5
#
#runtime: python


# use these lines for Python 2.7
# upload app with: appcfg.py update web2py (where 'web2py' is web2py's root 
directory)
#
runtime: python27
threadsafe: true# true for WSGI & concurrent requests (Python 2.7 only)


- url: .*
  #script: gaehandler.py # CGI
  script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
  secure: optional

Is how mine is setup, if you don't have wsgihandler.py or gaehandler.py in 
your root web2py folder then you will also need to copy them from the 
examples folder.

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


[web2py] For web2py V2.8.2, how can I customize the default layout, changing colors and background images?

2013-12-05 Thread JoeCodeswell
Dear web2py Community,

I am trying follow the book Edition 6 to customize the default layout, 
changing colors and background 
images
.

I'd like to change the navbar background and the [.header h1; .statusbar; 
.footer; ]  selectors to darkred == #88.

Under "Customizing the default layout", the book says, "try append the 
following code to layout.html header."


body { background: url('images/background.png') repeat-x #3A3A3A; }
a { color: #349C01; }
.header h1 { color: #349C01; }
.header h2 { color: white; font-style: italic; font-size: 14px;}
.statusbar { background: #33; border-bottom: 5px #349C01 solid; }
.statusbar a { color: white; }
.footer { border-top: 5px #349C01 solid; }


Following the book, I tried:


// joe1
// match [.header h1; .statusbar; .footer; ] =  #XX == darkred = #88
body { background: url('images/background.png') repeat-x #3A3A3A; }
a { color: #349C01; }
.header h1 { color: #88; }
.header h2 { color: white; font-style: italic; font-size: 14px;}
.statusbar { background: #88; border-bottom: 5px #349C01 solid; }
.statusbar a { color: white; }
.footer { border-top: 5px #88 solid; }
// /joe1


The [.header h1] color didn't change. The footer color did. 

Does the book need to be updated? Or is it just my lack of understanding? 

I'd like to make the navbar background color darkred as well.

Any suggestions would be appreciated.

Thanks in advance.

Love and peace,
Joe  

P.S. A Google group issue: The suggested tags for this Post are:

> sessions* ·  *cache* ·  *internationalization* ·  *routing* ·  *
> error_handling* ·  *scheduler* ·  *modules* ·  *views* ·  *html_helpers* ·  
> *DAL* ·  *uploads* ·  *forms* ·  *validation* ·  *grid* ·  *crud* ·  *mail* · 
>  
> *auth* ·  *services* ·  *REST* ·  *javascript* ·  *ajax* ·  *components* ·  
> *plugins* ·  *deployment* ·  *GAE* ·  *development* ·  *debugging* ·  *
> testing* ·  *models* ·  *bug* ·  *GIS* ·  *trunk* ·  *e-learning* ·  *
> contrib* ·  *css* ·  *payments
>

However, nothing after "*deployment*" shows up in my browser, so 
originally, until i copied and pasted the above, i didn't see  "*css*".

Thanks again.

Love and peace,
Joe

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


[web2py] Re: SQLite Integrity error after update to 2.8.2. => Widget problem?

2013-12-05 Thread Loïc
I know Massimo, but my problem seems to be located in the Widget management
And that's why I started my message with "
*I have the same problem as the one explained here : 
https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E 
But 
as I have more specific informations, I start a new thread...*"

Do you have any hints about that?
Thank you

Le jeudi 5 décembre 2013 16:27:55 UTC+1, Massimo Di Pierro a écrit :
>
> The problem is discussed here: 
> https://groups.google.com/forum/#!topic/web2py/klspqXpha4E
>
> On Thursday, 5 December 2013 05:04:17 UTC-6, Loïc wrote:
>>
>> Hello all-
>>
>> I have the same problem as the one explained here 
>> :https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E
>> But as I have more specific informations, I start a new thread...
>>
>> *My Model (simplified) : *
>> db.define_table('page',
>> Field('parent', 'reference page', label=T('Parent')),
>> Field('title', unique=True, notnull=True, label=T('Title')))
>>
>> db.page.parent.requires = IS_EMPTY_OR(IS_IN_DB(db, db.page.id, 
>> '%(title)s', zero=T('')))
>> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.
>> rank)
>> db.page.parent.widget = pageSelector.widget
>>
>> The goal of the HierarchicalSelect widget is to have a "tree-view" of all 
>> my pages. More elegant than the default selector
>>
>> *My Controller (simplified)*
>> def edit_page():
>> page = db.page(request.args(0))
>> crud.settings.update_deletable = False
>> form = crud.update(db.page,page,next=URL('show_page', args=page.id))
>> return dict(form=form)
>>
>> From 2.8.2 update, when I update a page, I get an error : 
>>  foreign key constraint failed
>>
>> This error *occurs only when I update a page and select "" value 
>> for the "parent" field.*
>> When I *remove the two following lines of my model definition, 
>> everything works fine*
>> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.
>> rank)
>> db.page.parent.widget = pageSelector.widget
>>
>>
>> So the error seems to be in my HierarchicalSelect class.
>> *Here is the code : *
>> class HierarchicalSelect(object):
>> def __init__(self, db, table_name, title_field, order_field):
>> self.options=[]
>> self.db = db
>> self.tablename = table_name
>> self.fieldname = None
>> self.title = title_field
>> self.order = order_field
>> self.type = None
>> self.rows=None
>> self.hierarchyseparator = XML(" "*4)
>>
>> def _childs_list(self, field, depth):
>> path = self.hierarchyseparator*depth
>>
>> path += self.hierarchyseparator
>> self.options.append((field['id'], path+field[self.title]))
>> [self._childs_list(child, (depth+1)) for child in self.rows.find(
>> lambda row: row.parent == field.id)]   
>>
>> def widget(self, field, value):
>> self.fieldname = field.name
>> self.type = field.type
>> self.rows = self.db(self.tablename).select(orderby=self.order)
>> self.options.append(("", T(''))) #add root node
>>
>> [self._childs_list(field,0) for field in self.rows.find(lambdarow
>> : row.parent < 1)] 
>> opt=[OPTION(name, _value=key) for key,name in self.options]
>> sel = SELECT(opt,_id="%s_%s" % (self.tablename, self.fieldname),
>> _class="generic-widget", 
>> _name=self.fieldname,
>> value=value)
>> return sel
>>
>> *HTML generated with the default SELECT helper for the first option (the 
>> option that causes error)*
>>
>> > value="">
>>
>>
>> *HTML generated with my Widget* *for the first option (the option that 
>> causes error)*
>> > value="">
>>
>>
>> The HTML seems to be the same, so I don't understand what's wrong with my 
>> widget...
>>
>>
>> Can anybody help me with that?
>> Thank you
>>
>

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


[web2py] Re: SQLite Integrity error after update to 2.8.2. => Widget problem?

2013-12-05 Thread Massimo Di Pierro
The problem is discussed 
here: https://groups.google.com/forum/#!topic/web2py/klspqXpha4E

On Thursday, 5 December 2013 05:04:17 UTC-6, Loïc wrote:
>
> Hello all-
>
> I have the same problem as the one explained here 
> :https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E
> But as I have more specific informations, I start a new thread...
>
> *My Model (simplified) : *
> db.define_table('page',
> Field('parent', 'reference page', label=T('Parent')),
> Field('title', unique=True, notnull=True, label=T('Title')))
>
> db.page.parent.requires = IS_EMPTY_OR(IS_IN_DB(db, db.page.id, '%(title)s'
> , zero=T('')))
> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.rank
> )
> db.page.parent.widget = pageSelector.widget
>
> The goal of the HierarchicalSelect widget is to have a "tree-view" of all 
> my pages. More elegant than the default selector
>
> *My Controller (simplified)*
> def edit_page():
> page = db.page(request.args(0))
> crud.settings.update_deletable = False
> form = crud.update(db.page,page,next=URL('show_page', args=page.id))
> return dict(form=form)
>
> From 2.8.2 update, when I update a page, I get an error : 
>  foreign key constraint failed
>
> This error *occurs only when I update a page and select "" value 
> for the "parent" field.*
> When I *remove the two following lines of my model definition, everything 
> works fine*
> pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.rank
> )
> db.page.parent.widget = pageSelector.widget
>
>
> So the error seems to be in my HierarchicalSelect class.
> *Here is the code : *
> class HierarchicalSelect(object):
> def __init__(self, db, table_name, title_field, order_field):
> self.options=[]
> self.db = db
> self.tablename = table_name
> self.fieldname = None
> self.title = title_field
> self.order = order_field
> self.type = None
> self.rows=None
> self.hierarchyseparator = XML(" "*4)
>
> def _childs_list(self, field, depth):
> path = self.hierarchyseparator*depth
>
> path += self.hierarchyseparator
> self.options.append((field['id'], path+field[self.title]))
> [self._childs_list(child, (depth+1)) for child in self.rows.find(
> lambda row: row.parent == field.id)]   
>
> def widget(self, field, value):
> self.fieldname = field.name
> self.type = field.type
> self.rows = self.db(self.tablename).select(orderby=self.order)
> self.options.append(("", T(''))) #add root node
>
> [self._childs_list(field,0) for field in self.rows.find(lambda row
> : row.parent < 1)] 
> opt=[OPTION(name, _value=key) for key,name in self.options]
> sel = SELECT(opt,_id="%s_%s" % (self.tablename, self.fieldname),
> _class="generic-widget", 
> _name=self.fieldname,
> value=value)
> return sel
>
> *HTML generated with the default SELECT helper for the first option (the 
> option that causes error)*
>
>  value="">
>
>
> *HTML generated with my Widget* *for the first option (the option that causes 
> error)*
>  value="">
>
>
> The HTML seems to be the same, so I don't understand what's wrong with my 
> widget...
>
>
> Can anybody help me with that?
> Thank you
>

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


[web2py] Re: web2py session timeout

2013-12-05 Thread Massimo Di Pierro
No but please open a ticket, we could add the functionality.

On Thursday, 5 December 2013 06:39:07 UTC-6, Samuel Komfi wrote:
>
> Goodday,
>
> I have an app which redirects to mini sites based on an 'event' argument 
> in the url like so http://0.0.0.0/app/c/login?event=event1(will take you 
> event1 themed page)
>
> The problem is when the logged in  users session is timed out, the user is 
> returned to 
> http://0.0.0.0/a/c/login?_next=/app/c/profile%3Fevent%3Devent1without the 
> event arg.
> Is it possible for me to inject the vars event to the setting.login_url 
> dynamically and cater for the event arg. 
>
> Thanks in advance 
>
>

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


[web2py] web2py session timeout

2013-12-05 Thread Samuel Komfi
Goodday,

I have an app which redirects to mini sites based on an 'event' argument in 
the url like so http://0.0.0.0/app/c/login?event=event1(will take you 
event1 themed page)

The problem is when the logged in  users session is timed out, the user is 
returned to http://0.0.0.0/a/c/login?_next=/app/c/profile%3Fevent%3Devent1 
without the event arg.
Is it possible for me to inject the vars event to the setting.login_url 
dynamically and cater for the event arg. 

Thanks in advance 

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


[web2py] Re: Making minor changes to auth.navbar()

2013-12-05 Thread Rohan Prinja
How did you solve it? I'm facing the same problem - deciding where to place 
the navbar code I wrote.

On Saturday, 15 December 2012 09:09:05 UTC+5:30, Lewis wrote:
>
> I solved this.
>
> On Friday, December 14, 2012 3:37:45 PM UTC-8, Lewis wrote:
>>
>> I understand that code and put it in my controller.
>>
>> But, where do I put the reference to it in the view (the base view that 
>> is extended):
>>
>> By default it says:  {{='auth' in globals() and 
>> auth.navbar(separators=(' ',' | ',''))}}
>>
>> I assume that user.bar must replace auth.navbar(...).
>>
>> But, I don't see how.  An arbitrary function in a controller cannot do 
>> the same things that the auth class method does.  The other problem is that 
>> my user.bar() is not in default so I must also reference the controller 
>> file.  Using URL('...', '') in place of auth.navbar did not work.
>>
>> I am sorry:  when you go mucking about substituting for internal 
>> functions/classes of web2py it is very unclear what one must do because the 
>> behavior of the internal classes is a bit obscure.
>>
>> Thank you.
>>
>> On Friday, July 20, 2012 4:29:37 PM UTC-7, pbreit wrote:
>>>
>>> I just write my own:
>>>
>>> def user_bar():
>>> action = '/user'
>>> if auth.user:
>>> logout=A('logout', _href=action+'/logout')
>>> profile=A('profile', _href=action+'/profile')
>>> password=A('change password', _href=action+'/change_password')
>>> bar = SPAN(auth.user.email, ' | ', profile, ' | ', password, ' 
>>> | ', logout, _class='auth_navbar')
>>> else:
>>> login=A('login', _href=action+'/login')
>>> register=A('register',_href=action+'/register')
>>> lost_password=A('lost password', _href=action+
>>> '/request_reset_password')
>>> bar = SPAN(' ', login, ' | ', register, ' | ', lost_password,_class
>>> ='auth_navbar')
>>> return bar
>>>
>>>

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


[web2py] Re: update table from sqlform

2013-12-05 Thread Yebach


Hello
>
> I am trying to update records in user profile from form
>
> I have two tables that need to be updated
>
> auth_user and organization
>
> record = db((db.auth_user.organization==db.organization.id) & (
> db.auth_user.id == uid)).select().first()
>
> if form.process().accepted:
> 
> record.update_record(**db.organization._filter_fields(form.vars))
>
>
> I also tried the 
> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg but kind of 
> the same problem
>
> I am getting the following error
>  'update_record'
>
 

> Doing some  experiments even if there is no error the update does not 
> happen. the table's fields in db are not updated
>

> thank you in advance
>

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


[web2py] did precion get implemented? decimal(7,3)

2013-12-05 Thread Ivo
hi did precision get implement? I can not seem to find it in the gluon 
folder.
do I need to import it explicitly?

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


[web2py] update table from sqlform

2013-12-05 Thread Yebach
Hello

I am trying to update records in user profile from form

I have two tables that need to be updated

auth_user and organization

record = db((db.auth_user.organization==db.organization.id) & 
(db.auth_user.id == uid)).select().first()

if form.process().accepted:

record.update_record(**db.organization._filter_fields(form.vars))


I also tried the https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg but 
kind of the same problem

I am getting the following error
 'update_record'


thank you in advance

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


[web2py] SQLite Integrity error after update to 2.8.2. => Widget problem?

2013-12-05 Thread Loïc
Hello all-

I have the same problem as the one explained here 
:https://groups.google.com/forum/?fromgroups#!topic/web2py/klspqXpha4E
But as I have more specific informations, I start a new thread...

*My Model (simplified) : *
db.define_table('page',
Field('parent', 'reference page', label=T('Parent')),
Field('title', unique=True, notnull=True, label=T('Title')))

db.page.parent.requires = IS_EMPTY_OR(IS_IN_DB(db, db.page.id, '%(title)s',zero
=T('')))
pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.rank)
db.page.parent.widget = pageSelector.widget

The goal of the HierarchicalSelect widget is to have a "tree-view" of all 
my pages. More elegant than the default selector

*My Controller (simplified)*
def edit_page():
page = db.page(request.args(0))
crud.settings.update_deletable = False
form = crud.update(db.page,page,next=URL('show_page', args=page.id))
return dict(form=form)

>From 2.8.2 update, when I update a page, I get an error : 
 foreign key constraint failed

This error *occurs only when I update a page and select "" value for 
the "parent" field.*
When I *remove the two following lines of my model definition, everything 
works fine*
pageSelector = HierarchicalSelect(db, db.page, db.page.title, db.page.rank)
db.page.parent.widget = pageSelector.widget


So the error seems to be in my HierarchicalSelect class.
*Here is the code : *
class HierarchicalSelect(object):
def __init__(self, db, table_name, title_field, order_field):
self.options=[]
self.db = db
self.tablename = table_name
self.fieldname = None
self.title = title_field
self.order = order_field
self.type = None
self.rows=None
self.hierarchyseparator = XML(" "*4)

def _childs_list(self, field, depth):
path = self.hierarchyseparator*depth
   
path += self.hierarchyseparator
self.options.append((field['id'], path+field[self.title]))
[self._childs_list(child, (depth+1)) for child in self.rows.find(
lambda row: row.parent == field.id)]   

def widget(self, field, value):
self.fieldname = field.name
self.type = field.type
self.rows = self.db(self.tablename).select(orderby=self.order)
self.options.append(("", T(''))) #add root node

[self._childs_list(field,0) for field in self.rows.find(lambda row:row
.parent < 1)] 
opt=[OPTION(name, _value=key) for key,name in self.options]
sel = SELECT(opt,_id="%s_%s" % (self.tablename, self.fieldname),
_class="generic-widget", 
_name=self.fieldname,
value=value)
return sel

*HTML generated with the default SELECT helper for the first option (the option 
that causes error)*




*HTML generated with my Widget* *for the first option (the option that causes 
error)*



The HTML seems to be the same, so I don't understand what's wrong with my 
widget...


Can anybody help me with that?
Thank you

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


[web2py] Re: Running instantpress in GAE: Internal error Ticket issued: unrecoverable

2013-12-05 Thread peibol
No, I didn't find any solution...


El jueves, 5 de diciembre de 2013 07:51:07 UTC+1, PRACHI VAKHARIA escribió:
>
>
>  
>
> *Did you find a Solution?*
>
> *If yes, what is the Solution?*
>
>  
>
> Thank you.
>
>
>
>
>
> On Thursday, June 13, 2013 11:29:35 AM UTC-4, peibol wrote:
>>
>> Hi all:
>>
>> Everything is running smoothly at localhost, but when deploying a raw 
>> instantpress on GAE I get Internal error Ticket issued: unrecoverable when 
>> trying to register or login. I'm using python 2.7, but the same thing 
>> happens with 2.5.
>>
>> Any hints there?
>>
>> Thanks!
>>
>

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


[web2py] Re: user profile fields for referenced table

2013-12-05 Thread 黄祥
if you had already logged in, you can retrieve current user logged in id 
using :
auth.user_id
after that just query it. 
e.g.
rows = db(db.auth_user.id == auth.user_id).select().first()

best regards,
stifan

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


[web2py] Re: After upgrade to 2.8.2: foreign key constraint failed

2013-12-05 Thread Loïc
The workaround for me was to specify adapter_args=dict(foreign_keys=False) 
in the DAL connection.
For example :
db = DAL('sqlite://storage.sqlite', pool_size=1, lazy_tables=True, 
migrate=True, adapter_args=dict(foreign_keys=False))

Le jeudi 5 décembre 2013 06:48:52 UTC+1, Vch H a écrit :
>
> How  I can change "foreign_keys=ON" to "OFF" for some application?
>
>
>

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