[web2py] Re: Syntax Error "unknown app...."

2018-07-12 Thread Anthony

>
> Hi, thanks for your response. That seems like a good solution and I think 
> I'm going to go that way, but I still ask ...
>
 

Is there a possibility to change the code in rewrite.py so that it does not 
> throw the error, but does not include that domain in the list and make a 
> log warning?

 
I think I would lean against that approach, as we don't want silent 
failures (e.g., if someone mis-types the app name, it would not be obvious 
why the routes are not working as expected). I'm not sure it's worth it for 
what seems like a fairly rare use case (i.e., suddenly disappearing 
applications).

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: row.update_record() leaves row as None (only sometimes)

2018-07-12 Thread Leonel Câmara
What virtual method? What does update_tsv do? I can guess it's related to 
some csv representation but that's not a regular row method.

-- 
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] Interesting Project

2018-07-12 Thread greenpoise
Been jumping around different python frameworks and stumbled into Websauna 
 . Its built on top of Pyramid (Pylons). I share 
it here because I thought it borough a few things from web2py (or so it 
looks like) and perhaps it has a few features web2py can borough from. Dont 
get me wrong, I struggle programming period. I try but I struggle but I 
find that I struggle getting the bootstrap part of web2py when I compare it 
to the others. Anyway, just sharing.


cheers

-- 
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: row.update_record() leaves row as None (only sometimes)

2018-07-12 Thread Lisandro
Thank you Leonel for your time.

The code I showed is a bit simplified. 
I do some validation in deed (to requests.vars and request.args). Even 
though, if there is a problem with request.vars (for example, if 
request.vars.age is a string that is not a digit), the update_record would 
throw some error.

Also, if row is None, it would throw an error inmediately when calling 
update_record(), but notice the error is at the line where the virtual 
method is called, right after running .update_record() succesfully. That is 
what I don't understand, how can row be None if the previous line was 
executed succesfully?

First I thought "maybe the content was deleted by another user, or 
something like that", but that does not make sense, since the function is 
executed inside a database transaction, and there is no commit made between 
the two sentences.
It's also weird that it happens very few times (compared to the times that 
it runs succesfully).

Weird... :/
Anyway, I'll keep monitoring the issue and will try to reproduce it.


El jueves, 12 de julio de 2018, 14:05:35 (UTC-3), Leonel Câmara escribió:
>
> You are not validating request.vars.name nor request.vars.age. Is it 
> possible something weird is going on there? Also you're not checking if row 
> is None initially after you get it using request.args(0).  
>   
> Other than that, I don't see how this is even possible. Because a None Row 
> should cause a problem with update_record to begin with.
>

-- 
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: row.update_record() leaves row as None (only sometimes)

2018-07-12 Thread Leonel Câmara
You are not validating request.vars.name nor request.vars.age. Is it 
possible something weird is going on there? Also you're not checking if row 
is None initially after you get it using request.args(0).  
  
Other than that, I don't see how this is even possible. Because a None Row 
should cause a problem with update_record to begin with.

-- 
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] row.update_record() leaves row as None (only sometimes)

2018-07-12 Thread Lisandro
Hi there! I'm having this weird issue where, after doing a 
row.update_record(), the row object ends up being None.

The scenario is simple: it is a function that receives a post with some 
data, creates a dictionary with the data, updates de row, and finally calls 
a virtual method of the row.
This is the function, simplified:

def edit():
row = db.content[request.args(0)]
data = {
  'name': request.vars.name,
  'age': request.vars.age
}
row.update_record(**data)
row.update_tsv()
return 'done!'


This function is executed several times per day (about 1.000 times in an 
average day). 
But the function throws error about 3 or 4 times per day, and this is the 
error:

AttributeError: 'NoneType' object has no attribute 'update_tsv'



I can't reproduce it, because as I said, the function works ok and is 
executed several times per day. Still, I can't figure out what could be 
causing those isolated errors. 
If the whole function is executed inside a db transaction, what could be 
the reason why row object ends up being None after running update_record?


I was able to avoid those isolated errors with this fix:

row.update_record(**data)
row = db.content[request.args(0)]
row.update_tsv()

I could even prevent those errors whit this fix:

row.update_record(**data)
row = db.content[row.id]
row.update_tsv()

That's weird. But also I don't think that is the proper solution: it's 
inefficient, and I would have to add that extra select in every single line 
where my app calls .update_record(), obviously that's ugly and I've 
discarded the solution.

So, what could be causing the error?
Any help or comment will be much appreciated.
I'm using last stable version of web2py 
(2.16.1-stable+timestamp.2017.11.14.05.54.25)

Best regards,
Lisandro.

-- 
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: Syntax Error "unknown app...."

2018-07-12 Thread fiubarc


Hi, thanks for your response. That seems like a good solution and I think I'm 
going to go that way, but I still ask ...

Is there a possibility to change the code in rewrite.py so that it does not 
throw the error, but does not include that domain in the list and make a log 
warining?

domains = dict()
if routers.BASE.domains:
for (d, a) in routers.BASE.domains.iteritems():
(domain, app) = (d.strip(':'), a.strip('/'))
if ':' in domain:
(domain, port) = domain.split(':')
else:
port = None
if '/' in app:
(app, ctlr) = app.split('/', 1)
else:
ctlr = None
if ctlr and '/' in ctlr:
(ctlr, fcn) = ctlr.split('/')
else:
fcn = None
if app not in all_apps and app not in routers:
raise SyntaxError("unknown app '%s' in domains" % app)

domains[(domain, port)] = (app, ctlr, fcn)
routers.BASE.domains = domains



















El miércoles, 11 de julio de 2018, 10:55:58 (UTC-3), Anthony escribió:

> routes.py is just Python code, so you can write code that will dynamically 
> generate the "domains" dictionary based on folders found in the 
> /applications folder. However, whenever you make a change, you will still 
> need to reload routes.py (or restart the web server), as routes.py is only 
> executed once upon startup.
>
> Anthony
>
> On Wednesday, July 11, 2018 at 9:47:30 AM UTC-4, fiubarc wrote:
>>
>> Hello, i need help with this behavior
>>
>> Steps to reproduce:
>>
>> 1) routes.py
>>
>> domains = {   "app1.com" : "app1", "app2.com" : "app2"}
>>
>> 2) uninstall app1
>>
>> 3) the app2 can not be accessed, not even the admin interface. 
>>
>> Web2py Log:
>>
>> [Tue Jul 10 11:16:58 2018] [error]  mod_wsgi (pid=2115): Target WSGI script 
>> '/home/www-data/web2py/wsgihandler.py' cannot be loaded as Python module.
>> [Tue Jul 10 11:16:58 2018] [error]  mod_wsgi (pid=2115): Exception occurred 
>> processing WSGI script '/home/www-data/web2py/wsgihandler.py'.
>> [Tue Jul 10 11:16:58 2018] [error]  Traceback (most recent call last):
>> [Tue Jul 10 11:16:58 2018] [error]   File 
>> "/home/www-data/web2py/wsgihandler.py", line 33, in 
>> [Tue Jul 10 11:16:58 2018] [error] import gluon.main
>> [Tue Jul 10 11:16:58 2018] [error]   File 
>> "/home/www-data/web2py/gluon/main.py", line 128, in 
>> [Tue Jul 10 11:16:58 2018] [error]  load_routes()
>> [Tue Jul 10 11:16:58 2018] [error]File 
>> "/home/www-data/web2py/gluon/rewrite.py", line 381, in load
>> [Tue Jul 10 11:16:58 2018] [error]  load_routers(all_apps)
>> [Tue Jul 10 11:16:58 2018] [error]File 
>> "/home/www-data/web2py/gluon/rewrite.py", line 530, in load_routers
>> [Tue Jul 10 11:16:58 2018] [error]  raise SyntaxError("unknown app '%s' 
>> in domains" % app)
>> [Tue Jul 10 11:16:58 2018] [error]  SyntaxError: unknown app 'app1' in 
>> domains
>>
>>
>>
>> 4) remove app1 from domains in routes.py
>>
>> 5) problem resolved
>>
>> The question is whether there is any way to catch the error so that the 
>> other installed applications can continue running without editing routes.py
>>
>> Thanks!!!
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to 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]

2018-07-12 Thread Martin Weissenboeck
Sorry, wrong address.

Martin Weissenboeck  schrieb am Do., 12. Juli 2018,
15:25:

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