[web2py] Re: gluon/contrib/redis_utils

2016-04-21 Thread Mirek Zvolský
Thank you.

What I need is heavy computing related to few users, they DON'T share any 
data.

User asks a query, some web service gives very long response,
and it is necessary to parse it maybe 20s.
In this time user can continue work include send next questions.

Finally user will receive info, which answers are parsed allready
and then he can choose from parsed data.
But I don't want save all parsed data to postgres database.

I think redis could be good here?
With namespaced keys instead of separated db, as you recommend.

So I need know, what is minimum for such scenario.
Redis + python module installed of course, that already works nice from 
python.

But in Web2py? Is it necessary to think about threads/queues ?
Or import the redis module and make one instance as bellow is enough:

> import redis
> r = redis.StrictRedis()
> r.set()








Dne čtvrtek 21. dubna 2016 22:27:28 UTC+2 Niphlod napsal(a):
>
> that machinery is only needed for a module that needs to be used within 
> web2py, as cache and session need (and should) use a single object per 
> class with namespaced keys. Also, there's really no point or any 
> performance benefit on using separate databases in redis, and they're 
> unofficially deprecated because they're not working reallty fine with the 
> new redis cluster. it's far better to namespace your keys.
>
> tl;dr: no, RConn() wasn't made with databases preselection in mind, mostly 
> because there's no need to.
>
> On Thursday, April 21, 2016 at 7:41:43 PM UTC+2, Mirek Zvolský wrote:
>>
>> I try understand how redis support should work.
>>
>> In the contrib web2py code I see function RConn() with code inside:
>>  
>>
>>> instance_name = 'redis_conn_' + current.request.application
>>
>> if not hasattr(RConn, instance_name):
>>
>> setattr(RConn, instance_name, StrictRedis(*args, **vars))
>>
>>
>> It looks like this should separate (isolate) redis/StrictRedis instances 
>> by request.application.
>>
>> However, if I create 2 redis/StrictRedis instances and save them as 2 
>> different variables,
>> they will share same data.
>> To really separate them, I need set different db=NNN parameter:
>>
>> r1 = StrictRedis()
>> r2 = StrictRedis()
>> will be same,
>>
>> but
>> r1 = StrictRedis(db=1)
>> r2 = StrictRedis(db=2)
>> will be different.
>>
>> So, is the per application isolation really working?
>>
>>

-- 
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 integrate SendGrid in Web2py ?

2016-04-21 Thread Mirek Zvolský
Not sure if I properly understand your question.
But..

I use this in starting web in such easy way:
- Virtual server Debian, no SMTP/POP3 installed at all,
- web2py app sends what is necessary through SparkPost,
- all incomming mails for the domain I have redirected in hosting admin 
settings (at forpsi) to my personal e-mail address.

-- 
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] Internal error @ web2pyslices

2016-04-21 Thread Manuele Pesenti
doh! http://www.web2pyslices.com/home

-- 
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] having SQLFORM show form var

2016-04-21 Thread Dave S
I seem to be missing something.

I have a simple table:

db.define_table("str1", 
Field('x1', 'string', requires=IS_NOT_EMPTY()),
Field('dt', 'datetime'))

And a simple controller.

def example1():
form = SQLFORM(db.str1)
form.vars.dt = request.now
form.vars.x1 = 'lasdfjl'
form.process()
print request.now
print form.vars
if form.accepted:
message=form.vars.x1
response.flash='good job, Dave'
elif form.errors:
message='you have errors, Dave'
else:
message="what did you do?"
return dict(message=message, form=form)



When I get to the print statements, the console shows what I expect (the 
values I filled out the form with).  But the form as rendered does not show 
anything until I enter something, and if I submit without entering 
anything, the process() yields form.errors, with "enter a value" under x1, 
and the print statement shows dt and x1 as None and empty.

What am I not doing, such that setting form.vars.x1 and form.vars.dt 
doesn't get displayed in the form, and they aren't used as values if I 
don't enter anything?

/dps

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


[web2py] Re: OT: converting dot-h to python

2016-04-21 Thread Dave S
On Thursday, April 21, 2016 at 1:07:55 PM UTC-7, Ron Chatterjee wrote:
>
> You may be able to use numpy to do something like this.
>
> import numpy as np
>
> value = np.ctypeslib.as_array(value).tolist()
>
>
This doesn't look like it is what I'm after.  This appears to be a way to 
treat a C array as a Python array, which is a different problem.  Of 
course, I've skimmed the numpy documentation, so if I've missed something, 
please point it out.

/dps

 

>
>
>
>
>
>
> On Thursday, April 21, 2016 at 3:39:03 PM UTC-4, Dave S wrote:
>>
>> Does someone here have a reference for how to convert a C *.h* file full 
>> of structs into either  Python objects or a sequence of byte/short/word 
>> reads?
>>
>> I'm trying to read a blob whose internal structure is specified by 
>> structs in a .h file.  I did a manual process one time (the sequence 
>> technique), but the structs continue to evolve (and why wouldn't they?), 
>> and I'd like to automate the process a bit.  Something that can read the .h 
>> and give me stuff to paste into my wrapper code.
>>
>> Thanks.
>>
>> Dave
>> /dps
>>
>>

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


[web2py] mongoDB dal adapter and dbref

2016-04-21 Thread luis . valladares
Hello!

I've been looking in web2py book and in pydal documentation searching 
information about the implementation of mongo database reference 
(https://docs.mongodb.org/manual/reference/database-references/) but didnt 
find anything. This is implemented in some way by pyDAL?

Thanks for your help!

-- 
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: turn off tags in search wiki

2016-04-21 Thread briannd81
Figured out to turn off tagging under search by setting cloud=False in 
search function arg

On Thursday, April 21, 2016 at 10:33:52 PM UTC-4, bria...@gmail.com wrote:
>
> How do I turn off the tags appear under the search function of the 
> built-in wiki?
>

-- 
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] turn off tags in search wiki

2016-04-21 Thread briannd81
How do I turn off the tags appear under the search function of the built-in 
wiki?

-- 
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: ckeditor error

2016-04-21 Thread Henk huisman




Hmm, buggy night 2 nite..

-- 
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: Changing color of field

2016-04-21 Thread 黄祥
another way aroud :
db.task.deadline.represent = lambda value, field: SPAN('%s' % (value), 
_class = 'text-danger' if value > request.now else 'text-success')

best regards,
stifan

On Friday, April 22, 2016 at 6:54:48 AM UTC+7, Michael Beller wrote:
>
> There are a couple of ways to do this.  I've found it easier to just add 
> to my models rather than use javascript ...
>
> If you have a date field in your model ...
>
> Field('deadline', 'date', default=request.now + (week * 4), label=T(
> 'Deadline')),
>
> you can add a represent that generates a span ...
>
> db.task.deadline.represent = lambda v, row: \
> SPAN(prettydate(v), _class='overdue' if v and v < datetime.date.today
> () else None)
>
> then in your css just add the style you want, something like this ...
>
> /* Deadline styles */
> .overdue {background-color: red; color:white; padding:5px;}
>
>
> On Thursday, April 21, 2016 at 9:08:23 AM UTC-4, Md Anam Raihan wrote:
>>
>> I am creating task management app and i want to change color of field if 
>> deadline is completed then how to do it using javascript also i am facing 
>> problem in extracting datetime from my field??
>>
>

-- 
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: Changing color of field

2016-04-21 Thread Michael Beller
There are a couple of ways to do this.  I've found it easier to just add to 
my models rather than use javascript ...

If you have a date field in your model ...

Field('deadline', 'date', default=request.now + (week * 4), label=T(
'Deadline')),

you can add a represent that generates a span ...

db.task.deadline.represent = lambda v, row: \
SPAN(prettydate(v), _class='overdue' if v and v < datetime.date.today() 
else None)

then in your css just add the style you want, something like this ...

/* Deadline styles */
.overdue {background-color: red; color:white; padding:5px;}


On Thursday, April 21, 2016 at 9:08:23 AM UTC-4, Md Anam Raihan wrote:
>
> I am creating task management app and i want to change color of field if 
> deadline is completed then how to do it using javascript also i am facing 
> problem in extracting datetime from my field??
>

-- 
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: strange behaviour in after_insert callback

2016-04-21 Thread 黄祥
yes, you all right, in the past i learned the after_insert callback can be 
access via f.amount, yet it still work when using insert, but not 
bulk_insert (must use dict f['amount'] ), please correct me if i'm wrong 
about my conclusion

thanks and best regards,
stifan

On Thursday, April 21, 2016 at 9:03:16 PM UTC+7, Anthony wrote:
>
> On Thursday, April 21, 2016 at 1:57:20 AM UTC-4, 黄祥 wrote:
>>
>> meet strange behaviour in after_insert callback, when using variable 
>> (e.g. f.amount) is not work, but when using dict (e.g. f['amount'] ) work
>> models/db_wizard_4_subscription.py
>> # not work
>> def __after_insert_subscription_detail(f, id):
>> unit = float(f.amount) / float(f.nav_per_unit)
>>
>
> Why would you expect that to work? As noted in the documentation:
>
> Here f is a dict of fields passed to insert or update...
>
>
> Anthony
>
>  
>
>>
>> """
>> # work
>> def __after_insert_subscription_detail(f, id):
>> unit = float(f['amount'] ) / float(f['nav_per_unit'] )
>> """
>>
>> def on_define_subscription_detail(table): 
>> table._after_insert.append(__after_insert_subscription_detail)
>>
>> db.define_table('subscription_detail', 
>> Field('subscription_no', 'reference subscription_header'), 
>> Field('account', 'reference account'), 
>> Field('nav_date', 'date'),
>> Field('nav_per_unit', 'double'),
>> Field('amount', 'double'),
>> Field('fee', 'double'),
>> Field('fee_amount', 'double'),
>> Field('unit', 'double'),
>> auth.signature,
>> on_define = on_define_subscription_detail, 
>> format = '%(subscription_no)s')
>>
>> Traceback (most recent call last):
>>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>>  
>> line 221, in 
>>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>>  
>> line 201, in index
>> 'fee_amount' : 0}, ] )
>>   File 
>> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 831, in bulk_insert
>> ret and [[f(item, ret[k]) for k, item in enumerate(items)] for f in 
>> self._after_insert]
>>   File 
>> "/Users/MacBookPro/site/web2py/applications/mutualfunds/models/db_wizard_4_subscription.py",
>>  
>> line 43, in __after_insert_subscription_detail
>> unit = float(f.amount) / float(f.nav_per_unit)
>> AttributeError: 'dict' object has no attribute 'amount'
>>
>> controllers/install.py
>> db.subscription_detail.bulk_insert([{'subscription_no' : 1, 'account' : 
>> 1, 'nav_date' : '2016-01-01', 
>> 'nav_per_unit' : 1.0, 'amount' : 1, 'fee' : 0, 
>> 'fee_amount' : 0}, 
>> {'subscription_no' : 2, 'account' : 1, 'nav_date' : '2016-01-02', 
>> 'nav_per_unit' : 1.1, 'amount' : 2, 'fee' : 0, 
>> 'fee_amount' : 0}, ] )
>>
>> anyone know about this behaviour? is it normal?
>>
>> 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/d/optout.


[web2py] Re: deploy to pythonanywhere broken in >= 2.14.x version

2016-04-21 Thread 黄祥
pardon me, on the first post, i've tried several times to deploy on 
pythonanywhere, before i post in this group :
- using web2py 2.14.5 test deploy 1 app and 3 apps, the result is not 
expected
- turn off web2py 2.14.5 on my local and switch back to 2.14.4 repeat test 
deploy 1 app and 3 apps, the result is not expected

after saw your message (several hours later)
- i tested it again and it's work, perhaps the problem is on outage.

for the strange behaviour :
usually the button show working in a couple minutes (depends on the apps 
deployed), yet in the 2.14.x version, the button show working just in few 
seconds, yet in the pythonanywere shows nothing for the uploaded apps.
i mean in the 2.13.x version, the button text will show 'working' while the 
deploying process, after it's done, the button text back to 'deploy' or 
'submit'
in 2.14.x version, the button text only show 'working' only several secs 
after that the button text back to 'deploy' or 'submit' 
so i think it's not convinience since the user doesn't know either the 
deployed is still in process or finished. to face this, the user who 
deployed to pythonanywhere must open the pythonanywhere admin too, and 
refresh it several times, to check the apps is deployed or not.

thanks and best regards,
stifan


On Thursday, April 21, 2016 at 9:03:55 PM UTC+7, Giles Thomas wrote:
>
> Sorry, I'm a bit confused -- you seem to be saying in the first sentence 
> that it is working, then in the second one that it isn't...?
>
>
> Giles
>
>
> On Wednesday, April 20, 2016 at 8:53:17 PM UTC+1, 黄祥 wrote:
>>
>> yes, you all right, it back to normal right now, perhaps about the 
>> outage, but the same behaviour is still exist :
>>
>> usually the button show working in a couple minutes (depends on the apps 
>> deployed), yet in the 2.14.x version, the button show working just in few 
>> seconds, yet in the pythonanywere shows nothing for the uploaded apps.
>>
>> 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/d/optout.


Re: [web2py] Re: How can I pre populate a option column of a form?

2016-04-21 Thread Andrea Marin
Trans a lot 

> Il giorno 21 apr 2016, alle ore 05:22, Michael Beller  ha 
> scritto:
> 
> before you call SQLFORM, insert:
> db.pratiche.stato_pratica.default = 'aperta'
> 
> 
> 
>> On Wednesday, April 20, 2016 at 6:05:06 PM UTC-4, Andrea Marin wrote:
>> Hi I have this type of form in my model file:
>> 
>> db.define_table('pratiche',
>> Field('nome', requires=IS_NOT_EMPTY()),
>> Field('descrizione', 'text', requires=IS_NOT_EMPTY()),
>> Field('tipo_allegato', requires=IS_IN_SET(['mandato', 
>> 'comparsa preliminare', 'relazione ctu', 'parcella'])),
>> Field('doc_filename'),
>> Field('doc', 'upload'),
>> Field('stato_pratica', requires=IS_IN_SET(['aperta', 
>> 'attesa', 'chiusa'])),
>> auth.signature)
>> 
>> 
>> I want to setup a default value for field stato_pratica to 'aperta' every 
>> time a user create a new record
>> This is my controller function to create a new record
>> 
>> def create():
>> form = SQLFORM(db.pratiche).process()
>> form.vars.stato_pratica = 'aperta'
>> form.add_button('Back', URL('index'))
>> if form.accepted:
>> session.flash = T('Posted')
>> redirect(URL('index'))
>> elif form.errors:
>> session.flash = T('Il form ha degli errori')
>> return locals()
>> 
>> I try to set form.values.stato_pratica = 'aperta' but it not works.
>> 
>> 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 a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/QJ1aaP5Febo/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: gluon/contrib/redis_utils

2016-04-21 Thread Niphlod
that machinery is only needed for a module that needs to be used within 
web2py, as cache and session need (and should) use a single object per 
class with namespaced keys. Also, there's really no point or any 
performance benefit on using separate databases in redis, and they're 
unofficially deprecated because they're not working reallty fine with the 
new redis cluster. it's far better to namespace your keys.

tl;dr: no, RConn() wasn't made with databases preselection in mind, mostly 
because there's no need to.

On Thursday, April 21, 2016 at 7:41:43 PM UTC+2, Mirek Zvolský wrote:
>
> I try understand how redis support should work.
>
> In the contrib web2py code I see function RConn() with code inside:
>  
>
>> instance_name = 'redis_conn_' + current.request.application
>
> if not hasattr(RConn, instance_name):
>
> setattr(RConn, instance_name, StrictRedis(*args, **vars))
>
>
> It looks like this should separate (isolate) redis/StrictRedis instances 
> by request.application.
>
> However, if I create 2 redis/StrictRedis instances and save them as 2 
> different variables,
> they will share same data.
> To really separate them, I need set different db=NNN parameter:
>
> r1 = StrictRedis()
> r2 = StrictRedis()
> will be same,
>
> but
> r1 = StrictRedis(db=1)
> r2 = StrictRedis(db=2)
> will be different.
>
> So, is the per application isolation really working?
>
>

-- 
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: Cascade is killing me

2016-04-21 Thread Mark Billion
That fixed it!

On Thursday, April 21, 2016 at 3:30:39 PM UTC-4, Anthony wrote:
>
> Try with a fresh table and see if cascade works.
>
> On Thursday, April 21, 2016 at 3:27:25 PM UTC-4, Mark Billion wrote:
>>
>> It was added later.
>>
>> On Thursday, April 21, 2016 at 3:23:19 PM UTC-4, Anthony wrote:
>>>
>>> Was Income_Src a reference field when you first created the table, or 
>>> did you make that change later?
>>>
>>> On Thursday, April 21, 2016 at 2:16:10 PM UTC-4, Mark Billion wrote:

 No, I mean the first one.  I delete an income entry and the associated 
 deduction entries still stick around.

 Btw, when I run MYSQL> SHOW CREATE TABLE deductions, I get: 

  deductions | CREATE TABLE `deductions` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `client` varchar(512) DEFAULT NULL,
   `Deduction_Type` varchar(512) DEFAULT NULL,
   `Income_Src` varchar(512) DEFAULT NULL,
   `Deduction_Amount` decimal(18,2) DEFAULT NULL,
   `B_22_Deduction_Amount` decimal(18,2) DEFAULT NULL,
   `Additional_Description` varchar(50) DEFAULT NULL,
   `deduction_type_string` varchar(512) DEFAULT NULL,
   `deduction_line_string` varchar(512) DEFAULT NULL,
   `income_src_cat` varchar(512) DEFAULT NULL,
   `income_src_string` varchar(512) DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=302 DEFAULT CHARSET=utf8 |




 On Thursday, April 21, 2016 at 2:11:34 PM UTC-4, Leonel Câmara wrote:
>
> Do you mean you delete something in table "income" and nothing is 
> deleted in "deductions"?
>
> Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH 
> and no row is deleted in table "income"?
>
> The second one is obviously to be expected since cascading is a 
> database operation and the element you deleted would be in a set in your 
> code not in the dabatase.
>


-- 
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: OT: converting dot-h to python

2016-04-21 Thread Ron Chatterjee
You may be able to use something like this.

value = np.ctypeslib.as_array(value).tolist()



On Thursday, April 21, 2016 at 3:39:03 PM UTC-4, Dave S wrote:
>
> Does someone here have a reference for how to convert a C *.h* file full 
> of structs into either  Python objects or a sequence of byte/short/word 
> reads?
>
> I'm trying to read a blob whose internal structure is specified by structs 
> in a .h file.  I did a manual process one time (the sequence technique), 
> but the structs continue to evolve (and why wouldn't they?), and I'd like 
> to automate the process a bit.  Something that can read the .h and give me 
> stuff to paste into my wrapper code.
>
> Thanks.
>
> Dave
> /dps
>
>

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


[web2py] OT: converting dot-h to python

2016-04-21 Thread Dave S
Does someone here have a reference for how to convert a C *.h* file full of 
structs into either  Python objects or a sequence of byte/short/word reads?

I'm trying to read a blob whose internal structure is specified by structs 
in a .h file.  I did a manual process one time (the sequence technique), 
but the structs continue to evolve (and why wouldn't they?), and I'd like 
to automate the process a bit.  Something that can read the .h and give me 
stuff to paste into my wrapper code.

Thanks.

Dave
/dps

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


[web2py] Re: Cascade is killing me

2016-04-21 Thread Anthony
Try with a fresh table and see if cascade works.

On Thursday, April 21, 2016 at 3:27:25 PM UTC-4, Mark Billion wrote:
>
> It was added later.
>
> On Thursday, April 21, 2016 at 3:23:19 PM UTC-4, Anthony wrote:
>>
>> Was Income_Src a reference field when you first created the table, or did 
>> you make that change later?
>>
>> On Thursday, April 21, 2016 at 2:16:10 PM UTC-4, Mark Billion wrote:
>>>
>>> No, I mean the first one.  I delete an income entry and the associated 
>>> deduction entries still stick around.
>>>
>>> Btw, when I run MYSQL> SHOW CREATE TABLE deductions, I get: 
>>>
>>>  deductions | CREATE TABLE `deductions` (
>>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>>   `client` varchar(512) DEFAULT NULL,
>>>   `Deduction_Type` varchar(512) DEFAULT NULL,
>>>   `Income_Src` varchar(512) DEFAULT NULL,
>>>   `Deduction_Amount` decimal(18,2) DEFAULT NULL,
>>>   `B_22_Deduction_Amount` decimal(18,2) DEFAULT NULL,
>>>   `Additional_Description` varchar(50) DEFAULT NULL,
>>>   `deduction_type_string` varchar(512) DEFAULT NULL,
>>>   `deduction_line_string` varchar(512) DEFAULT NULL,
>>>   `income_src_cat` varchar(512) DEFAULT NULL,
>>>   `income_src_string` varchar(512) DEFAULT NULL,
>>>   PRIMARY KEY (`id`)
>>> ) ENGINE=InnoDB AUTO_INCREMENT=302 DEFAULT CHARSET=utf8 |
>>>
>>>
>>>
>>>
>>> On Thursday, April 21, 2016 at 2:11:34 PM UTC-4, Leonel Câmara wrote:

 Do you mean you delete something in table "income" and nothing is 
 deleted in "deductions"?

 Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH 
 and no row is deleted in table "income"?

 The second one is obviously to be expected since cascading is a 
 database operation and the element you deleted would be in a set in your 
 code not in the dabatase.

>>>

-- 
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: Cascade is killing me

2016-04-21 Thread Mark Billion
It was added later.

On Thursday, April 21, 2016 at 3:23:19 PM UTC-4, Anthony wrote:
>
> Was Income_Src a reference field when you first created the table, or did 
> you make that change later?
>
> On Thursday, April 21, 2016 at 2:16:10 PM UTC-4, Mark Billion wrote:
>>
>> No, I mean the first one.  I delete an income entry and the associated 
>> deduction entries still stick around.
>>
>> Btw, when I run MYSQL> SHOW CREATE TABLE deductions, I get: 
>>
>>  deductions | CREATE TABLE `deductions` (
>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>   `client` varchar(512) DEFAULT NULL,
>>   `Deduction_Type` varchar(512) DEFAULT NULL,
>>   `Income_Src` varchar(512) DEFAULT NULL,
>>   `Deduction_Amount` decimal(18,2) DEFAULT NULL,
>>   `B_22_Deduction_Amount` decimal(18,2) DEFAULT NULL,
>>   `Additional_Description` varchar(50) DEFAULT NULL,
>>   `deduction_type_string` varchar(512) DEFAULT NULL,
>>   `deduction_line_string` varchar(512) DEFAULT NULL,
>>   `income_src_cat` varchar(512) DEFAULT NULL,
>>   `income_src_string` varchar(512) DEFAULT NULL,
>>   PRIMARY KEY (`id`)
>> ) ENGINE=InnoDB AUTO_INCREMENT=302 DEFAULT CHARSET=utf8 |
>>
>>
>>
>>
>> On Thursday, April 21, 2016 at 2:11:34 PM UTC-4, Leonel Câmara wrote:
>>>
>>> Do you mean you delete something in table "income" and nothing is 
>>> deleted in "deductions"?
>>>
>>> Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH 
>>> and no row is deleted in table "income"?
>>>
>>> The second one is obviously to be expected since cascading is a database 
>>> operation and the element you deleted would be in a set in your code not in 
>>> the dabatase.
>>>
>>

-- 
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: Cascade is killing me

2016-04-21 Thread Anthony
Was Income_Src a reference field when you first created the table, or did 
you make that change later?

On Thursday, April 21, 2016 at 2:16:10 PM UTC-4, Mark Billion wrote:
>
> No, I mean the first one.  I delete an income entry and the associated 
> deduction entries still stick around.
>
> Btw, when I run MYSQL> SHOW CREATE TABLE deductions, I get: 
>
>  deductions | CREATE TABLE `deductions` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `client` varchar(512) DEFAULT NULL,
>   `Deduction_Type` varchar(512) DEFAULT NULL,
>   `Income_Src` varchar(512) DEFAULT NULL,
>   `Deduction_Amount` decimal(18,2) DEFAULT NULL,
>   `B_22_Deduction_Amount` decimal(18,2) DEFAULT NULL,
>   `Additional_Description` varchar(50) DEFAULT NULL,
>   `deduction_type_string` varchar(512) DEFAULT NULL,
>   `deduction_line_string` varchar(512) DEFAULT NULL,
>   `income_src_cat` varchar(512) DEFAULT NULL,
>   `income_src_string` varchar(512) DEFAULT NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=302 DEFAULT CHARSET=utf8 |
>
>
>
>
> On Thursday, April 21, 2016 at 2:11:34 PM UTC-4, Leonel Câmara wrote:
>>
>> Do you mean you delete something in table "income" and nothing is deleted 
>> in "deductions"?
>>
>> Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH 
>> and no row is deleted in table "income"?
>>
>> The second one is obviously to be expected since cascading is a database 
>> operation and the element you deleted would be in a set in your code not in 
>> the dabatase.
>>
>

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


Re: [web2py] Re: relation "auth_user" already exists

2016-04-21 Thread Richard Vézina
What happen  when you put back fake_migrate_all to false?

Did they really get created in the database?

In which context are you needing to do this? If you try to recreate your DB
in a new environnement you can simply delete databases/ folder content and
set migrate to true...

Richard

On Thu, Apr 21, 2016 at 2:43 PM, Gael Princivalle  wrote:

> Version is 2.12.3.
> >I believe you need to set both migrate=True and fake_migrate_all=True
> for the fake migrate to regenerate the .tables files.
> Thanks in fact with both to True all table files have been recreated.
>
>
> Il giorno giovedì 21 aprile 2016 05:33:37 UTC+2, Michael Beller ha scritto:
>>
>> It sounds like you need to update the .tables files to match your
>> database and models.
>>
>> I believe you need to set both migrate=True and fake_migrate_all=True for
>> the fake migrate to regenerate the .tables files.
>>
>> Here's the logic in the book:
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=fake#Migration-control-summary
>>
>> Have you tried setting both migrate and fake_migrate_all to True?
>>
>> On Wednesday, April 20, 2016 at 4:34:50 PM UTC-4, Gael Princivalle wrote:
>>>
>>> Hello.
>>>
>>> I'm still having some pain with DAL connection strings and migrations.
>>>
>>> In one application my DAL connection string is like that:
>>> DAL('postgres://username:password@localhost:5432/postg_db',
>>> check_reserved=['all'], pool_size=1, entity_quoting=True, bigint_id=True
>>> , migrate=False, fake_migrate_all=False)
>>>
>>> The application works well, but in the databases folder I have only
>>> tables form ckeditor and scheduler.
>>> If I set fake_migrate_all=True and run the application tables are not
>>> recreated.
>>> If I set migrate=True a ticket says me that relation "auth_user" already
>>> exists.
>>> So I'm unable to make modifications to this db.
>>>
>>> My reference for migration is this Niphlod post but in this case I don't
>>> know how to found a solution:
>>> 1. Put your models exactly has the database tables are.
>>> 2. Do a fake migrate.
>>> 3. Remove fake migrate and set migrate=True
>>> 4. Do the changes you need in your model.
>>>
>>> What happens if you set migrate=False in the table definition ? the
>>> check between the model in db.py and the .table file is skipped, and
>>> web2py assumes that on the db the table reflect exactly what there is in
>>> the model
>>>
>>> What happens if you set fake_migrate=True in the table definition ?
>>> web2py assumes that on the db the table reflect exactly what there is in
>>> the model, the .table files are recreated
>>>
>>> What happens if you set fake_migrate_all=True in the DAL ? all .table
>>> files are recreated, and web2py assumes that on the db the db tables
>>> are reflecting the model.
>>>
>>> What happens if you set migrate=False in the DAL? whatever table has no
>>> a specific "migrate" parameter, the migrate=False is applied to every
>>> table
>>>
>>> This kind of errors can happen only if you messed with this logic, e.g.
>>> db.define_table('test', Field('test1'), migrate=True) #web2py create
>>> the test table with the columns id and test1
>>>
>>> then
>>> db.define_table('test', Field('test1'), Field('test2'), migrate=False,
>>> fake_migrate=True) # web2py assumes that you created manually on the db
>>> the column test2, and updates the .table file
>>>
>>> then
>>> db.define_table('test', Field('test1'), Field('test2')) # web2py sees
>>> no change between the .table file and the model, but if there's not the
>>> column on the db, when you try to use it you'll get the "no such column"
>>> error
>>>
>>> then you delete the 'test' .table file manually, then
>>> db.define_table('test', Field('test1'), Field('test2'), migrate=True) 
>>> #web2py
>>> assumes that the 'test' table is not on the db, because the corresponding
>>> .table file is not there, so it tries to create it, and you get the error
>>> "table 'test' already exists on the db"
>>>
>>> or, you delete the 'test' .table file manually, and drop the table
>>> manually on the db then
>>> db.define_table('test', Field('test1'), migrate=False) #web2py assumes
>>> that the table is already there, and when you try to use it you get the
>>> error "table 'test' does not exist"
>>>
>>>
>>> Someone knows how can I resolve it ?
>>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Iss

[web2py] Re: relation "auth_user" already exists

2016-04-21 Thread Gael Princivalle
Version is 2.12.3.
>I believe you need to set both migrate=True and fake_migrate_all=True for 
the fake migrate to regenerate the .tables files.
Thanks in fact with both to True all table files have been recreated.


Il giorno giovedì 21 aprile 2016 05:33:37 UTC+2, Michael Beller ha scritto:
>
> It sounds like you need to update the .tables files to match your database 
> and models.
>
> I believe you need to set both migrate=True and fake_migrate_all=True for 
> the fake migrate to regenerate the .tables files.
>
> Here's the logic in the book:
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=fake#Migration-control-summary
>
> Have you tried setting both migrate and fake_migrate_all to True?
>
> On Wednesday, April 20, 2016 at 4:34:50 PM UTC-4, Gael Princivalle wrote:
>>
>> Hello.
>>
>> I'm still having some pain with DAL connection strings and migrations.
>>
>> In one application my DAL connection string is like that:
>> DAL('postgres://username:password@localhost:5432/postg_db', 
>> check_reserved=['all'], pool_size=1, entity_quoting=True, bigint_id=True, 
>> migrate=False, fake_migrate_all=False)
>>
>> The application works well, but in the databases folder I have only 
>> tables form ckeditor and scheduler.
>> If I set fake_migrate_all=True and run the application tables are not 
>> recreated.
>> If I set migrate=True a ticket says me that relation "auth_user" already 
>> exists.
>> So I'm unable to make modifications to this db.
>>
>> My reference for migration is this Niphlod post but in this case I don't 
>> know how to found a solution:
>> 1. Put your models exactly has the database tables are.
>> 2. Do a fake migrate.
>> 3. Remove fake migrate and set migrate=True 
>> 4. Do the changes you need in your model.
>>
>> What happens if you set migrate=False in the table definition ? the 
>> check between the model in db.py and the .table file is skipped, and 
>> web2py assumes that on the db the table reflect exactly what there is in 
>> the model
>>
>> What happens if you set fake_migrate=True in the table definition ? 
>> web2py assumes that on the db the table reflect exactly what there is in 
>> the model, the .table files are recreated
>>
>> What happens if you set fake_migrate_all=True in the DAL ? all .table 
>> files are recreated, and web2py assumes that on the db the db tables are 
>> reflecting the model.
>>  
>> What happens if you set migrate=False in the DAL? whatever table has no 
>> a specific "migrate" parameter, the migrate=False is applied to every 
>> table
>>
>> This kind of errors can happen only if you messed with this logic, e.g.
>> db.define_table('test', Field('test1'), migrate=True) #web2py create the 
>> test table with the columns id and test1
>>
>> then
>> db.define_table('test', Field('test1'), Field('test2'), migrate=False, 
>> fake_migrate=True) # web2py assumes that you created manually on the db 
>> the column test2, and updates the .table file
>>
>> then
>> db.define_table('test', Field('test1'), Field('test2')) # web2py sees no 
>> change between the .table file and the model, but if there's not the column 
>> on the db, when you try to use it you'll get the "no such column" error
>>
>> then you delete the 'test' .table file manually, then
>> db.define_table('test', Field('test1'), Field('test2'), migrate=True) 
>> #web2py 
>> assumes that the 'test' table is not on the db, because the corresponding 
>> .table file is not there, so it tries to create it, and you get the error 
>> "table 'test' already exists on the db"
>>
>> or, you delete the 'test' .table file manually, and drop the table 
>> manually on the db then
>> db.define_table('test', Field('test1'), migrate=False) #web2py assumes 
>> that the table is already there, and when you try to use it you get the 
>> error "table 'test' does not exist"
>>
>>
>> Someone knows how can I resolve it ?
>>
>

-- 
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] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
I think process().accepted and validate are the same for .factory() since 
there is no dbio.  Without either, the form vars wasn't populating the form 
(it works with both .validate() and .process() but not with neither).

The update row below updates the investor table after validation (which is 
the investor row retrieved at the beginning of the function used to 
populate the form).

On Thursday, April 21, 2016 at 2:18:24 PM UTC-4, Richard wrote:
>
> Also not sure what investor contains here :
>
>  if form.validate():
> investor.update_record(**db.investor._filter_fields(form.vars))
>
> Is it a row or the db table (db.investor)??
>
> If it is a row, I am not sure if your issue wouldn't come from the way you 
> use update_record() as it make a row update hit the database... So, maybe 
> you try to update another record than the one you think you are updating...
>
> try :
>
> db(db.investor.id == 
> form.vars.investor_id_field_name).update(...filter_fields...)
>
> You need a way to specify the record you are updating...
>
> On Thu, Apr 21, 2016 at 2:12 PM, Richard Vézina  > wrote:
>
>> I am not sure what the purpose of this :
>>
>>for f in db.investor.fields:
>> form.vars[f] = investor[f]
>> for f in db.auth_user.fields:
>> form.vars[f] = user[f]
>>
>>
>> And why not using
>>
>>   
>>
>> if form.process().accepted:
>>
>>
>> Richard
>>
>> On Thu, Apr 21, 2016 at 2:05 PM, Richard Vézina > > wrote:
>>
>>> I am not sure, but .factory() should accept readonly=True for read 
>>> form...
>>>
>>> Are you sure you have not any fields with the same name in both tables?
>>>
>>> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina >> > wrote:
>>>
 Michael,

 About displaying value use default = when you create input field it 
 should be all what you need...

 About the other problem I don't get it... You should be able to update 
 a record email/username as long as the new value is unique...

 Richard

 On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller >>> > wrote:

> Thanks Richard, I should have provided more details.
>
> When I tried to create a form using SQLFORM.factory for two tables 
> (including auth_user), I would get an error that the auth_user email and 
> username existed even if I wasn't updating those fields.  It appears that 
> the validator to assure those fields are unique does not exclude the 
> current values.  I was able to fix this by adding these before calling 
> SQLFORM.factory:
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 
> 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
> 'auth_user.username')
>
> My entire function to create an edit form for two tables:
>
> def edit():
> 
> investor = db.investor(request.args(0)) or redirect(URL('index'))
> user = db.auth_user(investor.auth_user)
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 
> 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
> 'auth_user.username')
>
> db.auth_user.password.writable = False
> db.investor.auth_user.readable = False
> db.investor.auth_user.writable = False
>
> form = SQLFORM.factory(db.auth_user, db.investor)
>
> for f in db.investor.fields:
> form.vars[f] = investor[f]
> for f in db.auth_user.fields:
> form.vars[f] = user[f]
>
> if form.validate():
> investor.update_record(**db.investor._filter_fields(form.vars
> ))
> user.update_record(**db.auth_user._filter_fields(form.vars))
> session.flash = '%s updated!' % table._singular
> redirect(URL(request.controller, 'list'))
> elif form.errors:
> response.flash = 'Please correct the errors'
>
> response.view = 'template/edit.html'
> return dict(item_name=table._singular, form=form)
>
> Now I'm working on a readonly form but the readonly option for 
> SQLFORM.factory doesn't display the values from form.vars so I may just 
> generate the form manually.
>
> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>
>> Hello Michael,
>>
>> I am not sure to understand what you are trying to acheive exactly 
>> and what is causing issue...
>>
>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller  
>> wrote:
>>
>>>
>>> The approach in the book for one form for multiple tables works well 
>>> for create forms:
>>>
>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multip

Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
Ok, but test in web2py shell simple update :

db(db.auth_user.id == ID).update(username='new_or_even_same_username',
email=idem)
db.commit()

It should work... If not there is a problem...

On Thu, Apr 21, 2016 at 2:23 PM, Michael Beller  wrote:

> you're right - I probably could have just iterated through each field and
> set the default before calling .factory() with readonly - I didn't try
> that.  The method I came up with is very simple so I'm ok with it now.
>
> for the email/username, .factory() tries to validate the fields even if
> they don't change and it includes all existing values, including the
> current row, so the validation fails.  I avoid that by specifying the list
> of values for the 'not_in_db' validator to exclude the current row.
>
>
> On Thursday, April 21, 2016 at 2:05:30 PM UTC-4, Richard wrote:
>>
>> I am not sure, but .factory() should accept readonly=True for read form...
>>
>> Are you sure you have not any fields with the same name in both tables?
>>
>> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina 
>> wrote:
>>
>>> Michael,
>>>
>>> About displaying value use default = when you create input field it
>>> should be all what you need...
>>>
>>> About the other problem I don't get it... You should be able to update a
>>> record email/username as long as the new value is unique...
>>>
>>> Richard
>>>
>>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller 
>>> wrote:
>>>
 Thanks Richard, I should have provided more details.

 When I tried to create a form using SQLFORM.factory for two tables
 (including auth_user), I would get an error that the auth_user email and
 username existed even if I wasn't updating those fields.  It appears that
 the validator to assure those fields are unique does not exclude the
 current values.  I was able to fix this by adding these before calling
 SQLFORM.factory:

 emails = db(db.auth_user.email != user.email)
 db.auth_user.email.requires = IS_NOT_IN_DB(emails,
 'auth_user.email')
 usernames = db(db.auth_user.username != user.username)
 db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
 'auth_user.username')

 My entire function to create an edit form for two tables:

 def edit():

 investor = db.investor(request.args(0)) or redirect(URL('index'))
 user = db.auth_user(investor.auth_user)

 emails = db(db.auth_user.email != user.email)
 db.auth_user.email.requires = IS_NOT_IN_DB(emails,
 'auth_user.email')
 usernames = db(db.auth_user.username != user.username)
 db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
 'auth_user.username')

 db.auth_user.password.writable = False
 db.investor.auth_user.readable = False
 db.investor.auth_user.writable = False

 form = SQLFORM.factory(db.auth_user, db.investor)

 for f in db.investor.fields:
 form.vars[f] = investor[f]
 for f in db.auth_user.fields:
 form.vars[f] = user[f]

 if form.validate():
 investor.update_record(**db.investor._filter_fields(form.vars))
 user.update_record(**db.auth_user._filter_fields(form.vars))
 session.flash = '%s updated!' % table._singular
 redirect(URL(request.controller, 'list'))
 elif form.errors:
 response.flash = 'Please correct the errors'

 response.view = 'template/edit.html'
 return dict(item_name=table._singular, form=form)

 Now I'm working on a readonly form but the readonly option for
 SQLFORM.factory doesn't display the values from form.vars so I may just
 generate the form manually.

 On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>
> Hello Michael,
>
> I am not sure to understand what you are trying to acheive exactly and
> what is causing issue...
>
> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
> wrote:
>
>>
>> The approach in the book for one form for multiple tables works well
>> for create forms:
>>
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>
>> I have not found a good method for view or update forms.
>>
>> I have a model:
>>
>> db.define_table('buyer', Field('auth_user', 'reference auth_user',
>> ...)
>> db.define_table('seller', Field('auth_user', 'reference auth_user',
>> ...)
>>
>> Each buyer is associated with one user and each seller is associated
>> with one user.  I'd like to have one form to view and edit each buyer and
>> seller that includes their user profile.
>>
>> I've tried variations of
>>
>> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
>> and
>> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg

Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
you're right - I probably could have just iterated through each field and 
set the default before calling .factory() with readonly - I didn't try 
that.  The method I came up with is very simple so I'm ok with it now.

for the email/username, .factory() tries to validate the fields even if 
they don't change and it includes all existing values, including the 
current row, so the validation fails.  I avoid that by specifying the list 
of values for the 'not_in_db' validator to exclude the current row.


On Thursday, April 21, 2016 at 2:05:30 PM UTC-4, Richard wrote:
>
> I am not sure, but .factory() should accept readonly=True for read form...
>
> Are you sure you have not any fields with the same name in both tables?
>
> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina  > wrote:
>
>> Michael,
>>
>> About displaying value use default = when you create input field it 
>> should be all what you need...
>>
>> About the other problem I don't get it... You should be able to update a 
>> record email/username as long as the new value is unique...
>>
>> Richard
>>
>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller > > wrote:
>>
>>> Thanks Richard, I should have provided more details.
>>>
>>> When I tried to create a form using SQLFORM.factory for two tables 
>>> (including auth_user), I would get an error that the auth_user email and 
>>> username existed even if I wasn't updating those fields.  It appears that 
>>> the validator to assure those fields are unique does not exclude the 
>>> current values.  I was able to fix this by adding these before calling 
>>> SQLFORM.factory:
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>> 'auth_user.username')
>>>
>>> My entire function to create an edit form for two tables:
>>>
>>> def edit():
>>> 
>>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>>> user = db.auth_user(investor.auth_user)
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>> 'auth_user.username')
>>>
>>> db.auth_user.password.writable = False
>>> db.investor.auth_user.readable = False
>>> db.investor.auth_user.writable = False
>>>
>>> form = SQLFORM.factory(db.auth_user, db.investor)
>>>
>>> for f in db.investor.fields:
>>> form.vars[f] = investor[f]
>>> for f in db.auth_user.fields:
>>> form.vars[f] = user[f]
>>>
>>> if form.validate():
>>> investor.update_record(**db.investor._filter_fields(form.vars))
>>> user.update_record(**db.auth_user._filter_fields(form.vars))
>>> session.flash = '%s updated!' % table._singular
>>> redirect(URL(request.controller, 'list'))
>>> elif form.errors:
>>> response.flash = 'Please correct the errors'
>>>
>>> response.view = 'template/edit.html'
>>> return dict(item_name=table._singular, form=form)
>>>
>>> Now I'm working on a readonly form but the readonly option for 
>>> SQLFORM.factory doesn't display the values from form.vars so I may just 
>>> generate the form manually.
>>>
>>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:

 Hello Michael,

 I am not sure to understand what you are trying to acheive exactly and 
 what is causing issue...

 On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller  
 wrote:

>
> The approach in the book for one form for multiple tables works well 
> for create forms:
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>
> I have not found a good method for view or update forms.
>
> I have a model:
>
> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
> db.define_table('seller', Field('auth_user', 'reference auth_user', 
> ...)
>
> Each buyer is associated with one user and each seller is associated 
> with one user.  I'd like to have one form to view and edit each buyer and 
> seller that includes their user profile.
>
> I've tried variations of
>
> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
> and
> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg
>
> Has anybody found a good solution?
>
> -- 
> 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 Googl

[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Ron Chatterjee
Thank Michael. I feel special!


On Thursday, April 21, 2016 at 2:16:15 PM UTC-4, Michael Beller wrote:
>
> The starter app has a 'message.py' controller that has functions for 
> creating, receiving, and replying to messages (in addition to listing, 
> viewing).
>
> The starter app code uses mailgun but it's very similar to sendgrid.  You 
> need to setup a webhook in your sendgrid or mailgun account to post the 
> inbound message to your app and then the controller function 
> (receive_mailgun_message in the starter app) adds it to the message table.
>
> On Thursday, April 21, 2016 at 2:09:21 PM UTC-4, billmac...@gmail.com 
> wrote:
>>
>> Thank you guys. Michel, 
>>
>> message.set_from('myweb2pyapp.com')
>>
>> If someone response to the email, how do I retrieve it? I need to log 
>> into my sandgrid account I am guessing. Not sure why sessage.set_form is my 
>> app name.com
>>
>>
>>
>>
>> On Thursday, April 21, 2016 at 2:00:00 PM UTC-4, Michael Beller wrote:
>>>
>>> You can use the sendgrid smtp server or their api.
>>>
>>> https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/
>>>
>>> Here is my logic for using their api (I also use mailgun with I like 
>>> also):
>>>
>>> def send_email_via_sendgrid(email_to, email_subject, email_body):
>>> # https://github.com/sendgrid/sendgrid-python
>>>
>>> import sendgrid
>>> from sendgrid import SendGridError, SendGridClientError, 
>>> SendGridServerError
>>>
>>> sg = sendgrid.SendGridClient('', '>> sendgrid pwd>', raise_errors=True)
>>>
>>> message = sendgrid.Mail()
>>> message.add_to(email_to)
>>> message.set_subject(email_subject)
>>> message.set_html(email_body)
>>> #message.set_text('Body')
>>> message.set_from('Your Name ')
>>> #status, msg = sg.send(message)
>>>
>>> try:
>>> sg.send(message)
>>> # raise SendGridClientError
>>> except SendGridClientError:
>>> pass
>>> except SendGridServerError:
>>> pass
>>> finally:
>>> return_code = response.status
>>> return locals()
>>>
>>>
>>> On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
>>> wrote:

 Thank you Leonel Câmara.

 It worked.

 mail.settings.server = 'smtp.sendgrid.net:587'
 mail.settings.sender = xxx...@mail.com
 mail.settings.login = 'sendgrid_username:sendgrid_password'
 mail.settings.tls = True



 On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally 
 wrote:
>
> How to integrate (default mailing) SendGrid in 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/d/optout.


Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
Also not sure what investor contains here :

 if form.validate():
investor.update_record(**db.investor._filter_fields(form.vars))

Is it a row or the db table (db.investor)??

If it is a row, I am not sure if your issue wouldn't come from the way you
use update_record() as it make a row update hit the database... So, maybe
you try to update another record than the one you think you are updating...

try :

db(db.investor.id ==
form.vars.investor_id_field_name).update(...filter_fields...)

You need a way to specify the record you are updating...

On Thu, Apr 21, 2016 at 2:12 PM, Richard Vézina  wrote:

> I am not sure what the purpose of this :
>
>for f in db.investor.fields:
> form.vars[f] = investor[f]
> for f in db.auth_user.fields:
> form.vars[f] = user[f]
>
>
> And why not using
>
>
>
> if form.process().accepted:
>
>
> Richard
>
> On Thu, Apr 21, 2016 at 2:05 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> I am not sure, but .factory() should accept readonly=True for read form...
>>
>> Are you sure you have not any fields with the same name in both tables?
>>
>> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> Michael,
>>>
>>> About displaying value use default = when you create input field it
>>> should be all what you need...
>>>
>>> About the other problem I don't get it... You should be able to update a
>>> record email/username as long as the new value is unique...
>>>
>>> Richard
>>>
>>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller 
>>> wrote:
>>>
 Thanks Richard, I should have provided more details.

 When I tried to create a form using SQLFORM.factory for two tables
 (including auth_user), I would get an error that the auth_user email and
 username existed even if I wasn't updating those fields.  It appears that
 the validator to assure those fields are unique does not exclude the
 current values.  I was able to fix this by adding these before calling
 SQLFORM.factory:

 emails = db(db.auth_user.email != user.email)
 db.auth_user.email.requires = IS_NOT_IN_DB(emails,
 'auth_user.email')
 usernames = db(db.auth_user.username != user.username)
 db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
 'auth_user.username')

 My entire function to create an edit form for two tables:

 def edit():

 investor = db.investor(request.args(0)) or redirect(URL('index'))
 user = db.auth_user(investor.auth_user)

 emails = db(db.auth_user.email != user.email)
 db.auth_user.email.requires = IS_NOT_IN_DB(emails,
 'auth_user.email')
 usernames = db(db.auth_user.username != user.username)
 db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
 'auth_user.username')

 db.auth_user.password.writable = False
 db.investor.auth_user.readable = False
 db.investor.auth_user.writable = False

 form = SQLFORM.factory(db.auth_user, db.investor)

 for f in db.investor.fields:
 form.vars[f] = investor[f]
 for f in db.auth_user.fields:
 form.vars[f] = user[f]

 if form.validate():
 investor.update_record(**db.investor._filter_fields(form.vars))
 user.update_record(**db.auth_user._filter_fields(form.vars))
 session.flash = '%s updated!' % table._singular
 redirect(URL(request.controller, 'list'))
 elif form.errors:
 response.flash = 'Please correct the errors'

 response.view = 'template/edit.html'
 return dict(item_name=table._singular, form=form)

 Now I'm working on a readonly form but the readonly option for
 SQLFORM.factory doesn't display the values from form.vars so I may just
 generate the form manually.

 On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>
> Hello Michael,
>
> I am not sure to understand what you are trying to acheive exactly and
> what is causing issue...
>
> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
> wrote:
>
>>
>> The approach in the book for one form for multiple tables works well
>> for create forms:
>>
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>
>> I have not found a good method for view or update forms.
>>
>> I have a model:
>>
>> db.define_table('buyer', Field('auth_user', 'reference auth_user',
>> ...)
>> db.define_table('seller', Field('auth_user', 'reference auth_user',
>> ...)
>>
>> Each buyer is associated with one user and each seller is associated
>> with one user.  I'd like to have one form to view and edit each buyer and
>> seller that includes their user profile.
>>
>> I've tried variations of
>>
>> https://groups.google.c

[web2py] Re: Cascade is killing me

2016-04-21 Thread Mark Billion
No, I mean the first one.  I delete an income entry and the associated 
deduction entries still stick around.

On Thursday, April 21, 2016 at 2:11:34 PM UTC-4, Leonel Câmara wrote:
>
> Do you mean you delete something in table "income" and nothing is deleted 
> in "deductions"?
>
> Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH and 
> no row is deleted in table "income"?
>
> The second one is obviously to be expected since cascading is a database 
> operation and the element you deleted would be in a set in your code not in 
> the dabatase.
>

-- 
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 integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
The starter app has a 'message.py' controller that has functions for 
creating, receiving, and replying to messages (in addition to listing, 
viewing).

The starter app code uses mailgun but it's very similar to sendgrid.  You 
need to setup a webhook in your sendgrid or mailgun account to post the 
inbound message to your app and then the controller function 
(receive_mailgun_message in the starter app) adds it to the message table.

On Thursday, April 21, 2016 at 2:09:21 PM UTC-4, billmac...@gmail.com wrote:
>
> Thank you guys. Michel, 
>
> message.set_from('myweb2pyapp.com')
>
> If someone response to the email, how do I retrieve it? I need to log into 
> my sandgrid account I am guessing. Not sure why sessage.set_form is my app 
> name.com
>
>
>
>
> On Thursday, April 21, 2016 at 2:00:00 PM UTC-4, Michael Beller wrote:
>>
>> You can use the sendgrid smtp server or their api.
>>
>> https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/
>>
>> Here is my logic for using their api (I also use mailgun with I like 
>> also):
>>
>> def send_email_via_sendgrid(email_to, email_subject, email_body):
>> # https://github.com/sendgrid/sendgrid-python
>>
>> import sendgrid
>> from sendgrid import SendGridError, SendGridClientError, 
>> SendGridServerError
>>
>> sg = sendgrid.SendGridClient('', '> sendgrid pwd>', raise_errors=True)
>>
>> message = sendgrid.Mail()
>> message.add_to(email_to)
>> message.set_subject(email_subject)
>> message.set_html(email_body)
>> #message.set_text('Body')
>> message.set_from('Your Name ')
>> #status, msg = sg.send(message)
>>
>> try:
>> sg.send(message)
>> # raise SendGridClientError
>> except SendGridClientError:
>> pass
>> except SendGridServerError:
>> pass
>> finally:
>> return_code = response.status
>> return locals()
>>
>>
>> On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
>> wrote:
>>>
>>> Thank you Leonel Câmara.
>>>
>>> It worked.
>>>
>>> mail.settings.server = 'smtp.sendgrid.net:587'
>>> mail.settings.sender = xxx...@mail.com
>>> mail.settings.login = 'sendgrid_username:sendgrid_password'
>>> mail.settings.tls = True
>>>
>>>
>>>
>>> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally 
>>> wrote:

 How to integrate (default mailing) SendGrid in 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/d/optout.


Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
I am not sure what the purpose of this :

   for f in db.investor.fields:
form.vars[f] = investor[f]
for f in db.auth_user.fields:
form.vars[f] = user[f]


And why not using



if form.process().accepted:


Richard

On Thu, Apr 21, 2016 at 2:05 PM, Richard Vézina  wrote:

> I am not sure, but .factory() should accept readonly=True for read form...
>
> Are you sure you have not any fields with the same name in both tables?
>
> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Michael,
>>
>> About displaying value use default = when you create input field it
>> should be all what you need...
>>
>> About the other problem I don't get it... You should be able to update a
>> record email/username as long as the new value is unique...
>>
>> Richard
>>
>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller 
>> wrote:
>>
>>> Thanks Richard, I should have provided more details.
>>>
>>> When I tried to create a form using SQLFORM.factory for two tables
>>> (including auth_user), I would get an error that the auth_user email and
>>> username existed even if I wasn't updating those fields.  It appears that
>>> the validator to assure those fields are unique does not exclude the
>>> current values.  I was able to fix this by adding these before calling
>>> SQLFORM.factory:
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
>>> 'auth_user.username')
>>>
>>> My entire function to create an edit form for two tables:
>>>
>>> def edit():
>>>
>>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>>> user = db.auth_user(investor.auth_user)
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
>>> 'auth_user.username')
>>>
>>> db.auth_user.password.writable = False
>>> db.investor.auth_user.readable = False
>>> db.investor.auth_user.writable = False
>>>
>>> form = SQLFORM.factory(db.auth_user, db.investor)
>>>
>>> for f in db.investor.fields:
>>> form.vars[f] = investor[f]
>>> for f in db.auth_user.fields:
>>> form.vars[f] = user[f]
>>>
>>> if form.validate():
>>> investor.update_record(**db.investor._filter_fields(form.vars))
>>> user.update_record(**db.auth_user._filter_fields(form.vars))
>>> session.flash = '%s updated!' % table._singular
>>> redirect(URL(request.controller, 'list'))
>>> elif form.errors:
>>> response.flash = 'Please correct the errors'
>>>
>>> response.view = 'template/edit.html'
>>> return dict(item_name=table._singular, form=form)
>>>
>>> Now I'm working on a readonly form but the readonly option for
>>> SQLFORM.factory doesn't display the values from form.vars so I may just
>>> generate the form manually.
>>>
>>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:

 Hello Michael,

 I am not sure to understand what you are trying to acheive exactly and
 what is causing issue...

 On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
 wrote:

>
> The approach in the book for one form for multiple tables works well
> for create forms:
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>
> I have not found a good method for view or update forms.
>
> I have a model:
>
> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
> db.define_table('seller', Field('auth_user', 'reference auth_user',
> ...)
>
> Each buyer is associated with one user and each seller is associated
> with one user.  I'd like to have one form to view and edit each buyer and
> seller that includes their user profile.
>
> I've tried variations of
>
> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
> and
> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg
>
> Has anybody found a good solution?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to web2py+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 --
>>> Resources:
>>> - http:/

[web2py] Re: Cascade is killing me

2016-04-21 Thread Leonel Câmara
Do you mean you delete something in table "income" and nothing is deleted 
in "deductions"?

Or do you mean you delete something from the set DEBTOR_TOGGLE_NO_BOTH and 
no row is deleted in table "income"?

The second one is obviously to be expected since cascading is a database 
operation and the element you deleted would be in a set in your code not in 
the dabatase.

-- 
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 integrate SendGrid in Web2py ?

2016-04-21 Thread billmackalister
Thank you guys. Michel, 

message.set_from('myweb2pyapp.com')

If someone response to the email, how do I retrieve it? I need to log into 
my sandgrid account I am guessing. Not sure why sessage.set_form is my app 
name.com




On Thursday, April 21, 2016 at 2:00:00 PM UTC-4, Michael Beller wrote:
>
> You can use the sendgrid smtp server or their api.
>
> https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/
>
> Here is my logic for using their api (I also use mailgun with I like also):
>
> def send_email_via_sendgrid(email_to, email_subject, email_body):
> # https://github.com/sendgrid/sendgrid-python
>
> import sendgrid
> from sendgrid import SendGridError, SendGridClientError, 
> SendGridServerError
>
> sg = sendgrid.SendGridClient('', ' sendgrid pwd>', raise_errors=True)
>
> message = sendgrid.Mail()
> message.add_to(email_to)
> message.set_subject(email_subject)
> message.set_html(email_body)
> #message.set_text('Body')
> message.set_from('Your Name ')
> #status, msg = sg.send(message)
>
> try:
> sg.send(message)
> # raise SendGridClientError
> except SendGridClientError:
> pass
> except SendGridServerError:
> pass
> finally:
> return_code = response.status
> return locals()
>
>
> On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
> wrote:
>>
>> Thank you Leonel Câmara.
>>
>> It worked.
>>
>> mail.settings.server = 'smtp.sendgrid.net:587'
>> mail.settings.sender = xxx...@mail.com
>> mail.settings.login = 'sendgrid_username:sendgrid_password'
>> mail.settings.tls = True
>>
>>
>>
>> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally 
>> wrote:
>>>
>>> How to integrate (default mailing) SendGrid in 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/d/optout.


[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
Hi Ron,

I'm implementing an 'outlook' like interface for some messaging at the 
moment which includes two way messages with attachments.  The early parts 
are incorporated in my scaffold app 
at https://mjbeller.pythonanywhere.com/starter

The 'outlook' like interface that you can use is included like this:
https://almsaeedstudio.com/themes/AdminLTE/pages/mailbox/mailbox.html

(my starter app does not include the nice looking mailbox page yet, just a 
simple list of messages tied to the message icon in the header which 
includes an unread count)

I'll push some updates to starter for messages in the next few days (but 
probably not the full integration with the mailbox.html yet, just the 
simple datatables list of messages already in the repo)

On Wednesday, April 13, 2016 at 11:42:35 AM UTC-4, Ron Chatterjee wrote:
>
> On that note. Leonel, how do we create inbox using web2py that looks 
> similar to outlook? So, when someone write a blog post and other replies or 
> for chat application to say, we can use that outlook looking interface to 
> present the data. Can someone reply to the mail we send with 
> us...@myweb2pyapp.com ?
>
>
>
> On Wednesday, April 13, 2016 at 6:32:17 AM UTC-4, Leonel Câmara wrote:
>>
>> If you're asking this, I'm just going to tell you the most obvious way. 
>> Just use their SMTP server. I've never used sendgrid with web2py but the 
>> config would be something like this:
>>
>> mail.settings.server = 'smtp.sendgrid.net:587'
>> mail.settings.login = 'sendgrid_username:sengrid_password'
>> mail.settings.tls = True
>>
>

-- 
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] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
I am not sure, but .factory() should accept readonly=True for read form...

Are you sure you have not any fields with the same name in both tables?

On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina  wrote:

> Michael,
>
> About displaying value use default = when you create input field it should
> be all what you need...
>
> About the other problem I don't get it... You should be able to update a
> record email/username as long as the new value is unique...
>
> Richard
>
> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller 
> wrote:
>
>> Thanks Richard, I should have provided more details.
>>
>> When I tried to create a form using SQLFORM.factory for two tables
>> (including auth_user), I would get an error that the auth_user email and
>> username existed even if I wasn't updating those fields.  It appears that
>> the validator to assure those fields are unique does not exclude the
>> current values.  I was able to fix this by adding these before calling
>> SQLFORM.factory:
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
>> 'auth_user.username')
>>
>> My entire function to create an edit form for two tables:
>>
>> def edit():
>>
>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>> user = db.auth_user(investor.auth_user)
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
>> 'auth_user.username')
>>
>> db.auth_user.password.writable = False
>> db.investor.auth_user.readable = False
>> db.investor.auth_user.writable = False
>>
>> form = SQLFORM.factory(db.auth_user, db.investor)
>>
>> for f in db.investor.fields:
>> form.vars[f] = investor[f]
>> for f in db.auth_user.fields:
>> form.vars[f] = user[f]
>>
>> if form.validate():
>> investor.update_record(**db.investor._filter_fields(form.vars))
>> user.update_record(**db.auth_user._filter_fields(form.vars))
>> session.flash = '%s updated!' % table._singular
>> redirect(URL(request.controller, 'list'))
>> elif form.errors:
>> response.flash = 'Please correct the errors'
>>
>> response.view = 'template/edit.html'
>> return dict(item_name=table._singular, form=form)
>>
>> Now I'm working on a readonly form but the readonly option for
>> SQLFORM.factory doesn't display the values from form.vars so I may just
>> generate the form manually.
>>
>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>>
>>> Hello Michael,
>>>
>>> I am not sure to understand what you are trying to acheive exactly and
>>> what is causing issue...
>>>
>>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
>>> wrote:
>>>

 The approach in the book for one form for multiple tables works well
 for create forms:

 http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables

 I have not found a good method for view or update forms.

 I have a model:

 db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
 db.define_table('seller', Field('auth_user', 'reference auth_user', ...)

 Each buyer is associated with one user and each seller is associated
 with one user.  I'd like to have one form to view and edit each buyer and
 seller that includes their user profile.

 I've tried variations of

 https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
 and
 https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg

 Has anybody found a good solution?

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

>>>
>>> --
>> 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] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
Michael,

About displaying value use default = when you create input field it should
be all what you need...

About the other problem I don't get it... You should be able to update a
record email/username as long as the new value is unique...

Richard

On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller  wrote:

> Thanks Richard, I should have provided more details.
>
> When I tried to create a form using SQLFORM.factory for two tables
> (including auth_user), I would get an error that the auth_user email and
> username existed even if I wasn't updating those fields.  It appears that
> the validator to assure those fields are unique does not exclude the
> current values.  I was able to fix this by adding these before calling
> SQLFORM.factory:
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
> 'auth_user.username')
>
> My entire function to create an edit form for two tables:
>
> def edit():
>
> investor = db.investor(request.args(0)) or redirect(URL('index'))
> user = db.auth_user(investor.auth_user)
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
> 'auth_user.username')
>
> db.auth_user.password.writable = False
> db.investor.auth_user.readable = False
> db.investor.auth_user.writable = False
>
> form = SQLFORM.factory(db.auth_user, db.investor)
>
> for f in db.investor.fields:
> form.vars[f] = investor[f]
> for f in db.auth_user.fields:
> form.vars[f] = user[f]
>
> if form.validate():
> investor.update_record(**db.investor._filter_fields(form.vars))
> user.update_record(**db.auth_user._filter_fields(form.vars))
> session.flash = '%s updated!' % table._singular
> redirect(URL(request.controller, 'list'))
> elif form.errors:
> response.flash = 'Please correct the errors'
>
> response.view = 'template/edit.html'
> return dict(item_name=table._singular, form=form)
>
> Now I'm working on a readonly form but the readonly option for
> SQLFORM.factory doesn't display the values from form.vars so I may just
> generate the form manually.
>
> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>
>> Hello Michael,
>>
>> I am not sure to understand what you are trying to acheive exactly and
>> what is causing issue...
>>
>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
>> wrote:
>>
>>>
>>> The approach in the book for one form for multiple tables works well for
>>> create forms:
>>>
>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>>
>>> I have not found a good method for view or update forms.
>>>
>>> I have a model:
>>>
>>> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
>>> db.define_table('seller', Field('auth_user', 'reference auth_user', ...)
>>>
>>> Each buyer is associated with one user and each seller is associated
>>> with one user.  I'd like to have one form to view and edit each buyer and
>>> seller that includes their user profile.
>>>
>>> I've tried variations of
>>>
>>> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
>>> and
>>> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg
>>>
>>> Has anybody found a good solution?
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
You can use the sendgrid smtp server or their api.
https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/

Here is my logic for using their api (I also use mailgun with I like also):

def send_email_via_sendgrid(email_to, email_subject, email_body):
# https://github.com/sendgrid/sendgrid-python

import sendgrid
from sendgrid import SendGridError, SendGridClientError, 
SendGridServerError

sg = sendgrid.SendGridClient('', '', raise_errors=True)

message = sendgrid.Mail()
message.add_to(email_to)
message.set_subject(email_subject)
message.set_html(email_body)
#message.set_text('Body')
message.set_from('Your Name ')
#status, msg = sg.send(message)

try:
sg.send(message)
# raise SendGridClientError
except SendGridClientError:
pass
except SendGridServerError:
pass
finally:
return_code = response.status
return locals()


On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
wrote:
>
> Thank you Leonel Câmara.
>
> It worked.
>
> mail.settings.server = 'smtp.sendgrid.net:587'
> mail.settings.sender = xxx...@mail.com 
> mail.settings.login = 'sendgrid_username:sendgrid_password'
> mail.settings.tls = True
>
>
>
> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally wrote:
>>
>> How to integrate (default mailing) SendGrid in 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/d/optout.


[web2py] Cascade is killing me

2016-04-21 Thread Mark Billion
Parent table is income:

db.define_table('income',
   Field('client' , requires=IS_IN_DB(db, db.client.id), writable=False),
   
   Field('source', requires=IS_IN_SET(DEBTOR_TOGGLE_NO_BOTH),))

Child Table is deductions:

db.define_table('deductions',
   Field('client' , requires=IS_IN_DB(db, db.client.id), writable=False),
   .
   Field('Income_Src', 'reference income', requires=IS_IN_DB(db, 
db.income.id, '%(Employer_Name)s')),
   Field('Additional_Description' , 'string', length=50))

deductions.Income_Src references income.

When I delete an income source, it doesnt cascade.What am I missing? (I 
know this is an easy question, but I cant find the answer anywhere)

-- 
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 integrate SendGrid in Web2py ?

2016-04-21 Thread Mirek Zvolský
This is just different interface (different parameters) for SMTP server and 
for Sparkpost service.
Of course, you need use the code from documentation of sparkpost module 
(instead of code from welcome application).

Sparkpost service uses API key tu identify you as its user.
To send mails without problems, you must validate your registration email 
(just click link in the message) + set 2 TXT records in DNS settings for 
your domain. Sparkpost will give you hint for the content of these TXT 
records.





Dne čtvrtek 21. dubna 2016 19:29:08 UTC+2 billmac...@gmail.com napsal(a):
>
> Is SparkPost is any different than to fastmail or using gmail as shown in 
> web2py book? In otherwords, using SpartPost, we don't need to do 
> mail.settings just an API key? How about the return email address or 
> smsemail?
>
>
>
> On Saturday, April 16, 2016 at 12:51:37 AM UTC-4, Massimo Di Pierro wrote:
>>
>> I use sparkpost too and I am happy with it.
>>
>>
>>
>> On Friday, 15 April 2016 11:41:20 UTC-5, Mirek Zvolský wrote:
>>>
>>> Why sendgrid?
>>> I have just implemented sparkpost (rcommended from mandrill, which 
>>> terminates their free services).
>>> 10 mails/month for free, and we have sparkpost package in pypi.
>>>
>>> Here my notes (use google translate):
>>> http://wikilinuxdevel.alwaysdata.net/plugin_wiki/page/sparkpost
>>>
>>>
>>>
>>>
>>> Dne středa 13. dubna 2016 10:59:16 UTC+2 Krishna Bavandlapally napsal(a):

 How to integrate (default mailing) SendGrid in 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/d/optout.


Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
Thanks but that would prevent username and email from updating.  I want 
them editable on the form but sqlform.factory validates as if it's an 
insert form and not an update form (I was going to see if I could find the 
logic to change that but haven't had time).

My solution just changes the validation to make sure they are unique not 
including the current value.

I've also used the following for the readonly form:

def view():

db.investor.auth_user.readable = False
db.investor.auth_user.writable = False

investor = db.investor(request.args(0)) or redirect(URL('index'))
user = db.auth_user(investor.auth_user)

investor_form = SQLFORM(db.investor, investor, showid=False, readonly=
True, comments=False)
user_form = SQLFORM(db.auth_user, user, showid=False, readonly=True, 
comments=False)

form = user_form + investor_form

return dict(item_name=table._singular, form=form, item=investor)




On Thursday, April 21, 2016 at 9:36:46 AM UTC-4, Richard wrote:
>
> What if you use this inside _filter_fields() instead of form.vars
> **{k: v for k, v in form.vars.iteritems() if k not in ('username', 
> 'email')}
>
> ?
>
> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller  > wrote:
>
>> Thanks Richard, I should have provided more details.
>>
>> When I tried to create a form using SQLFORM.factory for two tables 
>> (including auth_user), I would get an error that the auth_user email and 
>> username existed even if I wasn't updating those fields.  It appears that 
>> the validator to assure those fields are unique does not exclude the 
>> current values.  I was able to fix this by adding these before calling 
>> SQLFORM.factory:
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>> 'auth_user.username')
>>
>> My entire function to create an edit form for two tables:
>>
>> def edit():
>> 
>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>> user = db.auth_user(investor.auth_user)
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>> 'auth_user.username')
>>
>> db.auth_user.password.writable = False
>> db.investor.auth_user.readable = False
>> db.investor.auth_user.writable = False
>>
>> form = SQLFORM.factory(db.auth_user, db.investor)
>>
>> for f in db.investor.fields:
>> form.vars[f] = investor[f]
>> for f in db.auth_user.fields:
>> form.vars[f] = user[f]
>>
>> if form.validate():
>> investor.update_record(**db.investor._filter_fields(form.vars))
>> user.update_record(**db.auth_user._filter_fields(form.vars))
>> session.flash = '%s updated!' % table._singular
>> redirect(URL(request.controller, 'list'))
>> elif form.errors:
>> response.flash = 'Please correct the errors'
>>
>> response.view = 'template/edit.html'
>> return dict(item_name=table._singular, form=form)
>>
>> Now I'm working on a readonly form but the readonly option for 
>> SQLFORM.factory doesn't display the values from form.vars so I may just 
>> generate the form manually.
>>
>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>>
>>> Hello Michael,
>>>
>>> I am not sure to understand what you are trying to acheive exactly and 
>>> what is causing issue...
>>>
>>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller  
>>> wrote:
>>>

 The approach in the book for one form for multiple tables works well 
 for create forms:

 http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables

 I have not found a good method for view or update forms.

 I have a model:

 db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
 db.define_table('seller', Field('auth_user', 'reference auth_user', ...)

 Each buyer is associated with one user and each seller is associated 
 with one user.  I'd like to have one form to view and edit each buyer and 
 seller that includes their user profile.

 I've tried variations of

 https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
 and
 https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg

 Has anybody found a good solution?

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

[web2py] gluon/contrib/redis_utils

2016-04-21 Thread Mirek Zvolský
I try understand how redis support should work.

In the contrib web2py code I see function RConn() with code inside:
 

> instance_name = 'redis_conn_' + current.request.application

if not hasattr(RConn, instance_name):

setattr(RConn, instance_name, StrictRedis(*args, **vars))


It looks like this should separate (isolate) redis/StrictRedis instances by 
request.application.

However, if I create 2 redis/StrictRedis instances and save them as 2 
different variables,
they will share same data.
To really separate them, I need set different db=NNN parameter:

r1 = StrictRedis()
r2 = StrictRedis()
will be same,

but
r1 = StrictRedis(db=1)
r2 = StrictRedis(db=2)
will be different.

So, is the per application isolation really working?

-- 
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 integrate SendGrid in Web2py ?

2016-04-21 Thread billmackalister
Is SparkPost is any different than to fastmail or using gmail as shown in 
web2py book? In otherwords, using SpartPost, we don't need to do 
mail.settings just an API key? How about the return email address?



On Saturday, April 16, 2016 at 12:51:37 AM UTC-4, Massimo Di Pierro wrote:
>
> I use sparkpost too and I am happy with it.
>
>
>
> On Friday, 15 April 2016 11:41:20 UTC-5, Mirek Zvolský wrote:
>>
>> Why sendgrid?
>> I have just implemented sparkpost (rcommended from mandrill, which 
>> terminates their free services).
>> 10 mails/month for free, and we have sparkpost package in pypi.
>>
>> Here my notes (use google translate):
>> http://wikilinuxdevel.alwaysdata.net/plugin_wiki/page/sparkpost
>>
>>
>>
>>
>> Dne středa 13. dubna 2016 10:59:16 UTC+2 Krishna Bavandlapally napsal(a):
>>>
>>> How to integrate (default mailing) SendGrid in 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/d/optout.


[web2py] Re: How to append (not erase and write) something to my div with id target called by ajax?

2016-04-21 Thread Anthony
Maybe try something like:

ajax('{{=URL('default', 'ignite')}}', 'q', function(html) {$('#target').
append(html)});

The third argument to ajax() can be a function that takes the return value 
from the Ajax call -- the above code simply appends that returned value to 
the content of "target".

Anthony

On Thursday, April 21, 2016 at 4:31:36 AM UTC-4, Emmanuel Dsouza wrote:
>
> ajax('{{=URL('default', 'ignite')}}', 'q', 'target');
>
> 
> So taeget is the id of div which shoes something as per requested by the 
> user. But I want the old results too. How do I simply append and not get 
> rewritten stuffs?
>

-- 
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] How to append (not erase and write) something to my div with id target called by ajax?

2016-04-21 Thread Richard Vézina
Maybe :
http://stackoverflow.com/questions/16192647/how-to-append-only-a-div-from-ajax-done

On Thu, Apr 21, 2016 at 4:31 AM, Emmanuel Dsouza 
wrote:

> ajax('{{=URL('default', 'ignite')}}', 'q', 'target');
>
> 
> So taeget is the id of div which shoes something as per requested by the
> user. But I want the old results too. How do I simply append and not get
> rewritten stuffs?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] How do I add extra buttons to a SQLFORM which will one to a different view?

2016-04-21 Thread Richard Vézina
buttons = [TAG.button((I('', _class='icon-ban-circle icon-large
icon-white'), CAT('  '), STRONG(T('Cancel'))),
  _type='button',
  _onClick="javascript:void(history.go(-1))",
  _class='btn btn-small btn-inverse'),
   TAG.button((I('', _class='icon-ok icon-large icon-white'),
CAT('  '), STRONG(T('Submit'))),
  _type='submit',
  _class='btn btn-small btn-primary')]

form=SQLFORM(db.person, buttons=buttons).process()

On Thu, Apr 21, 2016 at 10:37 AM, Emmanuel Dsouza 
wrote:

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

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


[web2py] How do I add extra buttons to a SQLFORM which will one to a different view?

2016-04-21 Thread Emmanuel Dsouza
form=SQLFORM(db.person).process()

-- 
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: Error importing module from within a virtual method field defined in another module

2016-04-21 Thread Lisandro
I've "fixed" the problem, but I don't understand exactly what was it.

The problem wasn't the import itself, but the moment in wich I was doing it.

Let's go back to the function that had the error, here with more detail

def instalar_nuevo_sitio(nombre):
sitio = db(db.sitios.nombre == nombre).select().first()
# here it does a lot of stuff
sitio.set_metodo_pago(metodopago='ticket')  # this line throws the error


Notice the comment where I say that in that place, the function does "a lot 
of stuff". What is that stuff? Well, what the function does is to install a 
new app in web2py, that is, clonning the repository and putting all the 
files needed by the new app. 

How did I solve it? I just moved the sentence to the top, before doing that 
"lot of stuff".
I don't know why exactly that worked, because the line that throwed the 
error doesn't have anything to do with the new application installed by the 
function.

Anyway, It's solved now, but I cannot say why :/





El jueves, 21 de abril de 2016, 8:48:06 (UTC-3), Lisandro escribió:
>
> I have a virtual method field, and its associated function is defined 
> inside a module.
> That function imports another function defined in another module.
> And that last function also imports another module.
>
>
> The virtual method function works ok when I call it from a controller 
> function.
> However, if I call that method in the scheduler environment, I have the 
> error "Cannot import module mercadopago"
>
>
> The virtual method field is defined in db.py like this:
> from virtual_methods import set_metodo_pago
>
> db.define_table('sitios',
>   Field('nombre'), 
>   Field.Method('set_metodo_pago', lambda row, metodo_pago: 
> sitios_set_metodo_pago(row, metodo_pago)))
>
>
> These are my modules:
> modules/virtual_methods.py
> modules/globals.py
> modules/mercadopago.py
> modules/scheduler_functions.py
>
>
> in modules/virtual_methods.py
> def set_metodo_pago(row, metodo_pago):
> from globals import get_mercadopago_client
> mp = get_mercadopago_client()
> ...
>
>
>
> in modules/globals.py
> def get_mercadopago_client():
> import mercadopago
> return MP.client()
> ...
>
>
> in modules/scheduler_function.py
> def instalar_nuevo_sitio(nombre):
>db = current.db
>sitio = db(db.sitios.nombre == nombre).select().first()
>sitio.set_metodo_pago(metodopago='ticket') # this is the line that 
> throws the error
>
>
> However, the same line works ok if I call it from a controller/function.
> What am I missing?
>
>

-- 
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: deploy to pythonanywhere broken in >= 2.14.x version

2016-04-21 Thread Giles Thomas
Sorry, I'm a bit confused -- you seem to be saying in the first sentence 
that it is working, then in the second one that it isn't...?


Giles


On Wednesday, April 20, 2016 at 8:53:17 PM UTC+1, 黄祥 wrote:
>
> yes, you all right, it back to normal right now, perhaps about the outage, 
> but the same behaviour is still exist :
>
> usually the button show working in a couple minutes (depends on the apps 
> deployed), yet in the 2.14.x version, the button show working just in few 
> seconds, yet in the pythonanywere shows nothing for the uploaded apps.
>
> 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/d/optout.


[web2py] Re: strange behaviour in after_insert callback

2016-04-21 Thread Anthony
On Thursday, April 21, 2016 at 1:57:20 AM UTC-4, 黄祥 wrote:
>
> meet strange behaviour in after_insert callback, when using variable (e.g. 
> f.amount) is not work, but when using dict (e.g. f['amount'] ) work
> models/db_wizard_4_subscription.py
> # not work
> def __after_insert_subscription_detail(f, id):
> unit = float(f.amount) / float(f.nav_per_unit)
>

Why would you expect that to work? As noted in the documentation:

Here f is a dict of fields passed to insert or update...


Anthony

 

>
> """
> # work
> def __after_insert_subscription_detail(f, id):
> unit = float(f['amount'] ) / float(f['nav_per_unit'] )
> """
>
> def on_define_subscription_detail(table): 
> table._after_insert.append(__after_insert_subscription_detail)
>
> db.define_table('subscription_detail', 
> Field('subscription_no', 'reference subscription_header'), 
> Field('account', 'reference account'), 
> Field('nav_date', 'date'),
> Field('nav_per_unit', 'double'),
> Field('amount', 'double'),
> Field('fee', 'double'),
> Field('fee_amount', 'double'),
> Field('unit', 'double'),
> auth.signature,
> on_define = on_define_subscription_detail, 
> format = '%(subscription_no)s')
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>  
> line 221, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>  
> line 201, in index
> 'fee_amount' : 0}, ] )
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", line 
> 831, in bulk_insert
> ret and [[f(item, ret[k]) for k, item in enumerate(items)] for f in 
> self._after_insert]
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/models/db_wizard_4_subscription.py",
>  
> line 43, in __after_insert_subscription_detail
> unit = float(f.amount) / float(f.nav_per_unit)
> AttributeError: 'dict' object has no attribute 'amount'
>
> controllers/install.py
> db.subscription_detail.bulk_insert([{'subscription_no' : 1, 'account' : 1, 
> 'nav_date' : '2016-01-01', 
> 'nav_per_unit' : 1.0, 'amount' : 1, 'fee' : 0, 
> 'fee_amount' : 0}, 
> {'subscription_no' : 2, 'account' : 1, 'nav_date' : '2016-01-02', 
> 'nav_per_unit' : 1.1, 'amount' : 2, 'fee' : 0, 
> 'fee_amount' : 0}, ] )
>
> anyone know about this behaviour? is it normal?
>
> 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/d/optout.


[web2py] Re: Someone tell me what's wrong here?

2016-04-21 Thread Anthony
Steve, you have asked quite a number of questions in the past week that 
suggest you have not read the web2py documentation. I would politely 
suggest that you take some time to read through the book, and then come 
here to ask questions that are not clearly covered in the documentation.

Also, in several cases, you have mentioned that some code of yours resulted 
in an error, but you have not reported the error. Always show the traceback 
(or if there is no traceback, explain in detail what you expected and what 
happened instead).

On Thursday, April 21, 2016 at 8:23:18 AM UTC-4, Steve Joe wrote:
>
> auth = Auth(db)
> auth.user_email.readable=False
> auth.user_email.writable=False
>

What's wrong with this is that it appears you have invented some code that 
you have not seen anywhere in the documentation. What do you expect this to 
do, and why would you expect it to work?

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] Re: How do I send same mail to a list of email ids?

2016-04-21 Thread Richard Vézina
Not ids, but emails... But do you want them to recieve the "same" email by
including them into the recipient field ? or you want to send them a copy
of the email individually ? In the later case you will have to make
multiple mail.send() to single item of your list of emails...

Richard

On Thu, Apr 21, 2016 at 8:27 AM, Emmanuel Dsouza 
wrote:

> No that's not what I asked.
> supposing i have a predefined list say L having many email ids. Can I
> simply send to a mail to everyone like this:
> mail.send(to=L,
>   
>
> On Wednesday, April 20, 2016 at 2:17:11 AM UTC+5:30, Niphlod wrote:
>>
>> mail.send has to,cc and ccn that take either a list or a string. to send
>> to two email addresses in the "to", use
>>
>> mail.send(to=['ma...@example.com', 'ma...@example.com'], )
>>
>> On Tuesday, April 19, 2016 at 10:24:34 PM UTC+2, Emmanuel Dsouza wrote:
>>>
>>> mail.send('ma...@some.com' , #here i want to attach a list of mail ids.
>>> 'Subject',
>>> 'Body'
>>> )
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] E2E Automated Tests

2016-04-21 Thread Richard Vézina
Had you give a look at web2py.test (
https://github.com/viniciusban/web2py.test) and welcome_augmented (
https://github.com/niphlod/welcome_augmented)... I did a hybrid of both...

Richard

On Thu, Apr 21, 2016 at 3:08 AM, Matheus Cardoso 
wrote:

> What do you guys use as a "solution" to E2E tests? I think this is a weak
> part of web2py. I know WebClient solution, but it's still uses the same
> "db" defined in db.py and prevents me to use Selenium, for instance. Let me
> give a example: in Django, one can write a test.py in an app, define some
> TestCase classes and then run (*python manage.py test*) in a complete
> separated "test environment", with separated test database, method's
> isolation, etc. What is correspondent way in web2py? (sorry for the
> comparison, but this is my daily routine, django in work and web2py to my
> side jobs).
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Someone tell me what's wrong here?

2016-04-21 Thread Richard Vézina
And what the problem?

I guess you want
db.auth_user.email.readable = False
db.auth_user.email.writable = False

On Thu, Apr 21, 2016 at 8:23 AM, Steve Joe  wrote:

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

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


[web2py] Re: checkboxes framework7.io and validate

2016-04-21 Thread 'DenesL' via web2py-users

I am still using F7 to develop mobile apps, unlike other frameworks/tools 
that I have tried before, which were dropped because of their lack of 
features or performance issues, and I have tried a few of them along the 
way: jquery mobile, kendoui, lungo, semantic, and some others I can't 
recall now.

Obviously F7 is not a perfect fit but what is?. At times its way of doing 
things might clash with w2p but so far so good.
Got to love the richness of features.

If more w2p-iers used it then we could eventually build a set of 
interfacing widgets to smooth out the bumps. 
So I am interested in hearing other people's experiences with it.

Denes

-- 
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] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Richard Vézina
What if you use this inside _filter_fields() instead of form.vars
**{k: v for k, v in form.vars.iteritems() if k not in ('username', 'email')}

?

On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller  wrote:

> Thanks Richard, I should have provided more details.
>
> When I tried to create a form using SQLFORM.factory for two tables
> (including auth_user), I would get an error that the auth_user email and
> username existed even if I wasn't updating those fields.  It appears that
> the validator to assure those fields are unique does not exclude the
> current values.  I was able to fix this by adding these before calling
> SQLFORM.factory:
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
> 'auth_user.username')
>
> My entire function to create an edit form for two tables:
>
> def edit():
>
> investor = db.investor(request.args(0)) or redirect(URL('index'))
> user = db.auth_user(investor.auth_user)
>
> emails = db(db.auth_user.email != user.email)
> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
> usernames = db(db.auth_user.username != user.username)
> db.auth_user.username.requires = IS_NOT_IN_DB(usernames,
> 'auth_user.username')
>
> db.auth_user.password.writable = False
> db.investor.auth_user.readable = False
> db.investor.auth_user.writable = False
>
> form = SQLFORM.factory(db.auth_user, db.investor)
>
> for f in db.investor.fields:
> form.vars[f] = investor[f]
> for f in db.auth_user.fields:
> form.vars[f] = user[f]
>
> if form.validate():
> investor.update_record(**db.investor._filter_fields(form.vars))
> user.update_record(**db.auth_user._filter_fields(form.vars))
> session.flash = '%s updated!' % table._singular
> redirect(URL(request.controller, 'list'))
> elif form.errors:
> response.flash = 'Please correct the errors'
>
> response.view = 'template/edit.html'
> return dict(item_name=table._singular, form=form)
>
> Now I'm working on a readonly form but the readonly option for
> SQLFORM.factory doesn't display the values from form.vars so I may just
> generate the form manually.
>
> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>
>> Hello Michael,
>>
>> I am not sure to understand what you are trying to acheive exactly and
>> what is causing issue...
>>
>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller 
>> wrote:
>>
>>>
>>> The approach in the book for one form for multiple tables works well for
>>> create forms:
>>>
>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>>
>>> I have not found a good method for view or update forms.
>>>
>>> I have a model:
>>>
>>> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
>>> db.define_table('seller', Field('auth_user', 'reference auth_user', ...)
>>>
>>> Each buyer is associated with one user and each seller is associated
>>> with one user.  I'd like to have one form to view and edit each buyer and
>>> seller that includes their user profile.
>>>
>>> I've tried variations of
>>>
>>> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
>>> and
>>> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg
>>>
>>> Has anybody found a good solution?
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-21 Thread Kiran Subbaraman
The module (which included grequests) was being used in a web2py and 
non-web2py context. The grequest capability was coming into play in the 
latter context.

Refactored by separating out this responsibility.


Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Thu, 21-04-2016 5:45 PM, Niphlod wrote:
why would you use a library made to use gevent in an environment that 
doesn't support it ?
if you need to use gevent-coroutines-etc-etc-etc you need to have the 
COMPLETE env supporting it, not just a piece.


On Thursday, April 21, 2016 at 7:49:25 AM UTC+2, Kiran Subbaraman wrote:

Narrowed down the issue. Basically, the grequests modules that I
was using seems to be the cause of the "|LoopExit: This operation
would block forever"|

Create an application: *redis_event*

*controller: default.py*
|
importcache_mod

defindex():
returndict(message=cache_mod.get_value())
|

*module: cache_mod.py*
|
importredis
importgrequests

redis_cache =redis.StrictRedis(host='localhost',port=6379,db=0)

defget_value(key='SOME_KEY'):
returnredis_cache.get(key)
|

view: index.html
|
{{=message}}
|

Once deployed on the server, access this url:
http://127.0.0.1:8000/redis_event/default/index

Reload the page successively - repeatedly F5 after page load - and
you will notice the error on the page.

Am moving away from grequests, and settling for just requests.



On Thursday, April 21, 2016 at 9:44:42 AM UTC+5:30, Kiran
Subbaraman wrote:

Thanks for the recommendation - IIS with web2py is a
recommended deployment on Windows.

The gevent-mix-up-with-rocket, was based on the stack trace I
pasted below. And like I mentioned, this connection was made
without any evidence ... so yeah, I was writing this before I
gave it too much thought or investigation.
In any case, I'll do some more investigation and try to track
down this issue.


Kiran Subbaraman
http://subbaraman.wordpress.com/about/


On Thu, 21-04-2016 3:42 AM, Niphlod wrote:

forget about uwsgi on windows. never really landed as
production-ready. fortunately iis can run python without any
hiccup and it's the current recommended way to deploy web2py
in production on windows.
that being said, I'm really eager to know how the hell you're
getting gevent mixed up with web2py's internal webserver,
which is not at all compatible with gevent. On Wednesday,
April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote:

Hello all, I use Windows 10 based laptop for my
development. By default, web2py serves its content via
the rocket server. My application makes use of the
'default' redis client () to connect to the local redis
server. I started noticing a stacktrace, in the cmd
prompt, from within which web2py has started:
|

CreatedbyMassimoDiPierro,Copyright2007-2016Version2.14.3-stable+timestamp.2016.03.26.17.54.43Databasedrivers

available:psycopg2,pymysql,imaplib,sqlite3,pg8000,pyodbc,mysqlconnector
please visit:http://127.0.0.1:8000/
starting browser...please visit: 
  http://127.0.0.1:8000/

starting
browser...2016-04-2020:26:54,003-Rocket.Errors.Port8000-ERROR
-Traceback(most recent call
last):File"d:\code\git\web2py\gluon\rocket.py",line
587,inlisten sock,addr

=self.listener.accept()File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
316,inaccept

self._wait(self._read_event)File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
300,in_wait

self.hub.wait(watcher)File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
348,inwait result

=waiter.get()File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line

575,ingetreturnself.hub.switch()File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
338,inswitchreturngreenlet.switch(self)LoopExit:Thisoperation
would block forever
|
The error in the error-ticket is:
|
This operation would block
forever Version web2py™ Version
2.14.3-stable+timestamp.2016.03.26.17.54.43 Python
Python 2.7.10: D:\programs\open\python27\python.exe

(prefix: D:\programs\open\python27) Traceback Traceback
(most recent call last): 

Re: [web2py] Changing color of field

2016-04-21 Thread Javier Pepe
Hello

If you use bootstrap, can change the class of field

http://getbootstrap.com/css/#helper-classes-backgrounds



On Thu, Apr 21, 2016 at 9:39 AM, Md Anam Raihan 
wrote:

> I am creating task management app and i want to change color of field if
> deadline is completed then how to do it using javascript also i am facing
> problem in extracting datetime from my field??
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Changing color of field

2016-04-21 Thread Md Anam Raihan
I am creating task management app and i want to change color of field if 
deadline is completed then how to do it using javascript also i am facing 
problem in extracting datetime from my field??

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


[web2py] Re: Not web2py related but want an advice.

2016-04-21 Thread Leonel Câmara
I would take it. It's always nice to have some idea of how something works, 
you never know when you might need it and you never know when the 
principles you learned in one area are going to help you solve problems in 
another. Frankly there's also not much about web development that you can't 
teach yourself with relative ease compared to that.


-- 
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: strange behaviour in after_insert callback

2016-04-21 Thread Niphlod
tried with f['amount']yet ?

On Thursday, April 21, 2016 at 7:57:20 AM UTC+2, 黄祥 wrote:
>
> meet strange behaviour in after_insert callback, when using variable (e.g. 
> f.amount) is not work, but when using dict (e.g. f['amount'] ) work
> models/db_wizard_4_subscription.py
> # not work
> def __after_insert_subscription_detail(f, id):
> unit = float(f.amount) / float(f.nav_per_unit)
>
> """
> # work
> def __after_insert_subscription_detail(f, id):
> unit = float(f['amount'] ) / float(f['nav_per_unit'] )
> """
>
> def on_define_subscription_detail(table): 
> table._after_insert.append(__after_insert_subscription_detail)
>
> db.define_table('subscription_detail', 
> Field('subscription_no', 'reference subscription_header'), 
> Field('account', 'reference account'), 
> Field('nav_date', 'date'),
> Field('nav_per_unit', 'double'),
> Field('amount', 'double'),
> Field('fee', 'double'),
> Field('fee_amount', 'double'),
> Field('unit', 'double'),
> auth.signature,
> on_define = on_define_subscription_detail, 
> format = '%(subscription_no)s')
>
> Traceback (most recent call last):
>   File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>  
> line 221, in 
>   File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 417, in 
> 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/controllers/install.py",
>  
> line 201, in index
> 'fee_amount' : 0}, ] )
>   File 
> "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", line 
> 831, in bulk_insert
> ret and [[f(item, ret[k]) for k, item in enumerate(items)] for f in 
> self._after_insert]
>   File 
> "/Users/MacBookPro/site/web2py/applications/mutualfunds/models/db_wizard_4_subscription.py",
>  
> line 43, in __after_insert_subscription_detail
> unit = float(f.amount) / float(f.nav_per_unit)
> AttributeError: 'dict' object has no attribute 'amount'
>
> controllers/install.py
> db.subscription_detail.bulk_insert([{'subscription_no' : 1, 'account' : 1, 
> 'nav_date' : '2016-01-01', 
> 'nav_per_unit' : 1.0, 'amount' : 1, 'fee' : 0, 
> 'fee_amount' : 0}, 
> {'subscription_no' : 2, 'account' : 1, 'nav_date' : '2016-01-02', 
> 'nav_per_unit' : 1.1, 'amount' : 2, 'fee' : 0, 
> 'fee_amount' : 0}, ] )
>
> anyone know about this behaviour? is it normal?
>
> 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/d/optout.


[web2py] Re: How do I send same mail to a list of email ids?

2016-04-21 Thread Emmanuel Dsouza
No that's not what I asked.
supposing i have a predefined list say L having many email ids. Can I 
simply send to a mail to everyone like this:
mail.send(to=L,
  

On Wednesday, April 20, 2016 at 2:17:11 AM UTC+5:30, Niphlod wrote:
>
> mail.send has to,cc and ccn that take either a list or a string. to send 
> to two email addresses in the "to", use 
>
> mail.send(to=['ma...@example.com ', 'ma...@example.com 
> '], )
>
> On Tuesday, April 19, 2016 at 10:24:34 PM UTC+2, Emmanuel Dsouza wrote:
>>
>> mail.send('ma...@some.com' , #here i want to attach a list of mail ids.
>> 'Subject',
>> 'Body'
>> )
>
>

-- 
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 do I send same mail to a list of email ids?

2016-04-21 Thread Emmanuel Dsouza
No that's what I asked.
supposing i have a predefined list say L having many email ids. Can I 
simply send to a mail to everyone like this:
mail.send(to=L,
  

On Wednesday, April 20, 2016 at 2:18:48 AM UTC+5:30, Dave S wrote:
>
>
>
> On Tuesday, April 19, 2016 at 1:24:34 PM UTC-7, Emmanuel Dsouza wrote:
>>
>> mail.send('ma...@some.com' , #here i want to attach a list of mail ids.
>> 'Subject',
>> 'Body'
>> )
>
>
> I think you just put a list in the 'to' argument.
>
> mail.send(['firs...@there.com ', 'secon...@elsewhere.net 
> ', 'thir...@nowhere.org ']), 
>
>
>
>  /dps
>
>

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


[web2py] Someone tell me what's wrong here?

2016-04-21 Thread Steve Joe
auth = Auth(db)
auth.user_email.readable=False
auth.user_email.writable=False

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


Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-21 Thread Niphlod
why would you use a library made to use gevent in an environment that 
doesn't support it ?
if you need to use gevent-coroutines-etc-etc-etc you need to have the 
COMPLETE env supporting it, not just a piece.

On Thursday, April 21, 2016 at 7:49:25 AM UTC+2, Kiran Subbaraman wrote:
>
> Narrowed down the issue. Basically, the grequests modules that I was using 
> seems to be the cause of the "LoopExit: This operation would block 
> forever"
>
> Create an application: *redis_event*
>
> *controller: default.py*
> import cache_mod
>
> def index():
> return dict(message=cache_mod.get_value())
>
> *module: cache_mod.py*
> import redis
> import grequests
>
> redis_cache = redis.StrictRedis(host='localhost', port=6379, db=0)
>
> def get_value(key='SOME_KEY'):
> return redis_cache.get(key)
>
> view: index.html
> {{=message}}
>
> Once deployed on the server, access this url: 
> http://127.0.0.1:8000/redis_event/default/index
> Reload the page successively - repeatedly F5 after page load - and you 
> will notice the error on the page.
>
> Am moving away from grequests, and settling for just requests.
>
>
>
> On Thursday, April 21, 2016 at 9:44:42 AM UTC+5:30, Kiran Subbaraman wrote:
>>
>> Thanks for the recommendation - IIS with web2py is a recommended 
>> deployment on Windows.
>>
>> The gevent-mix-up-with-rocket, was based on the stack trace I pasted 
>> below. And like I mentioned, this connection was made without any evidence 
>> ... so yeah, I was writing this before I gave it too much thought or 
>> investigation. 
>> In any case, I'll do some more investigation and try to track down this 
>> issue.
>>
>> 
>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>
>> On Thu, 21-04-2016 3:42 AM, Niphlod wrote:
>>
>> forget about uwsgi on windows. never really landed as production-ready. 
>> fortunately iis can run python without any hiccup and it's the current 
>> recommended way to deploy web2py in production on windows. 
>>
>> that being said, I'm really eager to know how the hell you're getting 
>> gevent mixed up with web2py's internal webserver, which is not at all 
>> compatible with gevent.
>>
>> On Wednesday, April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote: 
>>>
>>> Hello all,
>>> I use Windows 10 based laptop for my development. By default, web2py 
>>> serves its content via the rocket server. 
>>> My application makes use of the 'default' redis client () to connect to 
>>> the local redis server.
>>> I started noticing a stacktrace, in the cmd prompt, from within which 
>>> web2py has started:
>>> Created by Massimo Di Pierro, Copyright 2007-2016
>>> Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>>> Database drivers available: psycopg2, pymysql, imaplib, sqlite3, pg8000, 
>>> pyodbc, mysqlconnector
>>> please visit:
>>> http://127.0.0.1:8000/
>>> starting browser...
>>> please visit:
>>> http://127.0.0.1:8000/
>>> starting browser...
>>> 2016-04-20 20:26:54,003 - Rocket.Errors.Port8000 - ERROR - Traceback (most 
>>> recent call last):
>>>   File "d:\code\git\web2py\gluon\rocket.py", line 587, in listen
>>> sock, addr = self.listener.accept()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>>> line 316, in accept
>>> self._wait(self._read_event)
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>>> line 300, in _wait
>>> self.hub.wait(watcher)
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 348, in wait
>>> result = waiter.get()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 575, in get
>>> return self.hub.switch()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 338, in switch
>>> return greenlet.switch(self)
>>> LoopExit: This operation would block forever
>>>
>>> The error in the error-ticket is:
>>>  This operation would block forever
>>> Version
>>> web2py™ Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>>> Python Python 2.7.10: D:\programs\open\python27\python.exe (prefix: 
>>> D:\programs\open\python27)
>>> Traceback
>>>
>>>
>>> Traceback (most recent call last):
>>>   File "d:\code\git\web2py\gluon\restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>>> line 99, in 
>>>   File "d:\code\git\web2py\gluon\globals.py", line 417, in 
>>> self._caller = lambda f: f()
>>>   File "d:\code\git\web2py\gluon\cache.py", line 661, in wrapped_f
>>> rtn = func()
>>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>>> line 68, in data
>>> data = api.get_data(url)
>>>   File "applications\myapp\modules\data\api.py", line 145, in get_data
>>> return _get_data_for(url) if url else None
>>>   File "applications\myapp\modules\data\api.py", line 164, in 
>>> _get_data_for
>>> force_reload=rebuild
>>>   

[web2py] Error importing module from within a virtual method field defined in another module

2016-04-21 Thread Lisandro
I have a virtual method field, and its associated function is defined 
inside a module.
That function imports another function defined in another module.
And that last function also imports another module.


The virtual method function works ok when I call it from a controller 
function.
However, if I call that method in the scheduler environment, I have the 
error "Cannot import module mercadopago"


The virtual method field is defined in db.py like this:
from virtual_methods import set_metodo_pago

db.define_table('sitios',
  Field('nombre'), 
  Field.Method('set_metodo_pago', lambda row, metodo_pago: 
sitios_set_metodo_pago(row, metodo_pago)))


These are my modules:
modules/virtual_methods.py
modules/globals.py
modules/mercadopago.py
modules/scheduler_functions.py


in modules/virtual_methods.py
def set_metodo_pago(row, metodo_pago):
from globals import get_mercadopago_client
mp = get_mercadopago_client()
...



in modules/globals.py
def get_mercadopago_client():
import mercadopago
return MP.client()
...


in modules/scheduler_function.py
def instalar_nuevo_sitio(nombre):
   db = current.db
   sitio = db(db.sitios.nombre == nombre).select().first()
   sitio.set_metodo_pago(metodopago='ticket') # this is the line that 
throws the error


However, the same line works ok if I call it from a controller/function.
What am I missing?

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


[web2py] Re: Not web2py related but want an advice.

2016-04-21 Thread Michael Beller
imho, taking advantage of courses in college to broaden and deepen your 
understanding of computer science (and areas outside computer science) is 
very worthwhile.

it's hard to predict where your career will lead and what "web development" 
will be in 5, 10, 15, years and beyond.  "web development" at Twitter is 
also a very different experience than "web development" for a startup.


On Thursday, April 21, 2016 at 4:36:21 AM UTC-4, Emmanuel Dsouza wrote:
>
> So my college is offering me to do a parallel programming and CUDA course. 
> I am inclined towards making a career in web development. Should i go for 
> this course? Does it have any good scope in web development too or should I 
> invest time learning web development itself nicely.

-- 
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] Not web2py related but want an advice.

2016-04-21 Thread Emmanuel Dsouza
So my college is offering me to do a parallel programming and CUDA course. I am 
inclined towards making a career in web development. Should i go for this 
course? Does it have any good scope in web development too or should I invest 
time learning web development itself nicely.

-- 
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] How to append (not erase and write) something to my div with id target called by ajax?

2016-04-21 Thread Emmanuel Dsouza
ajax('{{=URL('default', 'ignite')}}', 'q', 'target');


So taeget is the id of div which shoes something as per requested by the user. 
But I want the old results too. How do I simply append and not get rewritten 
stuffs?

-- 
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: ckeditor error

2016-04-21 Thread Carlos Kitu
Hi Henk,
I recently used this slice for one of the projects I'm working on(still at 
web2py 2.13.4), and everything went fine:
http://www.web2pyslices.com/slice/show/1345/using-ckeditor-for-text-fields

Actually I didn't need the upload feature and applied a simplified 
configuration.

Did you follow those instructions?

Best regards.


El miércoles, 20 de abril de 2016, 2:17:55 (UTC+2), Henk huisman escribió:
>
> I installed ckEditor from the repository.
>
> When I try to use it with a simple SQLFORM like
>
>
> def test():
>
> form = SQLFORM.factory(
>
> Field('requiredfield', required=True, notnull=True),
>
> Field('textfield', 'text', widget=ckeditor.widget)
>
> )
>
> return dict(form=form)
>
>
>
> I get a SyntaxError: Unexpected token ,
>
>
> Anybody an idea what is going wrong?
>
> Version 2.14.3
>
>
>
>
>
>

-- 
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] E2E Automated Tests

2016-04-21 Thread Matheus Cardoso
What do you guys use as a "solution" to E2E tests? I think this is a weak 
part of web2py. I know WebClient solution, but it's still uses the same 
"db" defined in db.py and prevents me to use Selenium, for instance. Let me 
give a example: in Django, one can write a test.py in an app, define some 
TestCase classes and then run (*python manage.py test*) in a complete 
separated "test environment", with separated test database, method's 
isolation, etc. What is correspondent way in web2py? (sorry for the 
comparison, but this is my daily routine, django in work and web2py to my 
side jobs).

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