[web2py] Re: info: bootstrap3 compact form

2016-05-30 Thread Mirek Zvolský
This one is better for form.add_button() [see col_class_rest]
+uses smaller buttons [see btn-group-sm]


*def formstyle_bootstrap3_compact_factory(col_label_size=2, 
col_help_size=6,**
 input_class='input-sm', control_label='control-label-sm'):*
*"""formstyle=formstyle_bootstrap3_compact_factory()*
*TODO: control-label-sm není defnovaná (jako control-label, ale bez 
posunu dolů*
*"""*
*def _inner(form, fields):*
*form.add_class('form-horizontal')*
*label_col_class = "col-sm-%d" % col_label_size*
*col_class = "col-sm-%d" % (12 - col_label_size - 
col_help_size)*
*col_class_rest = "col-sm-%d" % (12 - col_label_size)*
*offset_class = "col-sm-offset-%d" % col_label_size*
*help_class = "col-sm-%d" % col_help_size*
*parent = CAT()*
*for id, label, controls, help in fields:*
*# wrappers*
*_help = DIV(SPAN(help, _class='help-block'), _class="%s" % 
(help_class))*
*# embed _help into _controls*
*_controls = DIV(controls, _class="%s" % (col_class))*
*if isinstance(controls, INPUT):*
*if controls['_type'] == 'submit':*
*controls.add_class('btn btn-primary')*
*_controls = DIV(DIV(controls, 
_class="btn-group-sm"),*
*_class="%s %s" % (col_class_rest, 
offset_class))*
*if controls['_type'] == 'button':*
*controls.add_class('btn btn-default')*
*elif controls['_type'] == 'file':*
*controls.add_class('input-file')*
*controls.add_class(input_class)*
*elif controls['_type'] in ('text', 'password'):*
*controls.add_class('form-control')*
*controls.add_class(input_class)*
*elif controls['_type'] == 'checkbox':*
*label['_for'] = None*
*label.insert(0, controls)*
*label.insert(1, ' ')*
*_controls = DIV(DIV(label, _class="checkbox"),*
*_class="%s %s" % (offset_class, 
col_class))*
*label = ''*
*elif isinstance(controls, (SELECT, TEXTAREA)):*
*controls.add_class('form-control')*
*controls.add_class(input_class)*

*elif isinstance(controls, SPAN):*
*_controls = P(controls.components,*
*  _class="form-control-static %s" % 
col_class)*
*elif isinstance(controls, UL):*
*for e in controls.elements("input"):*
*e.add_class('form-control')*
*if isinstance(label, LABEL):*
*label['_class'] = add_class(label.get('_class'),*
*'%s %s' % (control_label, 
label_col_class))*

*parent.append(DIV(label, _controls, _help, _class='row', 
_id=id))*
*return DIV(parent, _class='form-group')*
*return _inner*

-- 
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: Notification similar to django-notification

2016-05-30 Thread eric cuver
you can use api notification html 5  or other APIs such as 
notification http://docs.localytics.com/index.html

Le lundi 30 mai 2016 06:33:23 UTC+2, billmac...@gmail.com a écrit :
>
> You can look at facebook notification, basically an interface where user 
> pick how they want to receive their notification, by email or texts etc. 
> Toggle them on and off and when they log into their dashboard they see the 
> notifications and receive them as they have it set up in their settings. 
> Its pretty standard for big applications. But since its a volunteer driven 
> org/framework, it may be its not possible to get a package like that. 
>
> On Friday, May 20, 2016 at 10:33:56 AM UTC-4, eric cuver wrote:
>>
>> you can give the django notifcation links to see 
>>
>> Le vendredi 13 mai 2016 16:14:26 UTC+2, billmac...@gmail.com a écrit :
>>>
>>> Is there a plugin/package for web2py that is similar to 
>>> django-notification for emails, texts and other activities?
>>>
>>>

-- 
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] bug web2py ticket json

2016-05-30 Thread Alessio Varalta
Hi, I notice a big problem with the ticket report when you use json.

I have a controller where i take from the body the json with simple json 
and after parsing the body.

The problem is that if there is an error the ticket reporting an error of 
decoding json in any cases...For example in my case the error was the wrong 
name of table or in another case a null pointer exception but web2py 
reporting alway the error on json 

-- 
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: auth_user boolean extrafield odd behavior

2016-05-30 Thread Pierre
oups.this was a bad idea. I will never do it again
I didn't know auth_user was so "ticklish" (especially under the arms)it 
probably depends on the current user...


thanks 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] web2py scheduler service dead - how to prevent it?

2016-05-30 Thread Mirek Zvolský
Please help

Debian Jessie, postgres, web2py-scheduler

How can I prevent following crash - inactive scheduler?
Or how can I be sure that the scheduler is running and restart it if needed?



/etc/systemd/system/web2py-scheduler.service
-
[Unit]
Description=Web2py Scheduler service

[Service]
ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K 
codex2020,codex2020,codex2020
Type=simple

[Install]
WantedBy=multi-user.target
-


systemctl status web2py-scheduler
-
web2py-scheduler.service - Web2py Scheduler service 

   
  Loaded: loaded (/etc/systemd/system/web2py-scheduler.service; enabled) 
   
  Active: inactive (dead) since Mon 2016-05-30 02:16:39 CEST; 9h ago   
 < INACTIVE !! 
  
 Process: 5552 ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K 
codex2020,codex2020,codex2020 (code=exited, status=0/SUCCESS)   
Main PID: 5552 (code=exited, status=0/SUCCESS) 

 


May 30 02:16:39 mzDebian python[5552]: File 
"/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1697, in execute 
 
May 30 02:16:39 mzDebian python[5552]: self.handle_messages(cursor) 
 
May 30 02:16:39 mzDebian python[5552]: File 
"/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1770, in 
handle_messages  
May 30 02:16:39 mzDebian python[5552]: self._close() 


May 30 02:16:39 mzDebian python[5552]: File 
"/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1438, in _close 
  
May 30 02:16:39 mzDebian python[5552]: self._flush() 


May 30 02:16:39 mzDebian python[5552]: File "/usr/lib/python2.7/socket.py", 
line 303, in flush   
May 30 02:16:39 mzDebian python[5552]: 
self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
  
May 30 02:16:39 mzDebian python[5552]: error: [Errno 32] Broken pipe 

May 30 02:16:39 mzDebian python[5552]: Processes started   


-- 
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: web2py scheduler service dead - how to prevent it?

2016-05-30 Thread Mirek Zvolský
I have found this
https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

Service section should contain following:
[Service]
Restart=always

It looks like it works,
so I hope it will be well.




Dne pondělí 30. května 2016 12:15:18 UTC+2 Mirek Zvolský napsal(a):
>
> Please help
>
> Debian Jessie, postgres, web2py-scheduler
>
> How can I prevent following crash - inactive scheduler?
> Or how can I be sure that the scheduler is running and restart it if 
> needed?
>
>
>
> /etc/systemd/system/web2py-scheduler.service
> -
> [Unit]
> Description=Web2py Scheduler service
>
> [Service]
> ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K 
> codex2020,codex2020,codex2020
> Type=simple
>
> [Install]
> WantedBy=multi-user.target
> -
>
>
> systemctl status web2py-scheduler
> -
> web2py-scheduler.service - Web2py Scheduler service 
>   
>  
>   Loaded: loaded (/etc/systemd/system/web2py-scheduler.service; enabled) 
>
>   Active: inactive (dead) since Mon 2016-05-30 02:16:39 CEST; 9h ago   
>  < INACTIVE !! 
>   
>  Process: 5552 ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py 
> -K codex2020,codex2020,codex2020 (code=exited, status=0/SUCCESS)   
> Main PID: 5552 (code=exited, status=0/SUCCESS) 
>   
>
>
>   
>   
> May 30 02:16:39 mzDebian python[5552]: File 
> "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1697, in execute 
>  
> May 30 02:16:39 mzDebian python[5552]: self.handle_messages(cursor) 
>  
> May 30 02:16:39 mzDebian python[5552]: File 
> "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1770, in 
> handle_messages  
> May 30 02:16:39 mzDebian python[5552]: self._close() 
>   
>   
> May 30 02:16:39 mzDebian python[5552]: File 
> "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1438, in _close 
>   
> May 30 02:16:39 mzDebian python[5552]: self._flush() 
>   
>   
> May 30 02:16:39 mzDebian python[5552]: File 
> "/usr/lib/python2.7/socket.py", line 303, in flush 
>   
> May 30 02:16:39 mzDebian python[5552]: 
> self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
>   
> May 30 02:16:39 mzDebian python[5552]: error: [Errno 32] Broken pipe 
> 
> May 30 02:16:39 mzDebian python[5552]: Processes started   
> 
>
>

-- 
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: auth_user boolean extrafield odd behavior

2016-05-30 Thread Pierre
Does *session.forget() *affects the way users login/logout/signup..etc ?

should  *session.forget() * be placed in every controller function or is 
there a way to apply it globally ?

-- 
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 Scheduler on pythonanywhere

2016-05-30 Thread Scott Hunter
I have an appliance hosted on pythonanywhere which uses the Scheduler 
(invoked using a separate web2py process with the -K switch).

This setup in my test environment (OS X at home) works fine, but on 
pythonanywhere, the scheduler process generates a stream of errors like:

ERROR:web2py.scheduler.giles-livetask2#30970:Error coordinating TICKER
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error coordinating TICKER
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status


Attempts to schedule a task fail to even have a new task record inserted, 
much less executing that task.

It was working a week ago.  I thought it might be due to upgrading to 
2.14.6, but the last successful tasks show 
"web2py.scheduler.giles-livetask", so maybe the problem came after that 
upgrade.

I thought maybe the scheduler database was corrupted, but I can view the 
records via the admin appliance.

Any suggestions as to what I should investigate next would be appreciated.

- Scott

-- 
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: Problem with Scheduler on pythonanywhere

2016-05-30 Thread Niphlod
that error comes only on two codepaths: tables that are missing columns 
(and/or have different column types) and database locks.
try dropping tables, letting scheduler recreate them and see what happens.

On Monday, May 30, 2016 at 1:53:04 PM UTC+2, Scott Hunter wrote:
>
> I have an appliance hosted on pythonanywhere which uses the Scheduler 
> (invoked using a separate web2py process with the -K switch).
>
> This setup in my test environment (OS X at home) works fine, but on 
> pythonanywhere, the scheduler process generates a stream of errors like:
>
> ERROR:web2py.scheduler.giles-livetask2#30970:Error coordinating TICKER
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error coordinating TICKER
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
> ERROR:web2py.scheduler.giles-livetask2#30970:error popping tasks
> ERROR:web2py.scheduler.giles-livetask2#30970:Error retrieving status
>
>
> Attempts to schedule a task fail to even have a new task record inserted, 
> much less executing that task.
>
> It was working a week ago.  I thought it might be due to upgrading to 
> 2.14.6, but the last successful tasks show 
> "web2py.scheduler.giles-livetask", so maybe the problem came after that 
> upgrade.
>
> I thought maybe the scheduler database was corrupted, but I can view the 
> records via the admin appliance.
>
> Any suggestions as to what I should investigate next would be appreciated.
>
> - Scott
>

-- 
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: web2py 2.14.4 is OUT

2016-05-30 Thread Adam Filić
I isolated the problem in gluon/dal.py (line: 79) and with this change it 
works fine in postgresql.

 
if (field.notnull or field.unique) and not field_type in excluded_fields
:
requires.insert(0, validators.IS_NOT_EMPTY())
elif not field.notnull and not field.unique and requires:
requires[0] = validators.IS_EMPTY_OR(requires[0])
#requires[0] = validators.IS_EMPTY_OR(requires[0], null='' if field 
in ('string', 'text', 'password') else None)


Dana ponedjeljak, 2. svibnja 2016. u 19:59:26 UTC+2, korisnik Adam Filić 
napisao je:
>
> I have problem with empty field that should be inserted in db as NULL 
> (None), but 0 (zero) is inserted. Even when I declare form.vars.fo = None 
> (in validation routine), zero is inserted. Why?
>
> Dana utorak, 12. travnja 2016. u 23:29:26 UTC+2, korisnik Massimo Di 
> Pierro napisao je:
>>
>> web2py 2.14.4 is out.
>>
>> It fixes some a problem with CAS and some style issues with examples.
>> It also includes (and passes) a lot of new tests. 
>>
>> Thanks to Richard Vezina, Simone and Leonel for doing most of the work in 
>> this release.
>>
>> Massimo
>>
>

-- 
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: web2py 2.14.4 is OUT

2016-05-30 Thread Leonel Câmara
That doesn't make any sense Adam. You say your field is an integer, so

null='' if field in ('string', 'text', 'password') else None

is the same as

null=None

Which is the default value for null in IS_EMPTY_OR()

So your change shouldn't have many any difference whatsoever, note that by 
changing that you will also make forms put NULL values in string fields 
where you would probably want an empty string.

-- 
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] validate_and_update : I don't know what's going on ?

2016-05-30 Thread Pierre
Hi,

here it is : the cruel reality as is  :(

(1) the table:

db.define_table('uperson',
Field('auth_user','reference auth_user',unique=True,requires 
= IS_NOT_IN_DB(db,'uperson.auth_user')),
Field('country'),
Field('age','integer'))



(2) the actions:

>>> db.uperson.insert(auth_user=1,age=100,country='fr')
1L
>>> db.commit()
>>> r = db.uperson.validate_and_update(db.uperson.auth_user==1,age=101)
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 741, in 
validate_and_update
response, new_fields = self._validate_fields(fields, 'update')
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 727, in 
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 1625, in 
validate
(value, error) = validator(value)
  File "/opt/web2py/gluon/validators.py", line 696, in __call__
row = subset.select(table._id, field, limitby=(0, 1), orderby_on_limitby
=False).first()
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 2002, in 
select
return adapter.select(self.query,fields,attributes)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/sqlite.py", line 122, 
in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1273, 
in select
sql = self._select(query, fields, attributes)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1160, 
in _select
sql_w = ' WHERE ' + self.expand(query) if query else ''
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 945, in 
expand
rv = op(first, second, **optional_args)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 839, in 
EQ
self.expand(second, first.type))
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 955, in 
expand
rv = self.represent(expression, field_type)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1432, 
in represent
return str(long(obj))
ValueError: invalid literal for long() with base 10: 'None'

second attempt:

>>> db.uperson.validate_and_update(db.uperson.auth_user==1,auth_user=1,age=
102)
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: web2py 2.14.4 is OUT

2016-05-30 Thread Adam Filić
You are right. I have a problem with strings now, but empty field for 
integer is inserted as null at least. So I reverted this piece of code to 
version 2.13.4 like this and now is everything like it was, and shoud be.

"""
if field.unique:
requires.insert(0, validators.IS_NOT_IN_DB(db, field))
excluded_fields = ['string', 'upload', 'text', 'password', 'boolean']
if (field.notnull or field.unique) and not field_type in 
excluded_fields:
requires.insert(0, validators.IS_NOT_EMPTY())
elif not field.notnull and not field.unique and requires:
requires[0] = validators.IS_EMPTY_OR(requires[0], null='' if field 
in ('string', 'text', 'password') else None)
return requires
"""
if field.unique:
requires.append(validators.IS_NOT_IN_DB(db, field))
sff = ['in', 'do', 'da', 'ti', 'de', 'bo']
if field.notnull and not field_type[:2] in sff:
requires.append(validators.IS_NOT_EMPTY())
elif not field.notnull and field_type[:2] in sff and requires:
requires[0] = validators.IS_EMPTY_OR(requires[0])
return requires


Dana ponedjeljak, 30. svibnja 2016. u 15:33:20 UTC+2, korisnik Leonel 
Câmara napisao je:
>
> That doesn't make any sense Adam. You say your field is an integer, so
>
> null='' if field in ('string', 'text', 'password') else None
>
> is the same as
>
> null=None
>
> Which is the default value for null in IS_EMPTY_OR()
>
> So your change shouldn't have many any difference whatsoever, note that by 
> changing that you will also make forms put NULL values in string fields 
> where you would probably want an empty string.
>

-- 
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: validate_and_update : I don't know what's going on ?

2016-05-30 Thread Niphlod
npe!

validate_and_update is a method of a Query, not of a Table! (you may have 
scrambled it with validate_and_insert()...)

What you need to do is

db(db.uperson.auth_user==1).validate_and_update(age=101)



On Monday, May 30, 2016 at 3:34:48 PM UTC+2, Pierre wrote:
>
> Hi,
>
> here it is : the cruel reality as is  :(
>
> (1) the table:
>
> db.define_table('uperson',
> Field('auth_user','reference auth_user',unique=True,requires 
> = IS_NOT_IN_DB(db,'uperson.auth_user')),
> Field('country'),
> Field('age','integer'))
>
>
>
> (2) the actions:
>
> >>> db.uperson.insert(auth_user=1,age=100,country='fr')
> 1L
> >>> db.commit()
> >>> r = db.uperson.validate_and_update(db.uperson.auth_user==1,age=101)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 741, in 
> validate_and_update
> response, new_fields = self._validate_fields(fields, 'update')
>   File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 727, in 
> _validate_fields
> value, error = self[fieldname].validate(raw_value)
>   File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 1625, in 
> validate
> (value, error) = validator(value)
>   File "/opt/web2py/gluon/validators.py", line 696, in __call__
> row = subset.select(table._id, field, limitby=(0, 1), 
> orderby_on_limitby=False).first()
>   File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 2002, in 
> select
> return adapter.select(self.query,fields,attributes)
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/sqlite.py", line 122
> , in select
> return super(SQLiteAdapter, self).select(query, fields, attributes)
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1273, 
> in select
> sql = self._select(query, fields, attributes)
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1160, 
> in _select
> sql_w = ' WHERE ' + self.expand(query) if query else ''
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 945, 
> in expand
> rv = op(first, second, **optional_args)
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 839, 
> in EQ
> self.expand(second, first.type))
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 955, 
> in expand
> rv = self.represent(expression, field_type)
>   File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1432, 
> in represent
> return str(long(obj))
> ValueError: invalid literal for long() with base 10: 'None'
>
> second attempt:
>
> >>> db.uperson.validate_and_update(db.uperson.auth_user==1,auth_user=1,age
> =102)
>  None}
>
>
>
>

-- 
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: auth_user boolean extrafield odd behavior

2016-05-30 Thread Anthony
On Monday, May 30, 2016 at 6:56:30 AM UTC-4, Pierre wrote:
>
> Does *session.forget() *affects the way users 
> login/logout/signup..etc ?
>
> should  *session.forget() * be placed in every controller function or is 
> there a way to apply it globally ?
>

Not sure what you're getting at with regard to this issue. session.forget() 
just tells the session not to bother saving itself for the current request 
-- it does not erase or clear the session. What are you trying to do?

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: web2py 1.89.5

2016-05-30 Thread Richard Vézina
I will have it in my old VM pretty sure of that... As soon as I have time
to reboot, will have a look, sadly I can't have 2 VMs side by side :(

Richard



On Sun, May 29, 2016 at 7:39 PM, Leonel Câmara 
wrote:

> It should be on the code.google.com archive but I can't access it. An
> alternative for you may be to check which files were modified later than
> the others inside gluon, so you will at least know the files where he made
> the changes. You may then be able to use this slightly more recent version.
>
>
> Alternatively you can tell us what functionality the developer was trying
> to achieve when he modified gluon and we can just help you implement it
> again the right way.
>
> --
> 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: web2py 2.14.4 is OUT

2016-05-30 Thread Leonel Câmara
Humm this

requires[0] = validators.IS_EMPTY_OR(requires[0], null='' if field in 
('string', 'text', 'password') else None)

Should be

requires[0] = validators.IS_EMPTY_OR(requires[0], null='' if field_type in 
('string', 'text', 'password') else None)

-- 
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: validate_and_update : I don't know what's going on ?

2016-05-30 Thread Pierre
great !!! works
now I can validate all userseven the old ones:)


thanks Niphlod

-- 
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: Append fields within form, iteratively add fields inside form, List:string append, custom forms

2016-05-30 Thread Ron Chatterjee
If I do this inside the action "create_table" 

 db.Project.insert( added_term = ('English: 0 to 6 years', 'Math: 0 to 2 
years', 'History', 'over 5 years','science: never tought'))

It works. But how to save a list like this inside the controller every time 
someone hits "add" button? I am wondering if I have to save the variable in 
a temp table and read it. Because every time I hit the "create_table" 
action, all the variable gets reinitialize. 

Calling for Anthony with all his knowledge to help me with this! lol.

Happy memorial day everyone. 

Cheers,


On Friday, May 27, 2016 at 5:22:16 PM UTC-4, Ron Chatterjee wrote:
>
> Running into some issues and hoping community help out with thoughts. How 
> do I append to list:string and using form inside a form (custom form). 
>
> Question: How do I append skill_and_experience  as a list:string into the 
> field added_term as 'English': '1 year', 'Math':'2 years',...etc. 
>
> May be there is a better way to do this, but this is how I started out 
> with. 
>
>
> *Model.py:*
>
> db.define_table( 'Experience',Field('Experience_level'), format = 
> '%(Experience_level)s')
> db.define_table( 'teaching',Field('teach_string'), format = 
> '%(teach_string)s')
>
>
> db.define_table( 'add_list_item',
> Field('skill_list', db.teaching, label='Enter Your Skills 
> sets', comment = 'Enter skills'),
> Field('Experience_list', db.Experience, label='Enter Your 
> Experience',  comment = 'Enter years'))
> 
>
> db.define_table( 'Project', 
> Field("Title", "string", 
> requires=IS_NOT_EMPTY(),default=None),
> Field("added_term", "list:string", 
> requires=IS_NOT_EMPTY()),)
>
>
>
> *Controller:*
> def create_table():
> a_list = 'My skills and experience:'
> skill_and_experience = [];
>  
> form1 = SQLFORM(db.Project)
> form2 = SQLFORM(db.add_list_item, submit_button=' + Add',).process()
> form2.element('input[type=submit]').update(_class='btn btn-custom')
> 
> if form2.accepted:
> a = db(db.add_list_item.id == form2.vars.id).select().first()
> skills = db(db.teaching.id == a.skill_list).select().first()
> experience = db(db.Experience.id == 
> a.Experience_list).select().first()
> skill_and_experience = skills.teach_string+':' +''+ 
> experience.Experience_level
> added_term.append(skill_and_experience)
> response.flash = T("Added Experience")
> 
> if form1.accepted:
> response.flash = T("success!")
> 
> return dict(form1 = form1, form2 = form2, a_list = a_list)
>
>
> *View:*
>
> {{extend 'layout.html'}}
>
> 
>
> {{=form1.custom.begin}}
>
>
> 
> {{=form1.custom.widget.Title}}
>  
> 
> {{=form2.custom.begin}}
>
> {{=a_list}}
>
>
>
> 
> 
>   
>   
>  
>{{=form2.custom.widget.skill_list}}   
>
> {{=form2.custom.widget.Experience_list}}   
>   
>  
>{{=form2.custom.submit}}
>   
> 
> 
>  
> 
> 
> {{=form2.custom.end}}
>   
>  {{=form1.custom.submit}}
> 
> 
>  
>   
> 
> 
> {{=form1.custom.end}}
> 
>
> 
> .input-title{
> height: 100px;
> width: 400px;
> }
>
> #add_list_item_skill_list{
>  width: 200px;
> } 
> #add_list_item_Experience_list{
>  width: 200px;
> } 
>
>
> .btn-custom { text-align:right;color: blue;width:50px; 
> padding:20%;position: relative;top: -4px;left: 4px;height 20px;}   
> 
>
>
>
> The idea is to basically add experience and training using form2 and add 
> that to form1 and then process both. But I am having problem in appending 
> data into list:string like I would for project. 
>
> Project.id 
> 
> Project.Title2 
> 
> Project.added_term2 
> 
> 1  test1 
> test1
> 2  test2 test1, 
> test2, test3
> 3  test3 
> test23, 
> test32
>

-- 
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: web2py scheduler service dead - how to prevent it?

2016-05-30 Thread Dave S


On Monday, May 30, 2016 at 3:15:18 AM UTC-7, Mirek Zvolský wrote:
>
> Please help
>
> Debian Jessie, postgres, web2py-scheduler
>
> How can I prevent following crash - inactive scheduler?
>

Is the real problem that you're using pg8000?  I think there's been a lot 
of discussion of that driver recently, and the conclusion seems to be that 
it isn't reliable anymore.

 

> Or how can I be sure that the scheduler is running and restart it if 
> needed?
>
>
 
I see you've found an answer to that one, but I'd monitor to make sure it 
doesn't result in restarting the process when it shouldn't.

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