Re: [web2py] Re: how to override "select" method?

2017-03-10 Thread Jurgis Pralgauskis
Common filters only add to query,  but I need to change/replace
fields/expressions .

Now I think of monkeypatch'ing Set 'select' method (probably inside of
objects.py, because I guess Set is imported in different places).

Or maybe I don't need to touch pydal files, if I monkeypatch from db.py
some XAdapter in  DAL ADAPTERS. I hope it is single point of XAdapter
import..

Ps: class method monkeypatching seems quite straightforward
https://tryolabs.com/blog/2013/07/05/run-time-method-patching-python/

2017-03-10 04:28 popiet "Leonel Câmara"  rašė:

> Note that you can do what you want the first feature for, easily with
> common filters:
> http://www.web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer#Common-filters
>
> --
> 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/c_BMpcUu8Vg/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: Can't find controller?

2017-03-10 Thread LoveWeb2py
Slightly embarrassed... I had to reload my web app and it started to work. 
Not quite sure why yet, but thank you so much for all of your help!

On Friday, March 10, 2017 at 8:36:34 PM UTC-5, LoveWeb2py wrote:
>
> When I use just the IP address I get the pythonanywhere splash screen that 
> says Coming soon...
>
>
>
> On Friday, March 10, 2017 at 8:29:23 PM UTC-5, Dave S wrote:
>>
>>
>>
>> On Friday, March 10, 2017 at 5:26:15 PM UTC-8, LoveWeb2py wrote:
>>>
>>> Hi Anthony!
>>>
>>> I'm using www.mywebsite.com
>>>
>>> I can access it just fine when I use localhost:8000
>>>
>>
>> What happens when you use the explicit public IP?
>>
>> /dps
>>
>>  
>>
>>>
>>> On Friday, March 10, 2017 at 8:06:01 PM UTC-5, Anthony wrote:

 What URL are you using to access that controller?
>>>
>>>

-- 
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: Can't find controller?

2017-03-10 Thread LoveWeb2py
When I use just the IP address I get the pythonanywhere splash screen that 
says Coming soon...



On Friday, March 10, 2017 at 8:29:23 PM UTC-5, Dave S wrote:
>
>
>
> On Friday, March 10, 2017 at 5:26:15 PM UTC-8, LoveWeb2py wrote:
>>
>> Hi Anthony!
>>
>> I'm using www.mywebsite.com
>>
>> I can access it just fine when I use localhost:8000
>>
>
> What happens when you use the explicit public IP?
>
> /dps
>
>  
>
>>
>> On Friday, March 10, 2017 at 8:06:01 PM UTC-5, Anthony wrote:
>>>
>>> What URL are you using to access that controller?
>>
>>

-- 
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: Can't find controller?

2017-03-10 Thread Dave S


On Friday, March 10, 2017 at 5:26:15 PM UTC-8, LoveWeb2py wrote:
>
> Hi Anthony!
>
> I'm using www.mywebsite.com
>
> I can access it just fine when I use localhost:8000
>

What happens when you use the explicit public IP?

/dps

 

>
> On Friday, March 10, 2017 at 8:06:01 PM UTC-5, Anthony wrote:
>>
>> What URL are you using to access that controller?
>
>

-- 
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: Can't find controller?

2017-03-10 Thread LoveWeb2py
Hi Anthony!

I'm using www.mywebsite.com

I can access it just fine when I use localhost:8000

On Friday, March 10, 2017 at 8:06:01 PM UTC-5, Anthony wrote:
>
> What URL are you using to access that controller?

-- 
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] Can't find controller?

2017-03-10 Thread Anthony
What URL are you using to access that controller?

-- 
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] Can't find controller?

2017-03-10 Thread LoveWeb2py
So I have a controller. Let's call it controller_a, and when I try to link 
to it on my website

I get an error that says  invalid function (default/controller_a)

In my routes, all I have is 

routers = dict(

# base router
BASE=dict(
default_application='myappname',
),
)

I've read all the web2py book on parametric routes and I guess I'm missing 
something? Could someone please assist?

-- 
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 display field names and values within for loop?

2017-03-10 Thread Dave S


On Friday, March 10, 2017 at 1:02:21 PM UTC-8, Alex Glaros wrote:
>
> finally, this worked perfectly, thanks Dave
>
> {{for f in db.Organization:}}
> {{=f.label}} {{=specificOrganization[f]}} {{=f.comment}}
> {{pass}}
>

Glad it's working for you!  Thanks for the report back.

/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: how to display field names and values within for loop?

2017-03-10 Thread Alex Glaros
finally, this worked perfectly, thanks Dave

{{for f in db.Organization:}}
{{=f.label}} {{=specificOrganization[f]}} {{=f.comment}}
{{pass}}

-- 
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: Worker active but don't process anything

2017-03-10 Thread Dave S


On Friday, March 10, 2017 at 6:35:12 AM UTC-8, Gael Princivalle wrote:
>
> Hello.
>
> I can see my worker in putty with:
>  ps -u tasko w
> 16975 ?S 37:34 /usr/local/bin/python2.7 
> /home/tasko/webapps/w2p_2_14_16/web2py/web2py.py -K mtbconnection
>
> In the db:
> wf-31-170-123-65.webfaction.com#16975
> Status active.
> Last hartbeat 09/03/2017 21:32:18
> Worker stats {"status": "ACTIVE", "errors": 0, "workers": 1, "queue": 0, 
> "empty_runs": 7, "sleep": 3, "distribution": {"main": {"workers": [{"c": 0, 
> "name": "wf-31-170-123-65.webfaction.com#16975"}]}}, "total": 43141}
>
> How an active worker can be active, present as a process in putty and have 
> a last hartbeat from hours ago?
> Of course all the tasks don't run.
>
> I would like to have more reliability with these workers.
>
> Can someone give a hand?
>
> Thanks, regards.
>

Gael --

from your series of posts on the scheduler, it seems you have problems the 
rest of us don't.  I can't tell you if that's because you're doing 
something wrong, or you're pushing the boundaries of the scheduler.  I can 
give you basics of using the scheduler from the consuming code point of 
view, and Niphlod has the deep incites (and code ownership).
Or maybe you're expecting something outside of what the scheduler provides 
(wrong assumptions, misunderstanding features, or a use-case not 
anticipated).

Can you put together a minimal app that demonstrates how you use the 
scheduler, and that reproduces your problems?  Give us (Him) a link to 
that.  Also, document your platform environment (OS, version, Python 
version, DB version, etc).

Good luck!

/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: how to display field names and values within for loop?

2017-03-10 Thread Dave S


On Thursday, March 9, 2017 at 5:03:27 PM UTC-8, Alex Glaros wrote:
>
> Will your example provide both field name and field value?
>

 My example provides a standard ROWS object.   If you print results (or, in 
your case, supRows) on the console, the default to-string will show the 
labels as tablename.fieldname and then rows of values.  If you print just a 
single row (say [0]),  you see it is a dict-like object, with the 
fieldnames (but not tablename) as the keys and the values as the 
rows.values().


http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#select>
.

>
> am reveiving error
>
> CONTROLLER: supRows = db(db.Organization.id == 1).select()  {{#returns 
> locals}}
>
> VIEW:
> {{for record in supRows:}}
> {{=record.field}} 
> {{pass}}
>
> Error ticket for "ES3"Ticket ID
>
> 127.0.0.1.2017-03-09.16-54-06.fc1316c6-4ce4-4041-81fc-4f3ab11ce557
> 
>

Is there something at the bottom of the ticket which shows which of your 
lines is doing the _getattr_ call?

This exact code runs in my contoller:

print results[0]
print "-->" + results[0].client
for record in results:
   if record.id > 110891:
 print record.tdstatus


Obviously, you want to use your own fieldnames.


/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: Problem with SQLFORM.grid

2017-03-10 Thread Dave S


On Friday, March 10, 2017 at 9:11:03 AM UTC-8, Oasis Agano wrote:
>
> Did this issue get solved im facing it too
>

I suggest starting a new thread so your problem recieves the attention it 
needs.  But be sure and let us know

* your table definition
* how you are invoking the grid
* what error you are getting, or how the results differ from expected.

Good luck!

/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: how to display field names and values within for loop?

2017-03-10 Thread Alex Glaros
actually, this part works to display the label or comment

{{for f in db.Organization:}}
{{=f.label}} 
{{pass}}

So all I need is a little help displaying the value in a loop, something 
like this psudo code

specificOrganization = db.Organization(10) #just picked any record for 
convenience of illustration

{{for f in db.Organization:}}
{{=f.label}} {{=specificOrganization.f}} (hoping that somehow "f" 
is interpreted as the field name)
{{pass}}

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

2017-03-10 Thread Oasis Agano
Did this issue get solved im facing it too

On Monday, September 5, 2011 at 11:47:01 AM UTC+2, brushek wrote:
>
> Hello, 
>
> I have following table with custom type (database: postgres): 
> from gluon.sql import SQLCustomType 
> inet = SQLCustomType ( type='string', native='inet', encoder=lambda x: 
> repr(str(x))) 
> db.define_table("serwery", 
> Field("id_klienci",db.klienci), 
> Field("ip_serwera",type=inet,requires = IS_IPV4())) 
>
> When I try to use SQLFORM.grid, like this: 
>
> @auth.requires_login() 
> def dodajserwer(): 
> response.flash = T('Serwery') 
> form=SQLFORM.grid(db.serwery) 
>
> if form.accepts(request.vars, session): 
> response.flash='Serwer dodany' 
> elif form.errors: 
> response.flash = 'popraw' 
>
> return dict(form=form) 
>
> I get following error: 
> Traceback (most recent call last): 
>   File "/home/users/brushek/web2py/gluon/restricted.py", line 194, in 
> restricted 
> exec ccode in environment 
>   File "/home/users/brushek/web2py/applications/welcome/controllers/ 
> default.py", line 138, in  
>   File "/home/users/brushek/web2py/gluon/globals.py", line 145, in 
>  
> self._caller = lambda f: f() 
>   File "/home/users/brushek/web2py/gluon/tools.py", line 2510, in f 
> return action(*a, **b) 
>   File "/home/users/brushek/web2py/applications/welcome/controllers/ 
> default.py", line 60, in dodajserwer 
> form=SQLFORM.grid(db.serwery) 
>   File "/home/users/brushek/web2py/gluon/sqlhtml.py", line 1430, in 
> grid 
> T = current.T 
> TypeError: reduce() of empty sequence with no initial value 
>
> Where can be problem ? 
>
> regards 
> brushek

-- 
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: overriding fieldnames for SQLFORM

2017-03-10 Thread Anthony
I think you are limited to either monkey patching FormWidget in 
gluon.sqlhtml or using server-side DOM manipulation on the form object 
after it has been created.

Anthony

On Friday, March 10, 2017 at 6:39:07 AM UTC-5, Jurgis Pralgauskis wrote:
>
> Hi, 
>
> How could I have different name in generated SQLFORM than field.name?
>
> I'd like to have optional  field.formname  
>
> Use-cases:
>
>  - mult-table from with unique inputnames:
>  could be:   field.formname='tablename__fieldname'
>
>  - multi-record form (or multiform submision with ajax)
>some inputs serializers for ajax require notation for names like 
> "tablename[id].fieldname"
>   example https://github.com/maxatwork/form2js , 
> https://github.com/marioizquierdo/jquery.serializeJSON
>
>

-- 
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 display field names and values within for loop?

2017-03-10 Thread Alex Glaros
What is almost perfect is how w2p form displays a record (vertically with 
values)

1. Converts hyphens to spaces in field name, bolded
2. Displays label for field name, bolded
3. Displays comments for field name

the problem with using a form to display field values is:

a. not sure if record stays unnecessarily locked even if all fields have 
writable=False
b. the "submit" button displays

thanks

Alex

-- 
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] Worker active but don't process anything

2017-03-10 Thread Gael Princivalle
Hello.

I can see my worker in putty with:
 ps -u tasko w
16975 ?S 37:34 /usr/local/bin/python2.7 
/home/tasko/webapps/w2p_2_14_16/web2py/web2py.py -K mtbconnection

In the db:
wf-31-170-123-65.webfaction.com#16975
Status active.
Last hartbeat 09/03/2017 21:32:18
Worker stats {"status": "ACTIVE", "errors": 0, "workers": 1, "queue": 0, 
"empty_runs": 7, "sleep": 3, "distribution": {"main": {"workers": [{"c": 0, 
"name": "wf-31-170-123-65.webfaction.com#16975"}]}}, "total": 43141}

How an active worker can be active, present as a process in putty and have 
a last hartbeat from hours ago?
Of course all the tasks don't run.

I would like to have more reliability with these workers.

Can someone give a hand?

Thanks, regards.


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


[web2py] Re: how to override "select" method?

2017-03-10 Thread Leonel Câmara
Note that you can do what you want the first feature for, easily with 
common filters:
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Common-filters

-- 
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] overriding fieldnames for SQLFORM

2017-03-10 Thread Jurgis Pralgauskis
Hi, 

How could I have different name in generated SQLFORM than field.name?

I'd like to have optional  field.formname  

Use-cases:

 - mult-table from with unique inputnames:
 could be:   field.formname='tablename__fieldname'

 - multi-record form (or multiform submision with ajax)
   some inputs serializers for ajax require notation for names like 
"tablename[id].fieldname"
  example https://github.com/maxatwork/form2js 
, https://github.com/marioizquierdo/jquery.serializeJSON

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