[web2py] Re: 502 Bad Gateway - no tmp/web2py.socket file

2016-11-25 Thread Jim Russell


>
>  $ ps aux | grep "uwsgi"
> richard   1044  0.0  0.1   4276  1824 pts/0S+   10:54   0:00 grep 
> --color=auto uwsgi
>

That is the grep process, not uwsgi.  So uwsgi is not running.

Check in /var/log/nginx/ for any messages about uwsgi 

-- 
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] returning values from custom form

2016-11-25 Thread Jim Russell
Hi.

I have created a form which takes a list of hostnames and shows the 
hostnames with checkboxes next to it. The idea is to be able to uncheck any 
hostnames and pass the still checked hostnames to another function which 
will then act on that list of hostnames. The problem is that it just 
returns an empty list.

I am new to web2py, this is my first project, so if my thinking is wrong, 
I'm ok with rewriting this part from scratch.

Here is the code:

def verify():
hostnames=request.vars.hostnames.split()
num_hosts=len(hostnames)
form=FORM(TABLE(TR("Hostnames")))
for hn in hostnames:
row=XML(''+ hn)
form[0].append(row)
form[0].append(XML('Submit!'))
   
if form.accepts(request,session):
redirect(URL('execute',vars=dict(hostnames=form.vars.hostnames)))
return dict(hostnames=hostnames,form=form)

Thanks in advance for your help.

Jim

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


[web2py] Re: returning values from custom form

2016-11-26 Thread Jim Russell
Marlysson,

Thanks for the reply.  I did figure out how to do it the web2py way. It was 
not particularly intuitive, but now that I understand it, it makes sense 
and is pretty powerful.

form=SQLFORM.factory(
Field('hostnames',"list:string", 
default=hostnames,widget=SQLFORM.widgets.checkboxes.widget,requires=[IS_IN_SET(hostnames,multiple=True),IS_NOT_EMPTY()]))
form.add_button('Cancel',URL('index'))

Then the view just has {{==form}}

It works exactly the way I hoped it would.  Perhaps an example of this 
could be put in the examples page.


On Saturday, November 26, 2016 at 5:21:59 PM UTC-6, Marlysson Silva wrote:
>
> I don't used the form.accepted but you could use to validate de submit the 
> form and handle.. but basically it's 
>
> Em sábado, 26 de novembro de 2016 20:20:58 UTC-3, Marlysson Silva escreveu:
>>
>> I created a other version for your code, I created a form html ( the hard 
>> way ) and in the controller get the post vars sent by form:
>>
>> The controller:
>> def form():
>> host_names = ["google","facebook","amazon","localhost"]
>>
>> marcados = request.post_vars["host"]
>>
>> return dict(host_names=host_names,marcados=marcados)
>>
>> The view:
>>
>> 
>> {{for host in host_names:}}
>>  {{=host}} 
>> 
>> {{pass}}
>> 
>> 
>>
>> {{=marcados}}
>>
>>
>> Em sábado, 26 de novembro de 2016 02:03:33 UTC-3, Jim Russell escreveu:
>>>
>>> Hi.
>>>
>>> I have created a form which takes a list of hostnames and shows the 
>>> hostnames with checkboxes next to it. The idea is to be able to uncheck any 
>>> hostnames and pass the still checked hostnames to another function which 
>>> will then act on that list of hostnames. The problem is that it just 
>>> returns an empty list.
>>>
>>> I am new to web2py, this is my first project, so if my thinking is 
>>> wrong, I'm ok with rewriting this part from scratch.
>>>
>>> Here is the code:
>>>
>>> def verify():
>>> hostnames=request.vars.hostnames.split()
>>> num_hosts=len(hostnames)
>>> form=FORM(TABLE(TR("Hostnames")))
>>> for hn in hostnames:
>>> row=XML('>> checked>'+ hn)
>>> form[0].append(row)
>>> form[0].append(XML('>> id="submit">Submit!'))
>>>
>>> if form.accepts(request,session):
>>> redirect(URL('execute',vars=dict(hostnames=form.vars.hostnames)))
>>> return dict(hostnames=hostnames,form=form)
>>>
>>> Thanks in advance for your help.
>>>
>>> Jim
>>>
>>

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


[web2py] Re: check boxes with is_in_set

2016-12-08 Thread Jim Russell
Rob,

I used this code to get a list with checkboxes.

form=SQLFORM.factory(
Field('hostnames',"list:string", 
default=hostnames,widget=SQLFORM.widgets.checkboxes.widget,requires=[IS_IN_SET(hostnames,multiple=True),IS_NOT_EMPTY()]))

hostnames is a list containing strings.

-- 
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: check boxes with is_in_set

2016-12-12 Thread Jim Russell
In your example, list_chart is not a list of strings, it is a list of 
tuples.

In my code, hostnames is just a list of hostnames.  e.g. 
('hostname1.example.com','hostname2.example.com')

I assume that you are trying to make the checkboxes default to true. For 
me, they defaulted to being checked.

On Monday, December 12, 2016 at 3:50:58 PM UTC-6, 黄祥 wrote:
>
> trying the tricks but got error when the checkbox is empty (1 or all 
> checkbox is empty, when all checkbox is on its work) :
> *e.g.*
> def test_form():
> redirect_url = 'test'
>
> list_chart = [(True, 'line'), 
>  (True, 'pie'), 
>  (True, 'bar') ]
>
> form = SQLFORM.factory(
> Field('chart', 'list:string', 
>  default = list_chart,
>  widget = SQLFORM.widgets.checkboxes.widget, 
>  requires = [IS_IN_SET(list_chart, multiple = True) ] ) )
> if form.process().accepted:
> chart = form.vars.chart
> line = form.vars.line[0]
> pie = form.vars.pie[1]
> bar = form.vars.bar[2]
>
> response.new_window = URL(redirect_url, args = [chart] )
> #response.new_window = URL(redirect_url, args = [line, pie, bar] )
> elif form.errors:
> response.flash = T('Form has errors')
> return dict(form = form)
>
> *Traceback error:*
> line = form.vars.chart[0]
> IndexError: list index out of range
>
> any idea how to face it using web2py way?
>
> 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] SQLFORM.grid question

2017-04-24 Thread Jim Russell
Hi all.

I'm having an issue with an SQLFORM.gird query. I have a table where one of 
the columns references another table. Here are the table definitions:

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='reference osrwlpooltype'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

db.define_table('osrwlpooltype',
Field('id', type='id'),
Field('wtype', type='string', length=32, unique=True))

So osrwhitelistpool field wltype references osrwlpooltype field wtype.

When I run a simple query, just requesting the whole table I get an error Query 
Not Supported: invalid literal for long() with base 10: 'ALL'

I'm not sure why it thinks that field should be a long.

Here are the table definitions directly from the DB:

osrtest=# \d osrwlpooltype
Table "osrtest.osrwlpooltype"
 Column | Type  |Modifiers
+---+--
 id | integer   | not null default 
nextval('osrwlpooltypeseqpk'::regclass)
 wtype  | character varying(32) | not null
Indexes:
"osrwlpooltype_pkey" PRIMARY KEY, btree (id)
"osrwlpooltype_wtype_key" UNIQUE CONSTRAINT, btree (wtype)
Referenced by:
TABLE "osrwhitelistpool" CONSTRAINT "osrwhitelistpool_wltype_fkey" 
FOREIGN KEY (wltype) REFERENCES osrwlpooltype(wtype)

osrtest=# \d osrwhitelistpool
Table "osrtest.osrwhitelistpool"
  Column  |Type |  Modifiers
--+-+-
 id   | integer | not null default 
nextval('osrwhitelistpoolseqpk'::regclass)
 pool | character varying(255)  | not null
 wltype   | character varying   |
 comments | character varying(255)  |
 ctime| timestamp without time zone | default now()
Indexes:
"osrwhitelistpool_pkey" PRIMARY KEY, btree (id)
"osrwhitelistpool_pool_key" UNIQUE CONSTRAINT, btree (pool)
Foreign-key constraints:
"osrwhitelistpool_wltype_fkey" FOREIGN KEY (wltype) REFERENCES 
osrwlpooltype(wtype)



I changed the table definition in db.py to 

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='string'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

and it worked to display it. But then when I edit a record it is just a 
free form text field instead of a dropdown with the wtype field from 
osrwlpooltype.

Any ideas what I'm doing wrong?

Thanks,
Jim

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


[web2py] Re: SQLFORM.grid question

2017-04-25 Thread Jim Russell
I worked around this by setting the wltype field to string and adding 
a requires=IS_IN_SET. This makes the editing page have a dropdown with the 
set members instead of a free-form text field.

So it's working, but it's not the most elegant 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQLFORM.grid question

2017-04-26 Thread Jim Russell


On Tuesday, April 25, 2017 at 9:19:59 AM UTC-5, Anthony wrote:
>
> On Tuesday, April 25, 2017 at 3:20:23 AM UTC-4, Jim Russell wrote:
>>
>> I worked around this by setting the wltype field to string and adding 
>> a requires=IS_IN_SET. This makes the editing page have a dropdown with the 
>> set members instead of a free-form text field.
>>
>
> This is not a great idea if wltype is intended to be a reference to the 
> osrwlpooltype table, as you lose the benefits of the foreign key constraint 
> and the mechanisms the DAL provides for managing that.
>
> Anthony
>

Indeed, and I knew it was ugly.

I simplified my table and instead of having it reference another table, I 
just set wltype to a string and then set  the constraints for the field in 
db.py 

db.osrwhitelistpool.wltype.requires=IS_IN_SET(('ALL', 'REBOOT', 'PING))

Thanks very much for your help 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.