[web2py] Re: session data type changed after upgrade to 2.17.1

2018-08-22 Thread icodk
Yes Antony, You got it right 
The issue is that both
 form.vars.start_date and  form.vars.end_date
returns a str type. 
Exactly the same code under 2.14.6 returns a 'date' type

On Thursday, August 23, 2018 at 6:02:49 AM UTC+2, Anthony wrote:
>
> On Wednesday, August 22, 2018 at 6:41:06 PM UTC-4, Joe Barnhart wrote:
>>
>> So "session" stuff gets pickled and unpicked which makes sense that dates 
>> might come back as strings.
>>
>
> Pickling preserves the data type. That is not the issue here. The problem 
> is the values in form.vars used to be dates and are now strings. Those 
> values are being stored in the session, but the problem happens before 
> anything gets to the session.
>
> Anthony
>

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


[web2py] Re: session data type changed after upgrade to 2.17.1

2018-08-22 Thread Anthony
On Wednesday, August 22, 2018 at 6:41:06 PM UTC-4, Joe Barnhart wrote:
>
> So "session" stuff gets pickled and unpicked which makes sense that dates 
> might come back as strings.
>

Pickling preserves the data type. That is not the issue here. The problem 
is the values in form.vars used to be dates and are now strings. Those 
values are being stored in the session, but the problem happens before 
anything gets to the session.

Anthony

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


[web2py] Re: Need to add form "warnings" in addition to "errors"

2018-08-22 Thread Joe Barnhart
I hate to answer my own post, but what if I did something in a customer 
Validator?  What if the error returned by my validator was something like 
SPAN("blah blah", _class="warning").  Presumably I could search the FORM 
using elements() finding my SPANs and then modify the enclosing DIVs to be 
class "warning" also.  I'd provide different CSS for the yellow background. 
 Just thinking out loud here.

On Wednesday, August 22, 2018 at 3:31:14 PM UTC-7, Joe Barnhart wrote:
>
> I'm looking to add "warnings" to forms using (/hijacking) as much of the 
> existing form "errors" mechanism as possible.  The idea is to provide a 
> second level check that gives advice rather than drop-dead errors.
>
> I would like it to operate like this:
>
> 1.  The form is submitted and checked for errors as usual. 
>
> 2.  After the error check another set of criteria, "warnings",  are 
> checked.  Where the errors are added as red elements below the fields, I'd 
> like these to be added in yellow to delineate the difference.
>
> 3.  The user gets a chance to fix the errors and warnings (as in standard 
> practice).
>
> 4.  If the error check passes but there are still warnings, the warnings 
> are displayed.
>
> 5.  Whatever the user submits after the "warnings only" check is accepted.
>
> I can figure out the two-phase form submit.  I was having a little 
> difficulty trying to imagine how to hijack the error message code that adds 
> the error wrapper.  Currently that's done in the xml method for the INPUT, 
> for example, and I don't see an easy way to extend that without subclassing 
> each of the controls and adding my stuff.  Even then, the Fields and such 
> would want to add the original INPUT and not my subclassed version, leading 
> to more fun and hilarity. 
>
> Any simple ideas from the web2py blackbelts?  I'm a brownbelt and can 
> probably implement it if you give me a hint.
>
> -- Joe
>
> P.S. An example of a warning would be if a user fills in his parent's last 
> name as his first name.  It's possible, but much more likely they just 
> switched the first name / last name fields.  (Happens a lot, for some 
> reason.)
>
>

-- 
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: session data type changed after upgrade to 2.17.1

2018-08-22 Thread Joe Barnhart
So "session" stuff gets pickled and unpicked which makes sense that dates 
might come back as strings.  What puzzles me is that it "used to work" so 
did pickled date objects used to come back as date objects again?  That 
would seem like a much bigger change than just this example.

-- Joe

On Tuesday, August 21, 2018 at 1:28:44 PM UTC-7, icodk wrote:
>
> Turned out that after the upgrade  the   form.vars.end_date and 
> form.vars.end_date(both 
> defined as type 'date') returns a data type str instead of a 'date' type
>
> The form definition is:
>
> form = SQLFORM.factory(
> Field('start_date', 'date', label=T('Date range: '))
> ,Field('end_date', 'date', label=T(''))
> ,Field('amount',label=T('Total'),default=def_amount, widget=lambda f, v: 
> SQLFORM.widgets.string.widget(f, v, _disabled=True))
> ,Field('online_order','boolean',label=T('Online 
> orders'),default=session.online_order)
> ,Field('manual_order','boolean',label=T('Manual 
> orders'),default=session.manual_order)
>
>
> And then later the session vars gets 'infected'  as  str by the form.vars 
> that should return 'date'
>
> if form.process().accepted:
> session.start_date=*form.vars.start_date *# here the form.vars.start_date 
> is of type str
> session.end_date = *form.vars.end_date   *# here the form.vars.end_date 
> is of type str
> session.online_order=form.vars.online_order
> session.manual_order = form.vars.manual_order
>
>
>
>
>
>
>
> On Tuesday, August 21, 2018 at 12:56:34 PM UTC+2, icodk wrote:
>>
>> Have:
>>
>> session.end_date=request.now.date()
>>
>> and then retrieve it as:
>>
>> datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)
>>
>> this all worked fine in 2.14.6
>>
>> but after upgrade to 2.17.1 I get:
>>
>> datetimeEnd=datetime.datetime.combine(session.end_date, datetime.time.max)
>>
>> TypeError: combine() argument 1 must be datetime.date, not str
>>
>>
>>
>>

-- 
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] Need to add form "warnings" in addition to "errors"

2018-08-22 Thread Joe Barnhart
I'm looking to add "warnings" to forms using (/hijacking) as much of the 
existing form "errors" mechanism as possible.  The idea is to provide a 
second level check that gives advice rather than drop-dead errors.

I would like it to operate like this:

1.  The form is submitted and checked for errors as usual. 

2.  After the error check another set of criteria, "warnings",  are 
checked.  Where the errors are added as red elements below the fields, I'd 
like these to be added in yellow to delineate the difference.

3.  The user gets a chance to fix the errors and warnings (as in standard 
practice).

4.  If the error check passes but there are still warnings, the warnings 
are displayed.

5.  Whatever the user submits after the "warnings only" check is accepted.

I can figure out the two-phase form submit.  I was having a little 
difficulty trying to imagine how to hijack the error message code that adds 
the error wrapper.  Currently that's done in the xml method for the INPUT, 
for example, and I don't see an easy way to extend that without subclassing 
each of the controls and adding my stuff.  Even then, the Fields and such 
would want to add the original INPUT and not my subclassed version, leading 
to more fun and hilarity. 

Any simple ideas from the web2py blackbelts?  I'm a brownbelt and can 
probably implement it if you give me a hint.

-- Joe

P.S. An example of a warning would be if a user fills in his parent's last 
name as his first name.  It's possible, but much more likely they just 
switched the first name / last name fields.  (Happens a lot, for some 
reason.)

-- 
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] Problem with CAS and basic authentication

2018-08-22 Thread kakella
My app is configured with CAS (another web2py instance with Active 
Directory integrated) and authentication works. Now I want to enable basic 
authentication for certain calls via curl and cannot make it to work. When 
I invoke the curl command I get a redirect to the CAS login page. 

auth.settings.allow_basic_login = True has been set.


Apache has WSGIPassAuthorization On


request.env has the BASIC_AUTHORIZATION information in the request. Is any 
> additional configuration needed to make basic auth work?

-- 
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: Search for list:string values in grid search?

2018-08-22 Thread Dave S


On Wednesday, August 22, 2018 at 12:39:29 PM UTC-7, Marcelo Huerta wrote:
>
>
> El martes, 14 de agosto de 2018, 10:59:53 (UTC-3), Marcelo Huerta escribió:
>>
>> Is it possible at all to search for values contained in fields defined as 
>> list:string in the grid search dialog?
>>
>
> Anyone? 
>

In general, a list of strings can be searched with "if xs is in xl:"

You probably have a more specific question, but I think we need more 
context.  Do you want to search in the controller after the grid action has 
been submitted, or do want to have the user search the grid for a value?

/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: Search for list:string values in grid search?

2018-08-22 Thread Marcelo Huerta

El martes, 14 de agosto de 2018, 10:59:53 (UTC-3), Marcelo Huerta escribió:
>
> Is it possible at all to search for values contained in fields defined as 
> list:string in the grid search dialog?
>

Anyone? 

-- 
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: scheduler DAL object has no attribute

2018-08-22 Thread Anthony
Where and how is db.mail_logger defined? Is it possible either the code 
that defines it is not being run, or that the db object is being redefined 
after it has run?

On Wednesday, August 22, 2018 at 8:34:08 AM UTC-4, Yebach wrote:
>
> Attaching code
>
>
> #scheduler koda za pošiljanje mailov za stanje števcev
> def send_mail_stevci(first_reminder = False):
> dons = datetime.datetime.now()
> #a = True
> try:
> if dons.day in [22,25,28]:
> #if a:
> counters_data_oddani = db((db.counters.c_date.year() == 
> dons.year) &
>(db.counters.c_date.month() == 
> dons.month)).select(db.counters.c_user_inserted,
>   
> db.counters.c_machine_id,
>   
> db.machines.m_code,
>   
> join= db.machines.on(db.machines.id == 
> db.counters.c_machine_id)).as_list()
> users_machines = db(db.user_machines.um_status == 
> 1).select(db.user_machines.um_user,
> db.machines.m_code,
> db.machines.id,
> db.auth_user.email,
> join = 
> [db.machines.on(db.user_machines.um_machine == db.machines.id),
> 
> db.auth_user.on(db.user_machines.um_user == db.auth_user.id)]).as_list()
>
>
>
>
> from itertools import groupby
> from operator import itemgetter
>
> nw_users_machines = []
> #pogledamo kaj vse mašine ki jih user ima in za katere ni še 
> oddal ta mesec
> #glede na to mu bomo pol pošiljal maile
> for rec in users_machines:
> if not any(d['counters']['c_machine_id'] == 
> rec["machines"]["id"] for d in counters_data_oddani):
> nw_users_machines.append({"user": 
> rec["user_machines"]["um_user"], "m_code" : rec["machines"]["m_code"], 
> "email": rec["auth_user"]["email"],
>   "machine_id": 
> rec["machines"]["id"]})
>
>
>
> #print nw_masine_neoodanih
>
> masine_uporabnikov_unique = [dict(t) for t in 
> set([tuple(d.items()) for d in nw_users_machines])]
>
> #sortiramo po worker_nick
> sortWorkers = sorted(masine_uporabnikov_unique , 
> key=itemgetter('user'))
> #print sortWorkers
> grouper = lambda x: (x["user"])
> result = []
> #print masine_neoddanih_unique
> masine_uporabnikov_grupirane= []
> for key, grp in groupby(sorted(sortWorkers, key = grouper), 
> grouper):
> group = list(grp)
> all_machines =  [item['m_code'] for item in group]
> all_machines_codes = [(item['machine_id']) for item in 
> group]
> # print group
> # print group[0]["user"], all_machines
> masine_uporabnikov_grupirane.append({"user": 
> group[0]["user"], "mail" :group[0]["email"], "machines": all_machines, 
> "machines_codes": all_machines_codes})
>
> for neoddan in masine_uporabnikov_grupirane:
> #if neoddan["machines"]:
> if neoddan["mail"] == 'vid.og...@gmail.com':
> mail_send = False
> dan = dons.day
> #dan = 28
> msg = "Email ni bil poslan. Ali še ni pravi datum ali 
> pa nekaj ne dela"
> if dan == 22:
>
> msg = """Pozdravljeni,
> 
> bliža se konec meseca in ponovno je čas, da 
> pristopite k vašim napravam, jim ukažete, da vam pokažejo,
> koliko ste jih v tem mesecu mučili s tiskanjem ter 
> nam to sporočite preko našega portala.
> 
> Oddati morate stanja števcev za naprave s kodami 
> %s .
> 
> Sledite povezavi:
> 
> http://stevci.bilban-resitve.si:8000/bilbanstevci/default/index/login
> kjer se prijavite z vašim uporabniškim imenom in 
> geslom, katerega že poznate, ter oddate stanja za vsako napravo,
> ki jo uporabljate.
> 
> Punce v našem podjetju vam bodo zelo hvaležne, saj 
> jim boste olajšali delo. Prav tako vas ne bodo motile pri vašem delu
> s prošnjami glede stanja števcev, saj imate 
> zagotovo dovolj dela, ker se bliža konec meseca. 
> 
> Za vsa vprašanja smo vam na voljo na 
> ste...@bilban-resitve.si 
> 
> Le

[web2py] Re: scheduler DAL object has no attribute

2018-08-22 Thread Yebach
Attaching code


#scheduler koda za pošiljanje mailov za stanje števcev
def send_mail_stevci(first_reminder = False):
dons = datetime.datetime.now()
#a = True
try:
if dons.day in [22,25,28]:
#if a:
counters_data_oddani = db((db.counters.c_date.year() == 
dons.year) &
   (db.counters.c_date.month() == 
dons.month)).select(db.counters.c_user_inserted,

  db.counters.c_machine_id,

  db.machines.m_code,

  join= db.machines.on(db.machines.id == 
db.counters.c_machine_id)).as_list()
users_machines = db(db.user_machines.um_status == 
1).select(db.user_machines.um_user,
db.machines.m_code,
db.machines.id,
db.auth_user.email,
join = 
[db.machines.on(db.user_machines.um_machine == db.machines.id),

db.auth_user.on(db.user_machines.um_user == db.auth_user.id)]).as_list()




from itertools import groupby
from operator import itemgetter

nw_users_machines = []
#pogledamo kaj vse mašine ki jih user ima in za katere ni še 
oddal ta mesec
#glede na to mu bomo pol pošiljal maile
for rec in users_machines:
if not any(d['counters']['c_machine_id'] == 
rec["machines"]["id"] for d in counters_data_oddani):
nw_users_machines.append({"user": 
rec["user_machines"]["um_user"], "m_code" : rec["machines"]["m_code"], 
"email": rec["auth_user"]["email"],
  "machine_id": 
rec["machines"]["id"]})



#print nw_masine_neoodanih

masine_uporabnikov_unique = [dict(t) for t in 
set([tuple(d.items()) for d in nw_users_machines])]

#sortiramo po worker_nick
sortWorkers = sorted(masine_uporabnikov_unique , 
key=itemgetter('user'))
#print sortWorkers
grouper = lambda x: (x["user"])
result = []
#print masine_neoddanih_unique
masine_uporabnikov_grupirane= []
for key, grp in groupby(sorted(sortWorkers, key = grouper), 
grouper):
group = list(grp)
all_machines =  [item['m_code'] for item in group]
all_machines_codes = [(item['machine_id']) for item in 
group]
# print group
# print group[0]["user"], all_machines
masine_uporabnikov_grupirane.append({"user": 
group[0]["user"], "mail" :group[0]["email"], "machines": all_machines, 
"machines_codes": all_machines_codes})

for neoddan in masine_uporabnikov_grupirane:
#if neoddan["machines"]:
if neoddan["mail"] == 'vid.og...@gmail.com':
mail_send = False
dan = dons.day
#dan = 28
msg = "Email ni bil poslan. Ali še ni pravi datum ali 
pa nekaj ne dela"
if dan == 22:

msg = """Pozdravljeni,

bliža se konec meseca in ponovno je čas, da 
pristopite k vašim napravam, jim ukažete, da vam pokažejo,
koliko ste jih v tem mesecu mučili s tiskanjem ter 
nam to sporočite preko našega portala.

Oddati morate stanja števcev za naprave s kodami 
%s .

Sledite povezavi:

http://stevci.bilban-resitve.si:8000/bilbanstevci/default/index/login
kjer se prijavite z vašim uporabniškim imenom in 
geslom, katerega že poznate, ter oddate stanja za vsako napravo,
ki jo uporabljate.

Punce v našem podjetju vam bodo zelo hvaležne, saj 
jim boste olajšali delo. Prav tako vas ne bodo motile pri vašem delu
s prošnjami glede stanja števcev, saj imate 
zagotovo dovolj dela, ker se bliža konec meseca. 

Za vsa vprašanja smo vam na voljo na 
ste...@bilban-resitve.si 

Lep pozdrav

Ekipa Bilban
""" % (', '.join(x for x in 
neoddan["machines"]))
#print msg
mail_send = mail_reminder(neoddan, msg)

elif dan == 25:
msg = """Pozdravljeni,

radi bi vam sporočili, da smo že 25. v 
mesecu, sistem pa nam sporoč

[web2py] Re: scheduler DAL object has no attribute

2018-08-22 Thread Anthony
Hard to say without seeing code. Obviously the mail_logger table is not 
defined in the context of the task being executed. Is it possible the db 
object is redefined somewhere in the code?

On Wednesday, August 22, 2018 at 6:15:47 AM UTC-4, Yebach wrote:
>
> Hello
>
> I have a scheduler running some emailing tasks. After email is sent it 
> should write into table mail_logger. When insert should happen I get an 
> error DAL object has no attribute mail_logger. 
>
> On my test environment everything is working fine. 
>
> any suggestions?
>
> Thank you
>

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


[web2py] scheduler DAL object has no attribute

2018-08-22 Thread Yebach
Hello

I have a scheduler running some emailing tasks. After email is sent it 
should write into table mail_logger. When insert should happen I get an 
error DAL object has no attribute mail_logger. 

On my test environment everything is working fine. 

any suggestions?

Thank you

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


Re: [web2py] Re: Cookies and redirect

2018-08-22 Thread Carlos Correia
Às 03:28 de 22-08-2018, Anthony escreveu:
> On Tuesday, August 21, 2018 at 12:37:16 PM UTC-4, Carlos Correia wrote:
>
> Hi,
>
>
> Is it possible to set a cookie and redirect to another page in the same
> controller?
>
> If yes, how? I tried this simple example but the cookie is lost if I use
> the redirect...
>
> def cookies2():
> cookie_name = 'name' cookie_value = 'value' response.cookies[ 
> cookie_name ] = cookie_value
> response.cookies[ cookie_name ][ 'expires' ] = 24 * 3600 
> response.cookies[ cookie_name ][ 'path' ] = '/' response.cookies[ cookie_name 
> ][ 'secure' ] = True redirect( URL( c='test', f='cookie_result' ) )
>
>
> Instead of using redirect, you can use HTTP() directly:
>
> |
> raiseHTTP(303,cookies=response.cookies,Location=URL('test','cookie_result'))
> |
>
> redirect() is simply a shortcut for the above (minus the cookies).
>
> 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.


Thanks, Anthony :)


Carlos Correia
=
MEMÓRIA PERSISTENTE
GSM:  917 157 146
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt (NOVO)
GnuPG: wwwkeys.eu.pgp.net
URL Suporte: https://t5.m16e.com/gps

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