Re: [web2py] Re: grid: deletion row callback

2014-07-08 Thread Manuele Pesenti
Il 08/07/14 07:54, Manuele Pesenti ha scritto:
> Il 07/07/14 23:49, Anthony ha scritto:
>> I'm not sure how easy that would be in the browser without hacking
>> web2py.js, but on the server, you can check for when a deletion
>> happens and then send back some JS to be executed. Not tested, but
>> maybe something like:
>>
>> |
>> defmygrid():
>> ifrequest.args(-3)=='delete':
>> deleted_record =db.mytable(request.args(-1))
>> response.js =[JS code to be executed upon completion of the
>> Ajaxrequest]
>> grid =SQLFORM.grid(db.mytable)
>> returndict(grid=grid)
>> |
>>
>> Anthony 
> Thank you Antony,
> it could be a solution... I'll try it :)
Great it works perfectly for my needs!! Thank you again.

M.
>
> M.

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


[web2py] Re: XMLRPC fault ?

2014-07-08 Thread lyn2py
When I used @service.jsonrpc instead,

It gave this error…

  File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 108, in 

return lambda *args: self.call(attr, *args)
  File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 140, in call
self.error.get('data', None))
  File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 37, in 
__init__
value = "%s: %s\n%s" % (code, message, '\n'.join(data))
TypeError


The examples seemed simple enough and the code is very minimal, what seems 
to be wrong?

On Tuesday, July 8, 2014 12:51:42 PM UTC+8, lyn2py wrote:
>
> Hello,
>
> I'm trying out the XML RPC to have 2 apps talk to each other, and this is 
> what I have in my code (copy-pasted from this groups and web2py book):
>
> App 1:
> def test():
> import xmlrpclib
> xmlpxy = xmlrpclib.ServerProxy('
> http://127.0.0.1:8000/app2/default/call/xmlrpc')
> result = xmlpxy.do_action(3,7)
> return locals()
>
>
> App2:
> def call():
> return service()
>
>
> @service.xmlrpc
> def do_action(a,b):
> return a+b
>
>
> And I ran into this error… I'm puzzled what I am missing out to make this 
> work??
>
> File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py",
>  line 793, in close
> raise Fault(**self._stack[0])
> Fault: :method "xml" is not 
> supported'>
>
>

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


[web2py] Re: XMLRPC fault ?

2014-07-08 Thread lyn2py
Update: The JSON-RPC works in command line, but not in my app1's controller 
function (all my testing is done localhost).

I'm seeking assistance from anyone using JSON-RPC, with POST or GET to make 
it work… thank you!!!

On Tuesday, July 8, 2014 4:17:55 PM UTC+8, lyn2py wrote:
>
> When I used @service.jsonrpc instead,
>
> It gave this error…
>
>   File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 108, in 
> 
> return lambda *args: self.call(attr, *args)
>   File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 140, in 
> call
> self.error.get('data', None))
>   File "/Users/.../web2py/.../gluon/contrib/simplejsonrpc.py", line 37, in 
> __init__
> value = "%s: %s\n%s" % (code, message, '\n'.join(data))
> TypeError
>
>
> The examples seemed simple enough and the code is very minimal, what seems 
> to be wrong?
>
> On Tuesday, July 8, 2014 12:51:42 PM UTC+8, lyn2py wrote:
>>
>> Hello,
>>
>> I'm trying out the XML RPC to have 2 apps talk to each other, and this is 
>> what I have in my code (copy-pasted from this groups and web2py book):
>>
>> App 1:
>> def test():
>> import xmlrpclib
>> xmlpxy = xmlrpclib.ServerProxy('
>> http://127.0.0.1:8000/app2/default/call/xmlrpc')
>> result = xmlpxy.do_action(3,7)
>> return locals()
>>
>>
>> App2:
>> def call():
>> return service()
>>
>>
>> @service.xmlrpc
>> def do_action(a,b):
>> return a+b
>>
>>
>> And I ran into this error… I'm puzzled what I am missing out to make this 
>> work??
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py",
>>  line 793, in close
>> raise Fault(**self._stack[0])
>> Fault: :method "xml" is not 
>> supported'>
>>
>>

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


[web2py] JSON-RPC calls within controller functions

2014-07-08 Thread lyn2py
I'm wanting to get JSON RPC to work within web2py controller functions, 
without using pyjamas (which is the example provided in the book)

This is my code for the JSON RPC call:
def test_call():
from gluon.contrib.simplejsonrpc import ServerProxy
service = ServerProxy('http://127.0.0.1:8000/app22/default/call/jsonrpc'
)
result = service.load(1000)
return locals()

(1) Running it within web2py controller functions = It returns an error: 
ValueError: No JSON object could be decoded

(2) Running it in the browser =  
http://127.0.0.1:8000/app22/default/call/jsonrpc/load/1000 it runs into the 
same error as (1).

(3) Running it in command prompt = it works like a charm.

How do I get it to work within web2py controller functions? Thanks!


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


[web2py] Re: Login drop down in appadmin while logged in into admin

2014-07-08 Thread Annet
Thank you both for your reply. The difference between admin and appadmin, 
wasn't clear to me
but now it is.

Regards,

Annet

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


[web2py] unique=True for time on sqlite

2014-07-08 Thread Paolo Valleri
Hi all, I've tested the same example on both postgres and sqlite:
def run():
db.define_table('user_table',
Field('birthday', 'date', unique=True))

grid = SQLFORM.grid(db.user_table.id, user_signature=False)
return {'grid':grid}
The expected behavior is to get an error message when the I try to insert a 
new record with a date already present in the db.
It worked on postgres, on sqlite I got a ticket error instead saying:
UNIQUE constraint failed: user_table.birthday

is it possible to support unique=True on sqlite?
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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid changes request

2014-07-08 Thread Yebach
Hello

When I try to put form = SQLFORM.grid(db.mytable) in my controller the 
request changes to 
my/web/site/view?_signature=520af19b1095db04dda2f1b6cbea3a03c3551e13 which 
causes my if statement in controller to collapse. Can smbd please explain 
why this happens?

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/d/optout.


[web2py] unique=True for time on sqlite

2014-07-08 Thread Anthony
Are you saying you want an error message to appear on the form? For that, you 
need an IS_NOT_IN_DB validator, regardless of the database backend.

Anthony

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


Re: [web2py] unique=True for time on sqlite

2014-07-08 Thread Paolo Valleri
What is odd to me is that,on postgres the validator works as expected while
on sqlite it doesn‘t and it is the backend itself that raises the exception.
On Jul 8, 2014 6:43 PM, "Anthony"  wrote:

> Are you saying you want an error message to appear on the form? For that,
> you need an IS_NOT_IN_DB validator, regardless of the database backend.
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/AnmLhKmS8UA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] DAL Bug?

2014-07-08 Thread Leonel Câmara
I noticed I was getting zero returned from my deletes. After reading the 
python docs I found this:

With SQLite versions before 3.6.5, rowcount 
 is 
set to 0 if you make a DELETE FROM table without any condition.

Available 
here: https://docs.python.org/2/library/sqlite3.html#sqlite3.Cursor.rowcount

Shouldn't the DAL handle this better? Maybe in SQLiteAdapter which should 
already have a delete method overload anyway since there's special case 
code for it in the BaseAdapter which shouldn't be there as special cases 
should be in the specific implementations.
 





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


Re: [web2py] unique=True for time on sqlite

2014-07-08 Thread Paolo Valleri
I found the issue. Since the format of the date field (same happens for the 
time field) is a text in sqlite we must postpone to the validator 
IS_NOT_IN_DB the validator IS_DATE. 
By setting:
db.user_table.birthday.requires=[IS_DATE(), IS_NOT_IN_DB(db,
'user_table.birthday')]
everything works as expected even on sqlite. 
What do you think if we make it as default for date/time fields when the 
backend is sqlite?

Paolo

On Tuesday, July 8, 2014 7:04:44 PM UTC+2, Paolo Valleri wrote:
>
> What is odd to me is that,on postgres the validator works as expected 
> while on sqlite it doesn‘t and it is the backend itself that raises the 
> exception.
> On Jul 8, 2014 6:43 PM, "Anthony"  wrote:
>
>> Are you saying you want an error message to appear on the form? For that, 
>> you need an IS_NOT_IN_DB validator, regardless of the database backend.
>>
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/AnmLhKmS8UA/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: [web2py] unique=True for time on sqlite

2014-07-08 Thread Anthony
In DAL.sqlhtml_validators, we have:

if field.unique:
requires.insert(0,validators.IS_NOT_IN_DB(db,field))

I wonder why IS_NOT_IN_DB is prepended rather appended to the list of 
validators. Given that some of the validators may actually alter the value 
to be inserted (e.g., CRYPT, IS_SLUG, IS_UPPER, IS_LOWER, CLEANUP), I would 
think we would generally want IS_NOT_IN_DB to come last so it applies to 
the actual value to be inserted (of course, there are cases where you might 
want the opposite).

Anthony

On Tuesday, July 8, 2014 3:41:41 PM UTC-4, Paolo Valleri wrote:
>
> I found the issue. Since the format of the date field (same happens for 
> the time field) is a text in sqlite we must postpone to the validator 
> IS_NOT_IN_DB the validator IS_DATE. 
> By setting:
> db.user_table.birthday.requires=[IS_DATE(), IS_NOT_IN_DB(db,
> 'user_table.birthday')]
> everything works as expected even on sqlite. 
> What do you think if we make it as default for date/time fields when the 
> backend is sqlite?
>
> Paolo
>
> On Tuesday, July 8, 2014 7:04:44 PM UTC+2, Paolo Valleri wrote:
>>
>> What is odd to me is that,on postgres the validator works as expected 
>> while on sqlite it doesn‘t and it is the backend itself that raises the 
>> exception.
>> On Jul 8, 2014 6:43 PM, "Anthony"  wrote:
>>
>>> Are you saying you want an error message to appear on the form? For 
>>> that, you need an IS_NOT_IN_DB validator, regardless of the database 
>>> backend.
>>>
>>> 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 a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/AnmLhKmS8UA/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

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


[web2py] Re: How to host a website from web2py homepage on pythonanywhere.com?

2014-07-08 Thread Dragan Matic
Check my answer on the same question here: 

https://groups.google.com/forum/?fromgroups#!searchin/web2py/dragan/web2py/IURWDAP2eTY/EBgPNBZ2kmwJ


On Sunday, July 6, 2014 1:46:09 PM UTC+2, Ritesh Bhat wrote:
>
> Hi everyone,
> I am a beginner and am using the web2py framework.for the first time. I 
> would like to host a website from my web2py page on to pythonanywhere.com 
> and i am not able to figure out the same. Any help in this regard will be 
> very helpful.
> Thankyou.
>

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


[web2py] SQLEDITABLE : writable=False dosen't work

2014-07-08 Thread Fabiano Almeida
Hi!,

I'm trying to use SQLEDITABLE plugin with readable and writable attributes.

readable = False, hide the field. OK.

writable = False, the field remains editable.

How to leave only a few editable fields?

Thanks,

Fabiano.

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


[web2py] Re: DAL Bug?

2014-07-08 Thread Derek
What's buggy about it? 

On Tuesday, July 8, 2014 10:18:45 AM UTC-7, Leonel Câmara wrote:
>
> I noticed I was getting zero returned from my deletes. After reading the 
> python docs I found this:
>
> With SQLite versions before 3.6.5, rowcount 
>  is 
> set to 0 if you make a DELETE FROM table without any condition.
>
> Available here: 
> https://docs.python.org/2/library/sqlite3.html#sqlite3.Cursor.rowcount
>
> Shouldn't the DAL handle this better? Maybe in SQLiteAdapter which should 
> already have a delete method overload anyway since there's special case 
> code for it in the BaseAdapter which shouldn't be there as special cases 
> should be in the specific implementations.
>  
>
>
>
>
>
>

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


[web2py] Re: SQLEDITABLE : writable=False dosen't work

2014-07-08 Thread Fabiano Almeida
Sorry, my fault  I configured writable = False for wrong field o.O

thanks,

Fabiano.


Em terça-feira, 8 de julho de 2014 18h16min06s UTC-3, Fabiano Almeida 
escreveu:
>
> Hi!,
>
> I'm trying to use SQLEDITABLE plugin with readable and writable attributes.
>
> readable = False, hide the field. OK.
>
> writable = False, the field remains editable.
>
> How to leave only a few editable fields?
>
> Thanks,
>
> Fabiano.
>

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


[web2py] Re: custom group names in web2py

2014-07-08 Thread Derek
Not quite understanding. If the group isn't created yet, why would you want 
to add someone to it?

What's the point of your groups? If you aren't using it for authorization, 
you're better of rolling your own groups.

On Monday, July 7, 2014 2:50:17 AM UTC-7, Jimmy Stewpot wrote:
>
> Hello,
>
> I am trying to get custom group names to work properly in web2py. I am 
> using
>
> 2.9.5-stable+timestamp.2014.03.16.02.35.39
> (Running on Apache/2.2.22 (Ubuntu), Python 2.7.3) 
>
> I am trying to understand how when a user signs up the group they get 
> added to is partly created  by the organisation name in my custom auth 
> table. Here is my additional settings.
>
> auth.settings.extra_fields['auth_user'] = [
> Field('address'),
> Field('city'),
> Field('zip'),
> Field('phone', 'integer'),
> Field('organisation', 'string', notnull=True)
> ]
>
> It is the final "organisation" field that I want to add to the id field 
> i.e. %(organisation)s_%(id)s
>
> Any advice would be great.
>
> Regards,
>
> J.
>
>

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


[web2py] Re: custom group names in web2py

2014-07-08 Thread 黄祥
i think it can be achieved, because web2py had the same function for that, 
unless you set settings.create_user_groups = False.
please take a look at web2py code for that, and modified it to achieve what 
you want.

best regards,
stifan

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


[web2py] SQLEDITABLE: redirect after submit

2014-07-08 Thread Fabiano Almeida
Hi,

Has like 'accepted' attribute in SQLEDITABLE?

I need redirect to other page after 'ok' click.

Thanks,

Fabiano.

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


[web2py] Re: Using DAL inside a thread

2014-07-08 Thread dlypka
Perhaps the Scheduler can help.

On Saturday, July 5, 2014 11:47:39 AM UTC-5, Wonton wrote:
>
> Hello!
>
> As I commented in other post (
> https://groups.google.com/forum/#!topic/web2py/ZbEndj2H-fk) I have 
> problems using APNSWrapper feedback service sending push notifications.
>
> While I wait for an answer I've thought a possible solution to my problem. 
> This solution consists in:
> 1. I'm going to send push notifications to a series of device tokens.
> 2. For the current device token I mark it as "wrong" in the database.
> 3. I send the push notifications.
> 4.1. If the token is wrong the push notification is not sent and 
> APNSWrapper fails and the loop of tokens is broken.
> 4.2. If the token is right the push notification is sent.
> 5. I mark that token as "right" in the database.
>
> This way I can check the database and remove all tokens marked with 
> "wrong".
>
> The problem is that I'm executing this loop not in the main thread and I'm 
> having lots of problems: crashes, error for database connection closed, 
> etc...
>
> This is my code:
>
> ifcPushnotifications.py (is a module)
> push_thread = threading.Thread(target=__sendPushToUsersInBackground, args
> =(users, db))
> push_thread.start()
>
> def __sendPushToUsersInBackground(users, db):
> wrapper = APNSNotificationWrapper('mycert.pem', False)
> for user in users:
> _tokenRow = db(db.push_notifs_table.userId == user['id'])
> _tokenRow.update(status='wrong')
> __sendPushToUser(user)
> _tokenRow.update(status='right')
>
>
> If user's token is wrong __sendPushToUser fails and the loop leaves its 
> execution, so in the database it should be 'wrong'.
>
> My problem is that all 3 lines related to database (2 updates and the 
> query) fail randomly, sometimes crashes, sometimes returns an error of 
> closed database and do nothing, etc...
>
> So, how could I use my database inside a thread so I can avoid this errors?
>
> Thank you very much and kind regards!
>

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


[web2py] Possible to add a field to bulk_insert?

2014-07-08 Thread LoveWeb2py
I have data in json format and I love the db.table.bulk_insert(jsondata) 
feature

However, if I try to add a field it doesn't take it. For example: 
db.table.bulk_insert(jsondata, 
modified_by=db.auth_user['auth.user.id]['username'])

Any thoughts on how I could accomplish this? 

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


Re: [web2py] Auto update db records behaviour per input field on release (AJAX)

2014-07-08 Thread Francisco Gama
Derek,
that bit where you mention hooking "run-time" validation to be saved, is pretty 
much what I’m doing in my post. You need to consider that you might not have a 
complete record to insert, but one field at the time, hence why I create the 
‘updateTableService()’. From what I understand, the only difference between 
what you suggest and what I did, is that on my code, the validation is fully 
done on the server side. The advantages are that I can apply validators such as 
‘isUnique’ (among others that require the DB access) as well enforce input 
validation (from a security standpoint, there is no such thing as client-side 
input validation). The downside is obviously performance whenever things don’t 
even need to reach the server-side and parsley is able to do them immediately 
within the browser.

I guess I could add parsley to get the best of both worlds...

Thank you,
Francisco

On 7 Jul 2014, at 22:07, Derek  wrote:

> If you read, I suggested that when the 'page close' or 'navigate away' event 
> is fired, you can trigger a save then (one option). You can use parsely to 
> manage your validators (because you don't want to save invalid data). It will 
> do run-time validation, which you can then hook into to do the saving for 
> you, so as soon as valid data is entered, it is saved.
> 
> Another option is to collect a small amount of information at a time. Such 
> like a 'wizard' interface. Take a look here for what I'm talking about:
> 
> http://parsleyjs.org/doc/examples/multisteps.html
> 
> 
> On Friday, June 13, 2014 3:29:20 PM UTC-7, Francisco Ribeiro wrote:
> Thank you for stepping up to reply but 'parsely' looks more like a library 
> for client-side form validation which is not really the major problem I am 
> trying to address. My goal is to have a mechanism that stores (with 
> persistence) information provided by the user as soon as possible once it is 
> provided input field by input field (on focusOut event) , rather than just 
> doing all at once when the form is submitted. Anyway, thanks :)
> 
> Francisco
> 
> 
> On Friday, 13 June 2014 21:06:48 UTC+1, Derek wrote:
> Try 'parsely'
> 
> http://parsleyjs.org/doc/examples/simple.html
> 
> and prompt on page close to save first.
> 
> On Wednesday, June 11, 2014 7:43:41 PM UTC-7, Francisco G. T. Ribeiro wrote:
> hi all,
> I'm working on an app that uses forms that can be quite long and its users 
> often interrupt their sessions for whatever reason and end up losing the 
> information already filled. For this and other reasons I wanted to provide a 
> different behaviour to these forms where each input field updates the record 
> on the database as soon as its input field is released ('focusOut' event on 
> jQuery). Ideally, the server would reply with 'success' or an error message 
> so users know when they can move on to another field (without refreshing the 
> whole page). By the end of the form, the user wouldn't have to review things 
> that were written long ago since these were all already validated.
> 
> Now, I know this can be tricky due to database constrains but because i need 
> to do this very often (multiple fields and multiple forms), I thought it 
> would be useful to automate it, maybe even by having on the db Field 
> something like '..auto_update=True' (merely a suggestion) but before getting 
> there, I would like to know if anyone has faced this problem and if yes what 
> solution did you employ? 
> 
> Thank you in advance,
> Francisco
> 
> 
> -- 
> 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/v1MD3u5ZLm0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [web2py] Auto update db records behaviour per input field on release (AJAX)

2014-07-08 Thread Francisco Gama
Small errata on my own post:
I’m also doing some client side input validation at the moment since web2py 
provides some of it for “free" (e.g. if you have an input field that expects a 
number, you can’t even type any other character, it’s automatically removed) 
but of course that parsley would allow me to further extend this.

Francisco

On 9 Jul 2014, at 04:15, Francisco Gama  wrote:

> Derek,
> that bit where you mention hooking "run-time" validation to be saved, is 
> pretty much what I’m doing in my post. You need to consider that you might 
> not have a complete record to insert, but one field at the time, hence why I 
> create the ‘updateTableService()’. From what I understand, the only 
> difference between what you suggest and what I did, is that on my code, the 
> validation is fully done on the server side. The advantages are that I can 
> apply validators such as ‘isUnique’ (among others that require the DB access) 
> as well enforce input validation (from a security standpoint, there is no 
> such thing as client-side input validation). The downside is obviously 
> performance whenever things don’t even need to reach the server-side and 
> parsley is able to do them immediately within the browser.
> 
> I guess I could add parsley to get the best of both worlds...
> 
> Thank you,
> Francisco
> 
> On 7 Jul 2014, at 22:07, Derek  wrote:
> 
>> If you read, I suggested that when the 'page close' or 'navigate away' event 
>> is fired, you can trigger a save then (one option). You can use parsely to 
>> manage your validators (because you don't want to save invalid data). It 
>> will do run-time validation, which you can then hook into to do the saving 
>> for you, so as soon as valid data is entered, it is saved.
>> 
>> Another option is to collect a small amount of information at a time. Such 
>> like a 'wizard' interface. Take a look here for what I'm talking about:
>> 
>> http://parsleyjs.org/doc/examples/multisteps.html
>> 
>> 
>> On Friday, June 13, 2014 3:29:20 PM UTC-7, Francisco Ribeiro wrote:
>> Thank you for stepping up to reply but 'parsely' looks more like a library 
>> for client-side form validation which is not really the major problem I am 
>> trying to address. My goal is to have a mechanism that stores (with 
>> persistence) information provided by the user as soon as possible once it is 
>> provided input field by input field (on focusOut event) , rather than just 
>> doing all at once when the form is submitted. Anyway, thanks :)
>> 
>> Francisco
>> 
>> 
>> On Friday, 13 June 2014 21:06:48 UTC+1, Derek wrote:
>> Try 'parsely'
>> 
>> http://parsleyjs.org/doc/examples/simple.html
>> 
>> and prompt on page close to save first.
>> 
>> On Wednesday, June 11, 2014 7:43:41 PM UTC-7, Francisco G. T. Ribeiro wrote:
>> hi all,
>> I'm working on an app that uses forms that can be quite long and its users 
>> often interrupt their sessions for whatever reason and end up losing the 
>> information already filled. For this and other reasons I wanted to provide a 
>> different behaviour to these forms where each input field updates the record 
>> on the database as soon as its input field is released ('focusOut' event on 
>> jQuery). Ideally, the server would reply with 'success' or an error message 
>> so users know when they can move on to another field (without refreshing the 
>> whole page). By the end of the form, the user wouldn't have to review things 
>> that were written long ago since these were all already validated.
>> 
>> Now, I know this can be tricky due to database constrains but because i need 
>> to do this very often (multiple fields and multiple forms), I thought it 
>> would be useful to automate it, maybe even by having on the db Field 
>> something like '..auto_update=True' (merely a suggestion) but before getting 
>> there, I would like to know if anyone has faced this problem and if yes what 
>> solution did you employ? 
>> 
>> Thank you in advance,
>> Francisco
>> 
>> 
>> -- 
>> 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/v1MD3u5ZLm0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 



signature.asc
Description: Message signed with OpenPGP using GPGMail


[web2py] Before update and After update callbacks are giving the same results on updating table

2014-07-08 Thread Sarbjit
Hi All,

I want to detect if there is a change in auth_user table for 
registeration_key field. I have implemented the following code :-

Models :

db.auth_user._before_update.append(lambda s,f: before_trigger_auth(s,f))
db.auth_user._after_update.append(lambda s,f: after_trigger_auth(s,f))

Modules :

def before_trigger_auth(*args):
print args
print "before"
f = args[1]
rkey = f['registration_key']
current.session.before_rkey = rkey

def after_trigger_auth(*args):
print args
print "after"
f = args[1]
rkey = f['registration_key']
if current.session.before_rkey:
if current.session.before_rkey == "pending" and rkey == "":
del current.session.before_rkey
ruseremail = f['email']
print "Trigger an email update"


Now when I am editing the db.auth_user table record (using appadmin) to 
delete the pending word from registeration_key, I have noticed that the 
results from both and after callbacks were same i.e. registeration_key was 
empty. 

If I add the "pending" word in registration_key, then also I get the same 
results from both the after and before callbacks.


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