[web2py] Re: Strange behaviour of URL.verify() / @requires_signature() with big vars

2013-10-03 Thread D.
Thank you for the provided solutions - I'll try them out asap. When storing 
the list as a session-variable is it protected from user-manipulation as 
well?

Best regards!

Am Donnerstag, 3. Oktober 2013 22:57:44 UTC+2 schrieb Massimo Di Pierro:
>
> You can do but
>
> def one():
> files = []
> for i in range(10):
> files.append(i)
> session.files = files
> redirect(URL("two"))
>
> def two():
> files = session.files
> logger.info(True)
>
> OR
>
> from simplejson import loads, dumps
>
> def one():
> files = []
> for i in range(10):
> files.append(i)
> redirect(URL("two", vars={"files":dumps(files)}, user_signature=True)
>
> @auth.requires_signature()
> def two():
> files = loads(form.vars.files)
> logger.info(True)
>
> I think the problem is putting a list in vars.
>
> On Thursday, 3 October 2013 10:21:19 UTC-5, D. wrote:
>>
>> It does not really matter what's in the list:
>>
>> Even a simple list like this leads to a 403-error: [0, 1, 2, 3, 4, 5, 6, 
>> 7, 8, 9, 10]
>>
>> How would I store and retrieve a long list in a session?
>>
>> Thank you so much for your help!
>>
>> Am Donnerstag, 3. Oktober 2013 15:22:04 UTC+2 schrieb Massimo Di Pierro:
>>>
>>> What's into files? How long are the strings? There are limits to how 
>>> long the query string can be. I thing the files should be saved in a 
>>> session and retrieved by the target page
>>>
>>> On Thursday, 3 October 2013 01:52:47 UTC-5, D. wrote:

 I'm still struggeling with this problem - does anyone have an idea?

 I narrowed it a bit further down:

 If the list I'm passing as vars contains 10 items or less 
 @auth.requires_signature() validates correctly and access to the function 
 is granted. However, if the list has 11 or more items I get "Insufficient 
 priviledges".

 Best 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/groups/opt_out.


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Mirko
Done here : https://code.google.com/p/web2py/issues/detail?id=1703

A possible workaround could be to add the following lines somewhere where 
it is always called (cmd_options.test is None for normal use):

if request.global_settings.cmd_options.test:
auth.login_bare('userlogin','userpassword')



On Thursday, October 3, 2013 10:55:01 PM UTC+2, Massimo Di Pierro wrote:
>
> please open a ticket about this. we need a new request.is_shell option or 
> something similar to detect this state.
>
> On Thursday, 3 October 2013 09:52:07 UTC-5, Mirko wrote:
>>
>> Eventually I got something working (may be crappy) to put on top of 
>> controller file:
>>
>> *if request.global_settings.cmd_options.test.startswith('%s/%s' % 
>> (request.application,request.controller)):
>> auth.login_bare('user_for_test','his/her password')
>> *
>> Mirko
>>
>>
>> On Thursday, October 3, 2013 3:58:31 PM UTC+2, Mirko wrote:
>>>
>>> Hi Massimo, thank you very much for helping!
>>> However it looks like request.function contains '_TEST' only when 
>>> doctest is run from the web IDE, and contains function name when run from 
>>> command line..
>>>
>>> On Thursday, October 3, 2013 3:25:24 PM UTC+2, Massimo Di Pierro wrote:

 You need to add some logic that says:

 if request.function = '_TEST':
   auth.login_bare('user_for_test','his/her password')

 On Thursday, 3 October 2013 07:02:09 UTC-5, Mirko wrote:
>
> Hi all,
>
> I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 
> when function c is decorated with *@auth.requires_login()* 
> It works fine without that decoration and I don't know how to 
> authenticate when running doctests from command line, any suggestions 
> ?
>
> Many thanks!
> Mirko
>
>
> On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:
>>
>> I cannot say on top of my head. I would look into the 
>> build_environment when/where that is set. 
>> Thanks for looking into this. It is an important problem that needs 
>> to 
>> be solved. 
>>
>> Massimo 
>>
>> On Oct 16, 10:03 am, rboissat  wrote: 
>> > One issue though, with the code given above for instantiating a 
>> dummy 
>> > env, 
>> > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
>> > 
>> > It seems that in the line: 
>> > 
>> > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
>> > 
>> >  request.folder is NoneType, therefore making os.path.join fail. 
>> > 
>> > This is rather odd, cause in the tested controller, a: 
>> > 
>> > print request.folder 
>> > 
>> > gives me the the right path to my application. 
>> > 
>> > Any idea?
>
>

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
https://code.google.com/p/web2py/issues/detail?id=1702

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson


On Friday, 4 October 2013 13:50:42 UTC+10, Tim Richardson wrote:
>
> It doesn't seem to me to be a sort order problem. The problem seems to me 
> to be different: the criteria for evaluating which models to execute can 
> change while in that loop. If the criteria changes, then all candidate 
> models (all models in other words) should be reevaluated. The loop index 
> should reset to one. I don't know enough python yet.
>
>>

I don't think it's such an easy fix because it a question of dependency 
resolution. 

My work around will be to put common models in a ZZZ folder 

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
It doesn't seem to me to be a sort order problem. The problem seems to me 
to be different: the criteria for evaluating which models to execute can 
change while in that loop. If the criteria changes, then all candidate 
models (all models in other words) should be reevaluated. The loop index 
should reset to one. I don't know enough python yet.


On Friday, 4 October 2013 13:39:19 UTC+10, Anthony wrote:
>
> Oh, it looks like the issue regarding sorting of model 
> folderswas 
> never fixed.
>
> Massimo, can we change to sort=True in compileapp.py lines 
> 517and
>  
> 521
> ?
>
> Anthony
>
> On Thursday, October 3, 2013 11:02:21 PM UTC-4, Tim Richardson wrote:
>>
>> I put it at the top of the C1 model and I know it is being executed...  
>> I'll step through more and see what's happening 
>> On 04/10/2013 12:55 pm, "Anthony"  wrote:
>>
>>>
>>> Right now I have at the top of C1
 response.models_to_run['.*']  (just for debugging) but I still get a 
 ticket saying that 

>>>
>>> Are you saying you put that line at the top of the C1 controller? If so, 
>>> that's too late -- the controller isn't run until after the models have 
>>> been executed. You have to set/change response.models_to_run in one or more 
>>> model files. By default:
>>>
>>> response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.
>>> controller,
>>>   r'^%s/%s/\w+\.py$' % (request.controller,request
>>> .function)]
>>>
>>> which sets up the standard conditional models.
>>>
>>> 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 a topic in the 
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/web2py/OiZ6vwaNuEU/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
 Yes, I am correct. That's a bit subtle. By making a model folder ZZZ and
putting a copy of the requested model in there, it works. Not ideal.
Possibly could be a bug, maybe. Or perhaps needs to be better documented.


On Fri, Oct 4, 2013 at 1:37 PM, Tim Richardson wrote:

> I have response.models_to_run = ['.*']
> at the top of the C1/C1_db model.
> When I put a breakpoint, it completes the rest of the C1_db model, and
> arrives at compileapp.py at a loop
> for model in models:
>
> this is the loop where the regex is evaluated.
> But it doesn't enter the loop.
> I'm guessing that perhaps I have reentered that loop on the last iteration
> of models.
>
> Anyway, it never evaluates my new regex.
>
> I have been misleading with my example names: I say C1 but alphabetically
> the model with my response.models_to_run is actually later in the
> alphabet.It is the final model. The model I want to execute has alphabetic
> precedence.
> Perhaps this is the problem: the use of response.models_to_run does not
> regenerate the list of models, it just changes the test to execute a model
> from a candidate list, but if a candidate has already been evaluated it
> doesn't get looked at again.
>
>
>
> On Fri, Oct 4, 2013 at 1:09 PM, Anthony  wrote:
>
>> An alternative would be something like this:
>>
>> what_models_to_be_executed = {"C1": ["tab1.py", "tab2.py", "tab3.py"],
>>> "C2": "tab2.py"}
>>> response.models_to_run = what_models_to_be_executed[**request.controller]
>>>
>>>
>>
>> Note, it must be a list (above, in the case of C2, it would just be a
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/OiZ6vwaNuEU/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/groups/opt_out.
>>
>
>
>
> --
> Tim Richardson
>



-- 
Tim Richardson

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Anthony
Oh, it looks like the issue regarding sorting of model 
folderswas 
never fixed.

Massimo, can we change to sort=True in compileapp.py lines 
517and 
521 
?

Anthony

On Thursday, October 3, 2013 11:02:21 PM UTC-4, Tim Richardson wrote:
>
> I put it at the top of the C1 model and I know it is being executed...  
> I'll step through more and see what's happening 
> On 04/10/2013 12:55 pm, "Anthony" > wrote:
>
>>
>> Right now I have at the top of C1
>>> response.models_to_run['.*']  (just for debugging) but I still get a 
>>> ticket saying that 
>>>
>>
>> Are you saying you put that line at the top of the C1 controller? If so, 
>> that's too late -- the controller isn't run until after the models have 
>> been executed. You have to set/change response.models_to_run in one or more 
>> model files. By default:
>>
>> response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.
>> controller,
>>   r'^%s/%s/\w+\.py$' % (request.controller,request
>> .function)]
>>
>> which sets up the standard conditional models.
>>
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/OiZ6vwaNuEU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
I have response.models_to_run = ['.*']
at the top of the C1/C1_db model.
When I put a breakpoint, it completes the rest of the C1_db model, and
arrives at compileapp.py at a loop
for model in models:

this is the loop where the regex is evaluated.
But it doesn't enter the loop.
I'm guessing that perhaps I have reentered that loop on the last iteration
of models.

Anyway, it never evaluates my new regex.

I have been misleading with my example names: I say C1 but alphabetically
the model with my response.models_to_run is actually later in the
alphabet.It is the final model. The model I want to execute has alphabetic
precedence.
Perhaps this is the problem: the use of response.models_to_run does not
regenerate the list of models, it just changes the test to execute a model
from a candidate list, but if a candidate has already been evaluated it
doesn't get looked at again.



On Fri, Oct 4, 2013 at 1:09 PM, Anthony  wrote:

> An alternative would be something like this:
>
> what_models_to_be_executed = {"C1": ["tab1.py", "tab2.py", "tab3.py"],
>> "C2": "tab2.py"}
>> response.models_to_run = what_models_to_be_executed[**request.controller]
>>
>>
>
> Note, it must be a list (above, in the case of C2, it would just be a
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/OiZ6vwaNuEU/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/groups/opt_out.
>



-- 
Tim Richardson

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Anthony
On Thursday, October 3, 2013 11:09:23 PM UTC-4, Anthony wrote:

> An alternative would be something like this: 
>
> what_models_to_be_executed = {"C1": ["tab1.py", "tab2.py", "tab3.py"], 
>> "C2": "tab2.py"} 
>> response.models_to_run = what_models_to_be_executed[request.controller] 
>>
>
> Note, it must be a list (above, in the case of C2, it would just be a 
> string).
>

Never mind -- it does not have to be a list -- can just be a 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/groups/opt_out.


Re: [web2py] Re: import a model ?

2013-10-03 Thread Anthony

>
> An alternative would be something like this: 

what_models_to_be_executed = {"C1": ["tab1.py", "tab2.py", "tab3.py"], 
> "C2": "tab2.py"} 
> response.models_to_run = what_models_to_be_executed[request.controller] 
>

Note, it must be a list (above, in the case of C2, it would just be a 
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/groups/opt_out.


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
I put it at the top of the C1 model and I know it is being executed...
I'll step through more and see what's happening
On 04/10/2013 12:55 pm, "Anthony"  wrote:

>
> Right now I have at the top of C1
>> response.models_to_run['.*']  (just for debugging) but I still get a
>> ticket saying that
>>
>
> Are you saying you put that line at the top of the C1 controller? If so,
> that's too late -- the controller isn't run until after the models have
> been executed. You have to set/change response.models_to_run in one or more
> model files. By default:
>
> response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.
> controller,
>   r'^%s/%s/\w+\.py$' % (request.controller,request
> .function)]
>
> which sets up the standard conditional models.
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/OiZ6vwaNuEU/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/groups/opt_out.
>

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Vinicius Assef
An alternative would be something like this:
what_models_to_be_executed = {"C1": ["tab1.py", "tab2.py", "tab3.py"],
"C2": "tab2.py"}
response.models_to_run = what_models_to_be_executed[request.controller]


On Thu, Oct 3, 2013 at 11:55 PM, Anthony  wrote:
>
>> Right now I have at the top of C1
>> response.models_to_run['.*']  (just for debugging) but I still get a
>> ticket saying that
>
>
> Are you saying you put that line at the top of the C1 controller? If so,
> that's too late -- the controller isn't run until after the models have been
> executed. You have to set/change response.models_to_run in one or more model
> files. By default:
>
> response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' %
> request.controller,
>   r'^%s/%s/\w+\.py$' % (request.controller,
> request.function)]
>
> which sets up the standard conditional models.
>
> 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/groups/opt_out.

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Anthony


> Right now I have at the top of C1
> response.models_to_run['.*']  (just for debugging) but I still get a 
> ticket saying that 
>

Are you saying you put that line at the top of the C1 controller? If so, 
that's too late -- the controller isn't run until after the models have 
been executed. You have to set/change response.models_to_run in one or more 
model files. By default:

response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller
,
  r'^%s/%s/\w+\.py$' % (request.controller, request.
function)]

which sets up the standard conditional models.

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Vinicius Assef
reponse.models_to_run must be updated on models, before controller execution.

On Thu, Oct 3, 2013 at 11:41 PM, Tim Richardson  wrote:
> Thanks. I'm trying that but not getting it to work for me, maybe I have
> another problem.
>
> The problem is a function in controller C1 which refers to a part of the
> model for C2. Both controllers have models in models/C1 and models/C2
>
> Right now I have at the top of C1
> response.models_to_run['.*']  (just for debugging) but I still get a ticket
> saying that
>
>  'DAL' object has no attribute
> 'patient_submission'
>
> where patient_submission is the table defined in the model
> models/C2/C2_db.py
>
> I know that response.models_to_run is being changed thanks to the debugger.
>
>
> On Fri, Oct 4, 2013 at 12:24 PM, Anthony  wrote:
>>
>> You can customize response.models_to_run.
>>
>> Anthony
>>
>>
>> On Thursday, October 3, 2013 9:46:37 PM UTC-4, Tim Richardson wrote:
>>>
>>> If I have a conditional model, that is a model in a folder named after
>>> its controller, how can another controller source that model?
>>>
>> --
>> 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/OiZ6vwaNuEU/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/groups/opt_out.
>
>
>
>
> --
> Tim Richardson
>
> --
> 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/groups/opt_out.

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


Re: [web2py] Re: import a model ?

2013-10-03 Thread Tim Richardson
Thanks. I'm trying that but not getting it to work for me, maybe I have
another problem.

The problem is a function in controller C1 which refers to a part of the
model for C2. Both controllers have models in models/C1 and models/C2

Right now I have at the top of C1
response.models_to_run['.*']  (just for debugging) but I still get a ticket
saying that

 'DAL' object has no attribute
'patient_submission'

where patient_submission is the table defined in the model
models/C2/C2_db.py

I know that response.models_to_run is being changed thanks to the debugger.


On Fri, Oct 4, 2013 at 12:24 PM, Anthony  wrote:

> You can customize 
> response.models_to_run
> .
>
> Anthony
>
>
> On Thursday, October 3, 2013 9:46:37 PM UTC-4, Tim Richardson wrote:
>>
>> If I have a conditional model, that is a model in a folder named after
>> its controller, how can another controller source that model?
>>
>>  --
> 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/OiZ6vwaNuEU/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/groups/opt_out.
>



-- 
Tim Richardson

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


[web2py] Re: import a model ?

2013-10-03 Thread Anthony
You can customize 
response.models_to_run
.

Anthony

On Thursday, October 3, 2013 9:46:37 PM UTC-4, Tim Richardson wrote:
>
> If I have a conditional model, that is a model in a folder named after its 
> controller, how can another controller source that model?
>
>

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


[web2py] import a model ?

2013-10-03 Thread Tim Richardson
If I have a conditional model, that is a model in a folder named after its 
controller, how can another controller source that model?

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


[web2py] Re: DAL: read tagged data with handle?

2013-10-03 Thread Anthony


> def writeTagTest():
> a = db.tag.insert(name='red')
> b = db.tag.insert(name='green')
> c = db.tag.insert(name='blue')
> db.product.insert(name='Test Toy Car',tags=[a, b, c]) 
> return dict(message="Insert ok", tag=db.tag,product=db.product)
>
>
> def readTagTest():
> b=db(db.tag.name=='green').select().first()   # 
> gluon.dal.Rows?
> products = db(db.product.tags.contains(b)).select()  # here 
> products is empty? Why??
>

>From the above code, it appears db.product.tags is a list:reference field, 
so it stores the id's of the referenced tag records. In readTagTest, "b" is 
a Row object, so if you want the id of that row, you should use b.id:

products = db(db.product.tags.contains(b.id)).select()

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


[web2py] Representing Fields in SQLFORM.grid

2013-10-03 Thread pjryan126
I am trying to apply a standard representation to the fields in a 
SQLFORM.grid object using their field names with the following code:

for f in db.things.fields:
db.things[f].represent = lambda value, row: DIV(value if value else 
'-',_class=f, _id=str(row.id)+ '.' + f)

but all of the fields wind up with the exact same representation:



**6


**Years--but in other pigments 
compounded so it tells us at on


**2008-08-02 . . .

Incidentally, the "modified_by" field is the last field in the table. Does 
anyone see what I am doing wrong here and how I can correct it?

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


[web2py] Representing Fields in SQLFORM.grid

2013-10-03 Thread pjryan126
I am trying to apply a standard representation to the fields in a 
SQLFORM.grid object using their field names with the following code:

for f in db.timesheet.fields:
db.things[f].represent = lambda value, row: DIV(value if value else 
'-',_class=f, _id=str(row.id)+ '.' + f)

but all of the fields wind up with the exact same representation:



**6


**Years--but in other pigments 
compounded so it tells us at on


**2008-08-02 . . .

Incidentally, the "modified_by" field is the last field in the table. Does 
anyone see what I am doing wrong here and how I can correct it?

Thanks,
Patrick

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


[web2py] application for seminar management?

2013-10-03 Thread Stefaan Himpe

Hello list,

I'm looking for suggestions for something to manage in-house seminars.

Does anything like this exist already? (I can hardly imagine it 
doesn't...) Can Pynuke or Conf2py be used for something like this?


If nothing exists, I might try to make something simple myself.

Some requirements as far as I see them now:

- list upcoming seminars (basic info like title, speaker, date, start 
time) sorted by date


- user friendly way to create/edit seminars

- for each listed seminar link to some extra explanation (abstract, 
perhaps a picture, attached slides, ... This could be on a wiki page)


- allow people to create a profile and to register/unregister for 
upcoming seminars


- for each listed seminar also show a counter for how many people 
registered so far


- have a way to list people that registered for a given seminar

- allow people to suggest new (future) seminar topics (and have a page 
that lists suggested, not yet planned seminars, allow to assign a 
date/speaker/... to turn it into a planned seminar)


- send registered people a reminder mail some time before the seminar 
takes place



Currently, I have *no need* for things like
(things marked with a star are "nice-to-have"):
* search through seminar title/abstract/...
* good looks
- traveling directions
- online payment system
- maps


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


[web2py] Re: onselect ajax...

2013-10-03 Thread Avi A
It alerts the $(this).val() though.

On Thursday, October 3, 2013 8:18:15 PM UTC+3, Avi A wrote:
>
>
> Hi,
> I'm trying to use the ajax function on a list , with no success so far.
>
> def echo():
> return request.vars.value
>
>  name="f_item_category">
> 
> {{for c in category:}}
>  >{{=c.f_category_name}}
> {{pass}}
> 
>
> 
>
> 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/groups/opt_out.


[web2py] Google charts plugin added

2013-10-03 Thread Tim Richardson
I added a google charts plugin 
http://www.web2pyslices.com/slice/show/1721/google-charts-plugin

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


[web2py] Re: onselect ajax...

2013-10-03 Thread Avi A

Thanks. It partially works, it displays  "None" instead of the id.
On Thursday, October 3, 2013 10:10:02 PM UTC+3, Niphlod wrote:
>
> I'm not sure that the onselect attribute of an option tag does what you 
> need (triggering something when a certain option is selected).
> Don't use inline javascript when there are far more readable and concise 
> alternatives
>
> $('#t_items_f_item_category').change(function() {
>   ajax('echo', [$(this).val()], 'target')
> })
>
> On Thursday, October 3, 2013 7:18:15 PM UTC+2, Avi A wrote:
>>
>>
>> Hi,
>> I'm trying to use the ajax function on a list , with no success so far.
>>
>> def echo():
>> return request.vars.value
>>
>> > name="f_item_category">
>> 
>> {{for c in category:}}
>> > >{{=c.f_category_name}}
>> {{pass}}
>> 
>>
>> 
>>
>> 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/groups/opt_out.


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Anthony
On Thursday, October 3, 2013 4:55:01 PM UTC-4, Massimo Di Pierro wrote:

> please open a ticket about this. we need a new request.is_shell option or 
> something similar to detect this state.
>

request.global_settings.cmd_options can be used to distinguish other 
command line executions as well, such as cron, scheduler tasks, etc. Maybe 
we should add shortcuts to identify all of the different ways a request can 
come into the app.

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


Re: [web2py] network troubles with builtin webserver (Windows)

2013-10-03 Thread Alex
thanks a lot, Ricardo!

you're right about HTTP pipeline. Opera is the only browser with 
(activated) HTTP pipeline. If I deactivate it the site is loaded very fast. 
The 10 seconds delay is exactly the timeout setting for individual 
requests. So far I could not get the webserver to deliver all files without 
timeout with activated HTTP pipeline (min/max number of threads doesn't 
make any difference). Is it possible that rocket can't handle this 
correctly? I've another app running on Apache and there I don't have this 
problem with Opera.

you're also right with the low timeout values. I've increased the socket 
timeout (default is only 5 seconds) and so far I don't have any weird 
troubles accessing the page over VPN connection.

Alex

Am Donnerstag, 3. Oktober 2013 22:14:07 UTC+2 schrieb Ricardo Pedroso:
>
> On Thu, Oct 3, 2013 at 4:43 PM, Alex >wrote:
>
>> I'm using the builtin webserver with web2py on Windows.
>>
>> When I refresh the page (to reload all files) of a small app in Opera it 
>> takes very long (>10 sec) until the page is completely loaded. When I check 
>> the network log (with Dragonfly) I see that usually the first 10-20 files 
>> (css, js, images, etc.) are loaded very fast. The next couple of files are 
>> delayed for about 10 seconds (request is scheduled, header and body is 
>> written immediately, then the sequence is terminated and retried after 
>> about 10 seconds). After 10 seconds all remaining files are loaded quite 
>> fast.
>>
>> Has anyone an idea what blocks loading these files? I guess the builtin 
>> webserver should be able to handle a couple of simultaneous requests.
>>
>> Strangely this problem does not happen with FF or IE. Maybe it is because 
>> the timing of sending requests is different?
>>
>>  
> I guess this can be due to HTTP Pipeline. Not sure, but I read somewhere 
> that opera use http pipeline.
>
> Try increase/decrease the number of threads in builtin server, by default 
> it's 10 threads to serve requests.
>
> You can start by match the number of threads to the number of machine 
> cores.
> Even if you have only 2 cores, meaning having 2 threads in rocket to 
> handle requests, it can be more efficient
> because the kernel will have less context switch's to make, but you will 
> have more serialized requests/responses.
> Just test your use case. You have to play around... Also try different 
> timeout values, see below.
>
>
> I have a similar issue when I access the page over a VPN with IE. Some 
>> scripts get corrupted and IE shows a syntax error (e.g. in the jquery js 
>> file). This problem only occurs with IE and not with the other browsers. I 
>> think it is related to the other issue, since it only happens when the 
>> whole page is refreshed and all files are requested. Still, I'm very 
>> confused...
>>
>
> This can be due to low timeout values in rocket.
> You can change those timeouts through command line, just look in:
> python web2py -h
>
>
> Ricardo
>

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


[web2py] Re: Strange behaviour of URL.verify() / @requires_signature() with big vars

2013-10-03 Thread Massimo Di Pierro
You can do but

def one():
files = []
for i in range(10):
files.append(i)
session.files = files
redirect(URL("two"))

def two():
files = session.files
logger.info(True)

OR

from simplejson import loads, dumps

def one():
files = []
for i in range(10):
files.append(i)
redirect(URL("two", vars={"files":dumps(files)}, user_signature=True)

@auth.requires_signature()
def two():
files = loads(form.vars.files)
logger.info(True)

I think the problem is putting a list in vars.

On Thursday, 3 October 2013 10:21:19 UTC-5, D. wrote:
>
> It does not really matter what's in the list:
>
> Even a simple list like this leads to a 403-error: [0, 1, 2, 3, 4, 5, 6, 
> 7, 8, 9, 10]
>
> How would I store and retrieve a long list in a session?
>
> Thank you so much for your help!
>
> Am Donnerstag, 3. Oktober 2013 15:22:04 UTC+2 schrieb Massimo Di Pierro:
>>
>> What's into files? How long are the strings? There are limits to how long 
>> the query string can be. I thing the files should be saved in a session and 
>> retrieved by the target page
>>
>> On Thursday, 3 October 2013 01:52:47 UTC-5, D. wrote:
>>>
>>> I'm still struggeling with this problem - does anyone have an idea?
>>>
>>> I narrowed it a bit further down:
>>>
>>> If the list I'm passing as vars contains 10 items or less 
>>> @auth.requires_signature() validates correctly and access to the function 
>>> is granted. However, if the list has 11 or more items I get "Insufficient 
>>> priviledges".
>>>
>>> Best 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/groups/opt_out.


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Massimo Di Pierro
please open a ticket about this. we need a new request.is_shell option or 
something similar to detect this state.

On Thursday, 3 October 2013 09:52:07 UTC-5, Mirko wrote:
>
> Eventually I got something working (may be crappy) to put on top of 
> controller file:
>
> *if request.global_settings.cmd_options.test.startswith('%s/%s' % 
> (request.application,request.controller)):
> auth.login_bare('user_for_test','his/her password')
> *
> Mirko
>
>
> On Thursday, October 3, 2013 3:58:31 PM UTC+2, Mirko wrote:
>>
>> Hi Massimo, thank you very much for helping!
>> However it looks like request.function contains '_TEST' only when doctest 
>> is run from the web IDE, and contains function name when run from command 
>> line..
>>
>> On Thursday, October 3, 2013 3:25:24 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> You need to add some logic that says:
>>>
>>> if request.function = '_TEST':
>>>   auth.login_bare('user_for_test','his/her password')
>>>
>>> On Thursday, 3 October 2013 07:02:09 UTC-5, Mirko wrote:

 Hi all,

 I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 when 
 function c is decorated with *@auth.requires_login()* 
 It works fine without that decoration and I don't know how to 
 authenticate when running doctests from command line, any suggestions ?

 Many thanks!
 Mirko


 On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:
>
> I cannot say on top of my head. I would look into the 
> build_environment when/where that is set. 
> Thanks for looking into this. It is an important problem that needs to 
> be solved. 
>
> Massimo 
>
> On Oct 16, 10:03 am, rboissat  wrote: 
> > One issue though, with the code given above for instantiating a 
> dummy 
> > env, 
> > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
> > 
> > It seems that in the line: 
> > 
> > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
> > 
> >  request.folder is NoneType, therefore making os.path.join fail. 
> > 
> > This is rather odd, cause in the tested controller, a: 
> > 
> > print request.folder 
> > 
> > gives me the the right path to my application. 
> > 
> > Any idea?



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


Re: [web2py] network troubles with builtin webserver (Windows)

2013-10-03 Thread Ricardo Pedroso
On Thu, Oct 3, 2013 at 4:43 PM, Alex  wrote:

> I'm using the builtin webserver with web2py on Windows.
>
> When I refresh the page (to reload all files) of a small app in Opera it
> takes very long (>10 sec) until the page is completely loaded. When I check
> the network log (with Dragonfly) I see that usually the first 10-20 files
> (css, js, images, etc.) are loaded very fast. The next couple of files are
> delayed for about 10 seconds (request is scheduled, header and body is
> written immediately, then the sequence is terminated and retried after
> about 10 seconds). After 10 seconds all remaining files are loaded quite
> fast.
>
> Has anyone an idea what blocks loading these files? I guess the builtin
> webserver should be able to handle a couple of simultaneous requests.
>
> Strangely this problem does not happen with FF or IE. Maybe it is because
> the timing of sending requests is different?
>
>
I guess this can be due to HTTP Pipeline. Not sure, but I read somewhere
that opera use http pipeline.

Try increase/decrease the number of threads in builtin server, by default
it's 10 threads to serve requests.

You can start by match the number of threads to the number of machine cores.
Even if you have only 2 cores, meaning having 2 threads in rocket to handle
requests, it can be more efficient
because the kernel will have less context switch's to make, but you will
have more serialized requests/responses.
Just test your use case. You have to play around... Also try different
timeout values, see below.


I have a similar issue when I access the page over a VPN with IE. Some
> scripts get corrupted and IE shows a syntax error (e.g. in the jquery js
> file). This problem only occurs with IE and not with the other browsers. I
> think it is related to the other issue, since it only happens when the
> whole page is refreshed and all files are requested. Still, I'm very
> confused...
>

This can be due to low timeout values in rocket.
You can change those timeouts through command line, just look in:
python web2py -h


Ricardo

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


[web2py] Re: passing a alphanumerig id to a SQLFORM.grid getting error

2013-10-03 Thread Ari Lion BR Sp
Hi Niphold, thanks for the answer..!
So do you have any way to work with that?
Surely, at my database I dont have any blank spaces at primary keys.

I was thinkin on integrating some ERPs thru web2py and those ERPs use 
Alphanumeric (surely, without blank spaces) as primary keys.
I thik it would be importanto to handle with it.

I got the below at the ticket:

 if record and linkto:
db = linkto.split('/')[-1]
for rfld in table._referenced_by:
if keyed:
query = urllib.quote('%s.%s==%s' % (
db, rfld, record[rfld.type[10:].split('.')[1]]))

else:
query = urllib.quote(
'%s.%s==%s' % (db, rfld, record[self.id_field_name]))
lname = olname = '%s.%s' % (rfld.tablename, rfld.name)


As I see web2py try to splt the argumets... something like this...


Thanks!

Ari - Brazil




Em quinta-feira, 3 de outubro de 2013 12h04min56s UTC-3, Ari Lion BR Sp 
escreveu:
>
> Hi to All,
>
> I need to work with legacy table, even knowing it's not so recomended.
>
> One of my tables has a String for primarykey.
>
> I have built a SQLFORM.grid 
>
> When editing *only numbers* record code (key) - all works fine.
>
> [image: Imagem inline 1]
>
>
> all works fine
>
> [image: Imagem inline 2]
>
> 
> 
> --
>
> *but*, when choosing a key which  *contains a letter*
>  (alphanumeric charachter ), -in bellow case, the 'Y'
>
> [image: Imagem inline 3]
>
> I *get the following error:*:
>
> [image: Imagem inline 4]
> even ticket I do not get.
>
> --
> Even when I type the URL , it returns to me  *Object not found*:
>
> [image: Imagem inline 6]
> the *Model for * *Artigos* table:
>
> Artigos = db_prodmal.define_table('ARTIGOS',
>Field('COD_ARTIGO','string'),
>Field('NOME', 'string'),
>Field('COMPOSICAO', 'string'),
>.
>primarykey=['COD_ARTIGO'],
>format='%(NOME)s',
>migrate=False) 
>
> the  *Controller **:*
>
> *def *artigo_editar():
> # Armazena o ID do artigo
> id_artigo = request.args(0)
> buttons = [TAG.button('Salvar',_type="submit",_class = "btn-success")]
> 
> # Form edição do colaborador
> *if *id_artigo == '0':
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,
>   buttons =buttons,
>   submit_button='Incluir',
>   field_id='COD_ARTIGO',
>   _id='form_colaborador_editar')
> *else*:
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,id_artigo,
>   buttons =buttons,
>   submit_button='Alterar',
>   _id='form_colaborador_editar',
>   field_id='COD_ARTIGO')
>
> *...more code here...*
> *
> *
> *
> *
> ***return *dict(form_artigo_editar=form_artigo_editar, [...other 
> returns])
>
>
>
>
> 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/groups/opt_out.


[web2py] DAL: read tagged data with handle?

2013-10-03 Thread Py Dev
Hi,

here is some code, that should write and read some tags, it is a slightly 
different version as the code in the book (5th Edition) on page 316:

The write test works, but I do not get the handle to read it back. What is 
wrong with this code, marked in read?

Thanks for your help!
Cheers! 
pd


def writeTagTest():
a = db.tag.insert(name='red')
b = db.tag.insert(name='green')
c = db.tag.insert(name='blue')
db.product.insert(name='Test Toy Car',tags=[a, b, c]) 
return dict(message="Insert ok", tag=db.tag,product=db.product)


def readTagTest():
b=db(db.tag.name=='green').select().first()   # 
gluon.dal.Rows?
products = db(db.product.tags.contains(b)).select()  # here 
products is empty? Why??

for item in products:
print item.name, item.tags
return dict(b=b,product=db.product,products=products)

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


[web2py] Re: Change SQLFORM.grid Submit button label

2013-10-03 Thread Paolo Caruccio

if grid.create_form or grid.update_form:
o = grid.element(_type='submit', _value='%s' % T('Submit'))
o['_value'] = T("Compare Selected")


Il giorno giovedì 3 ottobre 2013 19:38:23 UTC+2, P T ha scritto:
>
> Thanks Massimo, but that didn't work. I resorted to using the following 
> jQuery in the view:
>
> 
>  $('input[type="submit"][value="Submit"]').attr('value', 'Compare 
> Selected');;
> 
>
> May be there is an equivalent expression in Web2Py.
>
> Thanks,
> PT
>
>
>
> On Thursday, October 3, 2013 8:19:57 AM UTC-5, Massimo Di Pierro wrote:
>>
>> if grid.create_form or grid.update_form: grid.element(_type='submit')[
>> '_value'] = T("something")
>>
>> On Wednesday, 2 October 2013 23:15:07 UTC-5, P T wrote:
>>>
>>> Hello All,
>>>
>>>
>>> I want change the label of Submit button in the SQLFORm.grid. I found 
>>> two solutions in the forum and both seems to be not working. 
>>>
>>> The first solution given here Changing SQLFORM.grid submit label from 
>>> python without 
>>> javascript?
>>>   
>>> is 
>>>
>>> grid.element(_type='submit')['_value'] = T("something")
>>>
>>> But, the above code is changing the label of the "Search" button. 
>>>
>>> The second solution given here SQLFORM.RID 
>>> Selectable
>>>  is
>>>
>>> grid.element('.web2py_table input[type=submit]')['_value'] = T(
>>> 'something')
>>>
>>> This indeed changes the label of the Submit button but break the 
>>> functionality of other buttons such as Edit, View and Delete and issues a 
>>> ticket. 
>>>
>>> What I am doing wrong? By the way I am using the latest version 
>>> 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the 
>>> controller function:
>>>
>>> def listscenarios():
>>>query = (db.scenario.created_by == auth.user.id)  
>>>grid = SQLFORM.grid(query, 
>>>links = [lambda row: A(I('',_class="icon-picture")+' Results',_class
>>> ='btn', _href=URL("default","calculate", args=[row.id], user_signature=
>>> True, hash_vars=True))],
>>>selectable=lambda ids: compare(ids), csv=False, 
>>>fields=[db.scenario.id, db.scenario.name, db.scenario.description, 
>>>db.scenario.avg_mass, db.scenario.cell_type, db.scenario.
>>> tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle],
>>>oncreate=scenario_create)
>>>
>>>
>>> ##   grid.element('.web2py_table input[type=submit]')['_value'] = 
>>> T('Something') ## this causes problems with View and Edit buttons
>>> ##   grid.element(_type='submit')['_value'] = T("something") ## this 
>>> chnages the label of the Search button?
>>>grid.element('.web2py_counter', replace=None) 
>>>
>>>
>>>return dict(grid=grid)
>>>
>>>
>>>
>>> Thanks,
>>> PT
>>>
>>

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


[web2py] Re: Legacy Table - Keyed Table / String primary Key

2013-10-03 Thread Ari Lion BR Sp
In Time:
I'm working with MySQL.

Em quinta-feira, 3 de outubro de 2013 14h40min37s UTC-3, Ari Lion BR Sp 
escreveu:
>
> Hi, 
>
> I have a Legacy table with string primary key.
> seems to bel web2py is not able to handle only the records containing 
> alphanumeric charachters . For those containing only numbers I get no 
> problem.
>
> For the alphanumeric (for exmple '222Y9800') I get back the following 
> Tichket.
>
>  list index out of range
>
> do anyone have a solution for that?
>
> Regards,
> Ari
>

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


[web2py] Re: passing a alphanumerig id to a SQLFORM.grid getting error

2013-10-03 Thread Niphlod
AFAIK the grid doesn't support non-integer primary keys. All the ids are 
passed around as arguments to have clean urls and dealing with those 
arguments as strings is a big issue (imagine /default/index/edit/tablename/*abc 
defg ... *it's not even a valid argument ^_^)

On Thursday, October 3, 2013 5:04:56 PM UTC+2, Ari Lion BR Sp wrote:
>
> Hi to All,
>
> I need to work with legacy table, even knowing it's not so recomended.
>
> One of my tables has a String for primarykey.
>
> I have built a SQLFORM.grid 
>
> When editing *only numbers* record code (key) - all works fine.
>
> [image: Imagem inline 1]
>
>
> all works fine
>
> [image: Imagem inline 2]
>
> 
> 
> --
>
> *but*, when choosing a key which  *contains a letter*
>  (alphanumeric charachter ), -in bellow case, the 'Y'
>
> [image: Imagem inline 3]
>
> I *get the following error:*:
>
> [image: Imagem inline 4]
> even ticket I do not get.
>
> --
> Even when I type the URL , it returns to me  *Object not found*:
>
> [image: Imagem inline 6]
> the *Model for * *Artigos* table:
>
> Artigos = db_prodmal.define_table('ARTIGOS',
>Field('COD_ARTIGO','string'),
>Field('NOME', 'string'),
>Field('COMPOSICAO', 'string'),
>.
>primarykey=['COD_ARTIGO'],
>format='%(NOME)s',
>migrate=False) 
>
> the  *Controller **:*
>
> *def *artigo_editar():
> # Armazena o ID do artigo
> id_artigo = request.args(0)
> buttons = [TAG.button('Salvar',_type="submit",_class = "btn-success")]
> 
> # Form edição do colaborador
> *if *id_artigo == '0':
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,
>   buttons =buttons,
>   submit_button='Incluir',
>   field_id='COD_ARTIGO',
>   _id='form_colaborador_editar')
> *else*:
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,id_artigo,
>   buttons =buttons,
>   submit_button='Alterar',
>   _id='form_colaborador_editar',
>   field_id='COD_ARTIGO')
>
> *...more code here...*
> *
> *
> *
> *
> ***return *dict(form_artigo_editar=form_artigo_editar, [...other 
> returns])
>
>
>
>
> 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/groups/opt_out.


[web2py] Re: Legacy Table - Keyed Table / String primary Key

2013-10-03 Thread Ari Lion BR Sp


I built a *grid *for listing records for this table (in this case, Products 
table) and all work well, it means, *on clickin on button* of *SQLFORM.grid*  
for edditing , as below
[image: Imagem inline 1]


all works well

[image: Imagem inline 2]


including master / details that we set (ie, the primary key works to filter 
the details too).
--

*However*, when you choose any item whose code contains a *letter *(character 
alphanumeric), - in the case below, the '*Y*'

[image: Imagem inline 3]

returns me the following *error*:

[image: Imagem inline 4]
the strange thing is that does not return Ticket, but the above.


--
And even when I test by typing the URL in hand, it returns me as *Object 
not found*:


[image: Imagem inline 6]
Model for Product Table is as follows:

Artigos = db_prodmal.define_table('ARTIGOS',
   Field('COD_ARTIGO','string'), #I've also tryed taking out ,'string')
   Field('NOME', 'string'),
   Field('COMPOSICAO', 'string'),
   .
   primarykey=['COD_ARTIGO'],
   format='%(NOME)s',
   migrate=False) 


 *Controller **:*

def artigo_editar():
# Armazena o ID do artigo
id_artigo = request.args(0)
buttons = [TAG.button('Salvar',_type="submit",_class = "btn-success")]

# Form edição do colaborador
if id_artigo == '0':
form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,
  buttons =buttons,
  submit_button='Incluir',
  field_id='COD_ARTIGO',
  _id='form_colaborador_editar')
else:
form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,id_artigo,
  buttons =buttons,
  submit_button='Alterar',
  _id='form_colaborador_editar',
  field_id='COD_ARTIGO')


...mais código aqui...




return dict(form_artigo_editar=form_artigo_editar, [...outros returns
])



--


But, also when I tryed to edit table directly at appadmin/select/db = Database 
Administration (appadmin)
I've gotten the error:

 list index out of range

Thanks for the help.
Ari - Brazil

Em quinta-feira, 3 de outubro de 2013 14h40min37s UTC-3, Ari Lion BR Sp 
escreveu:
>
> Hi, 
>
> I have a Legacy table with string primary key.
> seems to bel web2py is not able to handle only the records containing 
> alphanumeric charachters . For those containing only numbers I get no 
> problem.
>
> For the alphanumeric (for exmple '222Y9800') I get back the following 
> Tichket.
>
>  list index out of range
>
> do anyone have a solution for that?
>
> Regards,
> Ari
>

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


[web2py] Re: Absolute URL from field in grid

2013-10-03 Thread Niphlod
uhm: seems that you didn't quite get how lambda works.

lambda row : something(row)

equals to 

def something(row):
  return 'a'

lambda is used just to "inline" a small snippet of code.

In your case, you need to generate the link from the field pdf_path, but 
you need to take the pdf_path from the row you're passing to the 
function.

def generate_link(row):
  return A('whatever', _href=URL('default', 'download', 
args=row.pdf_path))

that, "transformed" to the "lambda format" is

lambda row : A('whatever', _href=URL('default', 'download', 
args=row.pdf_path))

As for having the URL absolute instead of relative, use the host parameter 
of the A helper.

On Thursday, October 3, 2013 5:32:20 PM UTC+2, Gael Princivalle wrote:
>
> Hi.
>
> In a table I have that:
> db.define_table('products',
> Field('code', unique=True),
> Field('description'),
> Field('brand'),
> Field('pdf_path'))
>
> I want to have a sqlform.grid that gone have all links to pdf_path field. 
> These are absolute links like "http://www.example.com/mycatalogue.pdf";
>
> Here is my controller:
> def products_listing():
> links = [lambda row: A('pdf', _href=db.products.pdf_path)]
> grid = SQLFORM.grid(db.products, orderby=db.products.code, 
> links=links,links_in_grid=True)
> return dict(grid=grid)
>
> I have two problems, path is relative because it begin at my website 
> http:///my_application/default
> And the products.pdf_path field is not considered like a filed, but like a 
> string.
>
> The result is:  http:///my_application/default/products.pdf_path
>
> I've tried also to play with the URL helper but without result.
>
> An idea ?
>
> 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/groups/opt_out.


[web2py] Re: network troubles with builtin webserver (Windows)

2013-10-03 Thread Niphlod
I use rocket on windows and don't incur in any noticeable problem. Of 
course its slower on Windows than Linux (as expected) but never had an 
issue of a corrupt file ... what error do you get exactly ?

On Thursday, October 3, 2013 5:43:27 PM UTC+2, Alex wrote:
>
> I'm using the builtin webserver with web2py on Windows.
>
> When I refresh the page (to reload all files) of a small app in Opera it 
> takes very long (>10 sec) until the page is completely loaded. When I check 
> the network log (with Dragonfly) I see that usually the first 10-20 files 
> (css, js, images, etc.) are loaded very fast. The next couple of files are 
> delayed for about 10 seconds (request is scheduled, header and body is 
> written immediately, then the sequence is terminated and retried after 
> about 10 seconds). After 10 seconds all remaining files are loaded quite 
> fast.
>
> Has anyone an idea what blocks loading these files? I guess the builtin 
> webserver should be able to handle a couple of simultaneous requests.
>
> Strangely this problem does not happen with FF or IE. Maybe it is because 
> the timing of sending requests is different?
>
> I have a similar issue when I access the page over a VPN with IE. Some 
> scripts get corrupted and IE shows a syntax error (e.g. in the jquery js 
> file). This problem only occurs with IE and not with the other browsers. I 
> think it is related to the other issue, since it only happens when the 
> whole page is refreshed and all files are requested. Still, I'm very 
> confused...
>
> 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/groups/opt_out.


[web2py] Re: PATCH(?) DAL with MSSQL and windows authentication

2013-10-03 Thread Niphlod
whoops, linked the slightly wrong page :)

http://www.connectionstrings.com/sql-server-native-client-11-0-odbc-driver/

On Thursday, October 3, 2013 6:39:19 PM UTC+2, Josh Myers wrote:
>
> Thank you, everyone.  The problem of how to sign in with windows 
> authorization was solved for me when I used the following connection string 
> in SQL Server 2005:
>  
> db = DAL('mssql://DRIVER={SQL 
> Server};SERVER:ServerName;DATABASE=DatabaseName;TRUSTED_CONNECTION=YES;')
>  
> For some reason it needed that DRIVER statement.  That was also the same 
> connection string that worked using pyodbc explicitly, so that makes sense 
> I guess.
>  
>
> On Thursday, October 3, 2013 4:53:55 AM UTC-4, Niphlod wrote:
>
>>
>>
>> Il giorno giovedì 3 ottobre 2013 01:20:40 UTC+2, Josh Myers ha scritto:
>>>
>>> I'm not a database expert.  
>>>
>>> Aren't both of those connection strings equivalent in the DAL?  Why are 
>>> you saying they are different?  I will try it in the other format, the 
>>> non-@ format.
>>>
>>> ehm.
>>
>> mssql://Provider=SQLNCLI11;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
>> vs
>> mssql://myUsername:myPassword@myServerAddress/myDataBase
>>
>> to me are different.
>> That being said, there are a few options (especially with integrated 
>> auth) that aren't "included" in the usual notation, so the only way is to 
>> use the former notation.
>>
>>

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


[web2py] Re: onselect ajax...

2013-10-03 Thread Niphlod
I'm not sure that the onselect attribute of an option tag does what you 
need (triggering something when a certain option is selected).
Don't use inline javascript when there are far more readable and concise 
alternatives

$('#t_items_f_item_category').change(function() {
  ajax('echo', [$(this).val()], 'target')
})

On Thursday, October 3, 2013 7:18:15 PM UTC+2, Avi A wrote:
>
>
> Hi,
> I'm trying to use the ajax function on a list , with no success so far.
>
> def echo():
> return request.vars.value
>
>  name="f_item_category">
> 
> {{for c in category:}}
>  >{{=c.f_category_name}}
> {{pass}}
> 
>
> 
>
> 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/groups/opt_out.


[web2py] Re: Legacy Table - Keyed Table / String primary Key

2013-10-03 Thread Niphlod
this happens when you try to do what exactly ?

On Thursday, October 3, 2013 7:40:37 PM UTC+2, Ari Lion BR Sp wrote:
>
> Hi, 
>
> I have a Legacy table with string primary key.
> seems to bel web2py is not able to handle only the records containing 
> alphanumeric charachters . For those containing only numbers I get no 
> problem.
>
> For the alphanumeric (for exmple '222Y9800') I get back the following 
> Tichket.
>
>  list index out of range
>
> do anyone have a solution for that?
>
> Regards,
> Ari
>

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


[web2py] passing a alphanumerig id to a SQLFORM.grid getting error

2013-10-03 Thread Ari Lion BR Sp
Hi to All,

I need to work with legacy table, even knowing it's not so recomended.

One of my tables has a String for primarykey.

I have built a SQLFORM.grid 

When editing *only numbers* record code (key) - all works fine.

[image: Imagem inline 1]


all works fine

[image: Imagem inline 2]



--

*but*, when choosing a key which  *contains a letter*
 (alphanumeric charachter ), -in bellow case, the 'Y'

[image: Imagem inline 3]

I *get the following error:*:

[image: Imagem inline 4]
even ticket I do not get.
--
Even when I type the URL , it returns to me  *Object not found*:

[image: Imagem inline 6]
the *Model for * *Artigos* table:

Artigos = db_prodmal.define_table('ARTIGOS',
   Field('COD_ARTIGO','string'),
   Field('NOME', 'string'),
   Field('COMPOSICAO', 'string'),
   .
   primarykey=['COD_ARTIGO'],
   format='%(NOME)s',
   migrate=False) 

the  *Controller **:*

*def *artigo_editar():
# Armazena o ID do artigo
id_artigo = request.args(0)
buttons = [TAG.button('Salvar',_type="submit",_class = "btn-success")]

# Form edição do colaborador
*if *id_artigo == '0':
form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,
  buttons =buttons,
  submit_button='Incluir',
  field_id='COD_ARTIGO',
  _id='form_colaborador_editar')
*else*:
form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,id_artigo,
  buttons =buttons,
  submit_button='Alterar',
  _id='form_colaborador_editar',
  field_id='COD_ARTIGO')

*...more code here...*
*
*
*
*
***return *dict(form_artigo_editar=form_artigo_editar, [...other 
returns])




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


[web2py] Legacy Table - Keyed Table / String primary Key

2013-10-03 Thread Ari Lion BR Sp
Hi, 

I have a Legacy table with string primary key.
seems to bel web2py is not able to handle only the records containing 
alphanumeric charachters . For those containing only numbers I get no 
problem.

For the alphanumeric (for exmple '222Y9800') I get back the following 
Tichket.

 list index out of range

do anyone have a solution for that?

Regards,
Ari

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


[web2py] Re: Web2py admin crashes

2013-10-03 Thread Dave S
On Thursday, October 3, 2013 10:51:37 AM UTC-7, Dave S scribbled:
>
>
> On Thursday, October 3, 2013 8:28:52 AM UTC-7, Joe Magaro wrote:
>>
>> Hi, 
>>
>> All was working well, until today I went and clicked "administrative 
>> interface" for my site, and it issues a ticket.
>>
>> Internal errorTicket issued: 
>> admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1
>>
>> When I click to view the ticket, it crashes and issues another ticket. I 
>> checked the http logs, but cant seem to find anything of importance. Can 
>> some one give me the next step to help solve this issue?
>>
>
> Can you read the tickets from a local shell?
>
> less Web2pyDir/applications/admin/errors/*
>
>
>
> I just did the upgrade, and it looks like my services are running ok, but 
> I get a "cannot import name Config", which I think means I missed copying 
> one of the files from the welcome app or something.  Private server running 
> web2py+rocket.
>
>
>
Also, be sure and 'rm' (or 'mv') all your old tickets ... the old ones 
aren't readable by the ticket functions in the app's admin controller.

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


[web2py] Re: Web2py admin crashes

2013-10-03 Thread Dave S

On Thursday, October 3, 2013 8:28:52 AM UTC-7, Joe Magaro wrote:
>
> Hi, 
>
> All was working well, until today I went and clicked "administrative 
> interface" for my site, and it issues a ticket.
>
> Internal errorTicket issued: 
> admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1
>
> When I click to view the ticket, it crashes and issues another ticket. I 
> checked the http logs, but cant seem to find anything of importance. Can 
> some one give me the next step to help solve this issue?
>

Can you read the tickets from a local shell?

less Web2pyDir/applications/admin/errors/*



I just did the upgrade, and it looks like my services are running ok, but I 
get a "cannot import name Config", which I think means I missed copying one 
of the files from the welcome app or something.  Private server running 
web2py+rocket.

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


[web2py] Re: Change SQLFORM.grid Submit button label

2013-10-03 Thread P T
Thanks Massimo, but that didn't work. I resorted to using the following 
jQuery in the view:


 $('input[type="submit"][value="Submit"]').attr('value', 'Compare Selected'
);;


May be there is an equivalent expression in Web2Py.

Thanks,
PT



On Thursday, October 3, 2013 8:19:57 AM UTC-5, Massimo Di Pierro wrote:
>
> if grid.create_form or grid.update_form: grid.element(_type='submit')[
> '_value'] = T("something")
>
> On Wednesday, 2 October 2013 23:15:07 UTC-5, P T wrote:
>>
>> Hello All,
>>
>>
>> I want change the label of Submit button in the SQLFORm.grid. I found two 
>> solutions in the forum and both seems to be not working. 
>>
>> The first solution given here Changing SQLFORM.grid submit label from 
>> python without 
>> javascript?
>>   
>> is 
>>
>> grid.element(_type='submit')['_value'] = T("something")
>>
>> But, the above code is changing the label of the "Search" button. 
>>
>> The second solution given here SQLFORM.RID 
>> Selectable
>>  is
>>
>> grid.element('.web2py_table input[type=submit]')['_value'] = T(
>> 'something')
>>
>> This indeed changes the label of the Submit button but break the 
>> functionality of other buttons such as Edit, View and Delete and issues a 
>> ticket. 
>>
>> What I am doing wrong? By the way I am using the latest version 
>> 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the 
>> controller function:
>>
>> def listscenarios():
>>query = (db.scenario.created_by == auth.user.id)  
>>grid = SQLFORM.grid(query, 
>>links = [lambda row: A(I('',_class="icon-picture")+' Results',_class
>> ='btn', _href=URL("default","calculate", args=[row.id], user_signature=
>> True, hash_vars=True))],
>>selectable=lambda ids: compare(ids), csv=False, 
>>fields=[db.scenario.id, db.scenario.name, db.scenario.description, 
>>db.scenario.avg_mass, db.scenario.cell_type, db.scenario.
>> tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle],
>>oncreate=scenario_create)
>>
>>
>> ##   grid.element('.web2py_table input[type=submit]')['_value'] = 
>> T('Something') ## this causes problems with View and Edit buttons
>> ##   grid.element(_type='submit')['_value'] = T("something") ## this 
>> chnages the label of the Search button?
>>grid.element('.web2py_counter', replace=None) 
>>
>>
>>return dict(grid=grid)
>>
>>
>>
>> Thanks,
>> PT
>>
>

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


[web2py] onselect ajax...

2013-10-03 Thread Avi A

Hi,
I'm trying to use the ajax function on a list , with no success so far.

def echo():
return request.vars.value



{{for c in category:}}
{{=c.f_category_name}}
{{pass}}




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


[web2py] Re: .ics file name

2013-10-03 Thread Paolo Caruccio
maybe not related to your issue but anyway interesting to read

http://greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf
http://greenbytes.de/tech/webdav/rfc6266.html


Il giorno lunedì 30 settembre 2013 09:45:47 UTC+2, Annet ha scritto:
>
> In my application I include the name of an organization in a .ics file 
> name. Sometimes the name includes
> characters that render an invalid file name, is there a way to prevent 
> this form happening.
>
> This is the code in the controller:
>
>  def downloadVevent():
> name=None
> nodeID=int(request.args(0))
> response.view='download/vEvent.ics'
> node=retrieve_node(db, nodeID)
> if node:
> name=node.name
> else:
> redirect(URL('addressbook', 'router'))
> row=db(db.eventList.id==int(request.args(1))).select().first()
> vevent=response.render(name=name, row=row)
> return vevent.replace('\n\n', '\n')
>
>
> This is the code for the file name:
>
> {{response.headers['Content-Disposition'] = 
> 'attachment;filename=event_%s_%s.ics' % (IS_SLUG()(name)[0], 
> row.startDate.strftime("%d-%m-%Y"))}}
>
>
> Kind regards,
>
> Annet
>

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


[web2py] Re: PATCH(?) DAL with MSSQL and windows authentication

2013-10-03 Thread Josh Myers
Thank you, everyone.  The problem of how to sign in with windows 
authorization was solved for me when I used the following connection string 
in SQL Server 2005:
 
db = DAL('mssql://DRIVER={SQL 
Server};SERVER:ServerName;DATABASE=DatabaseName;TRUSTED_CONNECTION=YES;')
 
For some reason it needed that DRIVER statement.  That was also the same 
connection string that worked using pyodbc explicitly, so that makes sense 
I guess.
 

On Thursday, October 3, 2013 4:53:55 AM UTC-4, Niphlod wrote:

>
>
> Il giorno giovedì 3 ottobre 2013 01:20:40 UTC+2, Josh Myers ha scritto:
>>
>> I'm not a database expert.  
>>
>> Aren't both of those connection strings equivalent in the DAL?  Why are 
>> you saying they are different?  I will try it in the other format, the 
>> non-@ format.
>>
>> ehm.
>
> mssql://Provider=SQLNCLI11;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
> vs
> mssql://myUsername:myPassword@myServerAddress/myDataBase
>
> to me are different.
> That being said, there are a few options (especially with integrated auth) 
> that aren't "included" in the usual notation, so the only way is to use the 
> former notation.
>
>

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


[web2py] network troubles with builtin webserver (Windows)

2013-10-03 Thread Alex
I'm using the builtin webserver with web2py on Windows.

When I refresh the page (to reload all files) of a small app in Opera it 
takes very long (>10 sec) until the page is completely loaded. When I check 
the network log (with Dragonfly) I see that usually the first 10-20 files 
(css, js, images, etc.) are loaded very fast. The next couple of files are 
delayed for about 10 seconds (request is scheduled, header and body is 
written immediately, then the sequence is terminated and retried after 
about 10 seconds). After 10 seconds all remaining files are loaded quite 
fast.

Has anyone an idea what blocks loading these files? I guess the builtin 
webserver should be able to handle a couple of simultaneous requests.

Strangely this problem does not happen with FF or IE. Maybe it is because 
the timing of sending requests is different?

I have a similar issue when I access the page over a VPN with IE. Some 
scripts get corrupted and IE shows a syntax error (e.g. in the jquery js 
file). This problem only occurs with IE and not with the other browsers. I 
think it is related to the other issue, since it only happens when the 
whole page is refreshed and all files are requested. Still, I'm very 
confused...

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


[web2py] Absolute URL from field in grid

2013-10-03 Thread Gael Princivalle
Hi.

In a table I have that:
db.define_table('products',
Field('code', unique=True),
Field('description'),
Field('brand'),
Field('pdf_path'))

I want to have a sqlform.grid that gone have all links to pdf_path field. 
These are absolute links like "http://www.example.com/mycatalogue.pdf";

Here is my controller:
def products_listing():
links = [lambda row: A('pdf', _href=db.products.pdf_path)]
grid = SQLFORM.grid(db.products, orderby=db.products.code, 
links=links,links_in_grid=True)
return dict(grid=grid)

I have two problems, path is relative because it begin at my website 
http:///my_application/default
And the products.pdf_path field is not considered like a filed, but like a 
string.

The result is:  http:///my_application/default/products.pdf_path

I've tried also to play with the URL helper but without result.

An idea ?

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


[web2py] Web2py admin crashes

2013-10-03 Thread Joe Magaro
Hi, 

All was working well, until today I went and clicked "administrative 
interface" for my site, and it issues a ticket.

Internal errorTicket issued: 
admin/65.94.212.187.2013-10-03.19-26-12.8b8b3b98-0858-4925-a517-59ebed5f1ad1

When I click to view the ticket, it crashes and issues another ticket. I 
checked the http logs, but cant seem to find anything of importance. Can 
some one give me the next step to help solve this issue?

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


[web2py] Re: Strange behaviour of URL.verify() / @requires_signature() with big vars

2013-10-03 Thread D.
It does not really matter what's in the list:

Even a simple list like this leads to a 403-error: [0, 1, 2, 3, 4, 5, 6, 7, 
8, 9, 10]

How would I store and retrieve a long list in a session?

Thank you so much for your help!

Am Donnerstag, 3. Oktober 2013 15:22:04 UTC+2 schrieb Massimo Di Pierro:
>
> What's into files? How long are the strings? There are limits to how long 
> the query string can be. I thing the files should be saved in a session and 
> retrieved by the target page
>
> On Thursday, 3 October 2013 01:52:47 UTC-5, D. wrote:
>>
>> I'm still struggeling with this problem - does anyone have an idea?
>>
>> I narrowed it a bit further down:
>>
>> If the list I'm passing as vars contains 10 items or less 
>> @auth.requires_signature() validates correctly and access to the function 
>> is granted. However, if the list has 11 or more items I get "Insufficient 
>> priviledges".
>>
>> Best 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/groups/opt_out.


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Mirko
Eventually I got something working (may be crappy) to put on top of 
controller file:

*if request.global_settings.cmd_options.test.startswith('%s/%s' % 
(request.application,request.controller)):
auth.login_bare('user_for_test','his/her password')
*
Mirko


On Thursday, October 3, 2013 3:58:31 PM UTC+2, Mirko wrote:
>
> Hi Massimo, thank you very much for helping!
> However it looks like request.function contains '_TEST' only when doctest 
> is run from the web IDE, and contains function name when run from command 
> line..
>
> On Thursday, October 3, 2013 3:25:24 PM UTC+2, Massimo Di Pierro wrote:
>>
>> You need to add some logic that says:
>>
>> if request.function = '_TEST':
>>   auth.login_bare('user_for_test','his/her password')
>>
>> On Thursday, 3 October 2013 07:02:09 UTC-5, Mirko wrote:
>>>
>>> Hi all,
>>>
>>> I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 when 
>>> function c is decorated with *@auth.requires_login()* 
>>> It works fine without that decoration and I don't know how to 
>>> authenticate when running doctests from command line, any suggestions ?
>>>
>>> Many thanks!
>>> Mirko
>>>
>>>
>>> On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:

 I cannot say on top of my head. I would look into the 
 build_environment when/where that is set. 
 Thanks for looking into this. It is an important problem that needs to 
 be solved. 

 Massimo 

 On Oct 16, 10:03 am, rboissat  wrote: 
 > One issue though, with the code given above for instantiating a dummy 
 > env, 
 > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
 > 
 > It seems that in the line: 
 > 
 > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
 > 
 >  request.folder is NoneType, therefore making os.path.join fail. 
 > 
 > This is rather odd, cause in the tested controller, a: 
 > 
 > print request.folder 
 > 
 > gives me the the right path to my application. 
 > 
 > Any idea?
>>>
>>>

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


[web2py] Re: Union of tables displayed in SQLFORM.grid

2013-10-03 Thread Niphlod
you can reassemble the smaller ones in a view, define that view as 
migrate=False and query that with web2py. There's no support for UNION in 
web2py.

On Thursday, October 3, 2013 3:10:22 PM UTC+2, TYRANISTAR wrote:
>
> Hello everyone,
>
> I have a big mysql table that I want to break into smaller ones in order 
> to retrieve its results quicker via a web2py interface. Question is is 
> there a way to call a union of the smalleer tables via SQLFORM.grid (giving 
> the number and names of tables as arguments) and if not is there another 
> way?
>
> 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/groups/opt_out.


[web2py] Re: how to build windows binary?

2013-10-03 Thread Niphlod
all files gets correctly imported and compiled even if it's commented with 
latest py2exe

On Thursday, October 3, 2013 11:52:44 AM UTC+2, step wrote:
>
> Thanks Niphlod. By the way, when I build web2py.exe should I 
> uncomment line 17 of web2py.py or should I leave it commented out as it 
> is?
>
> On Tuesday, October 1, 2013 8:43:52 PM UTC+2, Niphlod wrote:
>>
>> it's because of a bug in widget.py. Sending a PR and notifying @massimo 
>> right now. 
>>
>> On Tuesday, October 1, 2013 6:37:49 PM UTC+2, step wrote:
>>>
>>> Sorry, it's line 17 of web2py.py that I uncommented, not gluon\main.py
>>> import gluon.import_all # This should be uncommented for py2exe.py
>>>
>>> On Tuesday, October 1, 2013 6:12:21 PM UTC+2, step wrote:

 I noticed a comment on line 17 of gluon\main.py, uncommented the line 
 and rebuilt with py2exe to no avail, I still get the same error message
 .



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


[web2py] Re: Expression' object has no attribute

2013-10-03 Thread Anthony
db.static_text.id is a field object. If you want a record, you would do:

db.static_text(1)

or

db(db.static_text.id == 1).select().first()

Anthony

On Thursday, October 3, 2013 10:09:54 AM UTC-4, Gael Princivalle wrote:
>
> Hi.
>
> I want to show different fields in my applications, depending of the 
> current language (italian or english).
>
> Here is my table with static text like company presentation...
>
> db.define_table('static_text',
> Field('title_en'),
> Field('title_it'),
> Field('text_en', type='text'),
> Field('text_it', type='text'))
>
> The controller: (I know that company's texts are in the row with id==1
> def company():
> company = db.static_text.id[1]
> return dict(company=company)
>
> The view:
> {{extend 'layout.html'}}
> Company page
> {{if T.accepted_language=='it':}}
> {{=p(company.title_it)}}
> {{=p(company.text_it)}}
> {{else:}}
> {{=p(company.title_en)}}
> {{=p(company.text_en)}}
> {{pass}}
>
> I have this error: Expression' object has no attribute 'title_it'.
>
> Someone can give me a hand ?
>

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


[web2py] Expression' object has no attribute

2013-10-03 Thread Gael Princivalle
Hi.

I want to show different fields in my applications, depending of the 
current language (italian or english).

Here is my table with static text like company presentation...

db.define_table('static_text',
Field('title_en'),
Field('title_it'),
Field('text_en', type='text'),
Field('text_it', type='text'))

The controller: (I know that company's texts are in the row with id==1
def company():
company = db.static_text.id[1]
return dict(company=company)

The view:
{{extend 'layout.html'}}
Company page
{{if T.accepted_language=='it':}}
{{=p(company.title_it)}}
{{=p(company.text_it)}}
{{else:}}
{{=p(company.title_en)}}
{{=p(company.text_en)}}
{{pass}}

I have this error: Expression' object has no attribute 'title_it'.

Someone can give me a hand ?

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


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Mirko
Hi Massimo, thank you very much for helping!
However it looks like request.function contains '_TEST' only when doctest 
is run from the web IDE, and contains function name when run from command 
line..

On Thursday, October 3, 2013 3:25:24 PM UTC+2, Massimo Di Pierro wrote:
>
> You need to add some logic that says:
>
> if request.function = '_TEST':
>   auth.login_bare('user_for_test','his/her password')
>
> On Thursday, 3 October 2013 07:02:09 UTC-5, Mirko wrote:
>>
>> Hi all,
>>
>> I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 when 
>> function c is decorated with *@auth.requires_login()* 
>> It works fine without that decoration and I don't know how to 
>> authenticate when running doctests from command line, any suggestions ?
>>
>> Many thanks!
>> Mirko
>>
>>
>> On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:
>>>
>>> I cannot say on top of my head. I would look into the 
>>> build_environment when/where that is set. 
>>> Thanks for looking into this. It is an important problem that needs to 
>>> be solved. 
>>>
>>> Massimo 
>>>
>>> On Oct 16, 10:03 am, rboissat  wrote: 
>>> > One issue though, with the code given above for instantiating a dummy 
>>> > env, 
>>> > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
>>> > 
>>> > It seems that in the line: 
>>> > 
>>> > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
>>> > 
>>> >  request.folder is NoneType, therefore making os.path.join fail. 
>>> > 
>>> > This is rather odd, cause in the tested controller, a: 
>>> > 
>>> > print request.folder 
>>> > 
>>> > gives me the the right path to my application. 
>>> > 
>>> > Any idea?
>>
>>

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


Re: [web2py] Multiple domains accessing all apps through URL

2013-10-03 Thread Jonathan Lundell
On 3 Oct 2013, at 5:36 AM, Anthony  wrote:
> On Thursday, October 3, 2013 12:36:34 AM UTC-4, Jonathan Lundell wrote:
> On 2 Oct 2013, at 10:36 PM, Anthony  wrote:
>> A couple years ago, Jonathan seemed to think this behavior was a bug and 
>> alluded to a fix in trunk: 
>> https://groups.google.com/d/msg/web2py/elnV_6Ntw3E/KWNlpoJfpWAJ.
> 
> See if setting exclusive_domain=True in the router helps.
> 
> From that earlier discussion, it sounded like this was supposed to be the 
> behavior even without setting exclusive_domain to True. Was the old behavior 
> kept for backward compatibility?
> 


The relevant line (MapUrlIn.map_app):

if not base.exclusive_domain and base.applications and arg0 in 
base.applications:

This is the highest-priority test for resolving the app identity; arg0 is the 
(current) leftmost item of the incoming path. The following test is relevant as 
well; the third & fourth handle domain mapping. 

And *then* we repeat the first two tests but without exclusive_domain. That may 
have been the 

Per the old thread, it might be best to make exclusive_domain default to True. 
In the thread, I mention removing the option and forcing it always; at the 
moment I can't think of a case where it'd be desirable for it to be False, but 
my imagination might simply be not up to the task.

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


[web2py] Union of tables displayed in SQLFORM.grid

2013-10-03 Thread TYRANISTAR
Hello everyone,

I have a big mysql table that I want to break into smaller ones in order to 
retrieve its results quicker via a web2py interface. Question is is there a 
way to call a union of the smalleer tables via SQLFORM.grid (giving the 
number and names of tables as arguments) and if not is there another way?

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


Re: [web2py] .ics file name

2013-10-03 Thread Richard Vézina
You can test your ical file here : http://severinghaus.org/projects/icv/

To help troobleshoot...

Richard


On Thu, Oct 3, 2013 at 9:35 AM, Richard Vézina
wrote:

> Ho! You are generating the file? I thought you were parsing a file... So
> maybe you need .encode('someencoding')
>
> I am not sure but I think web2py will return ascii since python default
> encoding is ascii (http://docs.python.org/2/howto/unicode.html)
>
> So something like that :
>
> row.variable.encoding('utf-8') should work...
>
> ?
>
> Richard
>
>
> On Thu, Oct 3, 2013 at 2:48 AM, Annet  wrote:
>
>>
>> Not just this, the text inside of the file should be utf-8 encoded...
>>> Where this file come from (which software generate it)?
>>>
>>> You have to make sure that it is generated correctly (right encoding),
>>> in thunderbird for instance you can specified it if I remember. In outlook
>>> it may be impossible, so you will have to convert it mannually.
>>>
>>
>>
>> Is that what the call to xml() does in generic.ics?
>>
>> It's not the contents of the file that's giving me problems, the contents
>> is ietf compliant, it's the file name that's the cause of the problem.
>> Here's the contents of the .ics file.
>>
>>
>>  {{response.headers['Content-Disposition'] =
>> 'attachment;filename=event_%s_%s.ics' % (IS_SLUG()(name)[0],
>> row.startDate.strftime("%d-%m-%Y"))}}BEGIN:VCALENDAR
>> VERSION:2.0
>> CALSCALE:GREGORIAN
>> BEGIN:VEVENT
>> {{if row.onlocation:}}LOCATION:{{=row.onlocation}}{{pass}} {{if
>> row.locality:}}{{=row.locality}}{{pass}}
>> SUMMARY:{{=row.summary}}
>> DTSTART;TZID={{=row.TZID}}:{{=row.startDate.strftime("%Y-%m-%d").replace("-","")}}{{if
>> row.startTime:}}T{{=row.startTime.strftime("%H:%M:%S").replace(":","")}}{{pass}}
>> DTEND;TZID={{=row.TZID}}:{{if
>> row.endDate:}}{{=row.endDate.strftime("%Y-%m-%d").replace("-","")}}{{else:}}{{=row.startDate.strftime("%Y-%m-%d").replace("-","")}}{{pass}}{{if
>> row.endTime:}}T{{=row.endTime.strftime("%H:%M:%S").replace(":","")}}{{else:}}T24{{pass}}
>> {{if row.shortdescr:}}DESCRIPTION:{{=row.shortdescr}}{{pass}}
>> {{if row.url:}}URL;VALUE=URI:{{=row.url}}{{pass}}
>> END:VEVENT
>> END:VCALENDAR
>>
>>
>> Kind regards,
>>
>> Annet
>>
>> --
>> 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/groups/opt_out.
>>
>
>

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


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Massimo Di Pierro
You need to add some logic that says:

if request.function = '_TEST':
  auth.login_bare('user_for_test','his/her password')

On Thursday, 3 October 2013 07:02:09 UTC-5, Mirko wrote:
>
> Hi all,
>
> I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 when 
> function c is decorated with *@auth.requires_login()* 
> It works fine without that decoration and I don't know how to 
> authenticate when running doctests from command line, any suggestions ?
>
> Many thanks!
> Mirko
>
>
> On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:
>>
>> I cannot say on top of my head. I would look into the 
>> build_environment when/where that is set. 
>> Thanks for looking into this. It is an important problem that needs to 
>> be solved. 
>>
>> Massimo 
>>
>> On Oct 16, 10:03 am, rboissat  wrote: 
>> > One issue though, with the code given above for instantiating a dummy 
>> > env, 
>> > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
>> > 
>> > It seems that in the line: 
>> > 
>> > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
>> > 
>> >  request.folder is NoneType, therefore making os.path.join fail. 
>> > 
>> > This is rather odd, cause in the tested controller, a: 
>> > 
>> > print request.folder 
>> > 
>> > gives me the the right path to my application. 
>> > 
>> > Any idea?
>
>

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


Re: [web2py] .ics file name

2013-10-03 Thread Richard Vézina
Ho! You are generating the file? I thought you were parsing a file... So
maybe you need .encode('someencoding')

I am not sure but I think web2py will return ascii since python default
encoding is ascii (http://docs.python.org/2/howto/unicode.html)

So something like that :

row.variable.encoding('utf-8') should work...

?

Richard


On Thu, Oct 3, 2013 at 2:48 AM, Annet  wrote:

>
> Not just this, the text inside of the file should be utf-8 encoded...
>> Where this file come from (which software generate it)?
>>
>> You have to make sure that it is generated correctly (right encoding), in
>> thunderbird for instance you can specified it if I remember. In outlook it
>> may be impossible, so you will have to convert it mannually.
>>
>
>
> Is that what the call to xml() does in generic.ics?
>
> It's not the contents of the file that's giving me problems, the contents
> is ietf compliant, it's the file name that's the cause of the problem.
> Here's the contents of the .ics file.
>
>
>  {{response.headers['Content-Disposition'] =
> 'attachment;filename=event_%s_%s.ics' % (IS_SLUG()(name)[0],
> row.startDate.strftime("%d-%m-%Y"))}}BEGIN:VCALENDAR
> VERSION:2.0
> CALSCALE:GREGORIAN
> BEGIN:VEVENT
> {{if row.onlocation:}}LOCATION:{{=row.onlocation}}{{pass}} {{if
> row.locality:}}{{=row.locality}}{{pass}}
> SUMMARY:{{=row.summary}}
> DTSTART;TZID={{=row.TZID}}:{{=row.startDate.strftime("%Y-%m-%d").replace("-","")}}{{if
> row.startTime:}}T{{=row.startTime.strftime("%H:%M:%S").replace(":","")}}{{pass}}
> DTEND;TZID={{=row.TZID}}:{{if
> row.endDate:}}{{=row.endDate.strftime("%Y-%m-%d").replace("-","")}}{{else:}}{{=row.startDate.strftime("%Y-%m-%d").replace("-","")}}{{pass}}{{if
> row.endTime:}}T{{=row.endTime.strftime("%H:%M:%S").replace(":","")}}{{else:}}T24{{pass}}
> {{if row.shortdescr:}}DESCRIPTION:{{=row.shortdescr}}{{pass}}
> {{if row.url:}}URL;VALUE=URI:{{=row.url}}{{pass}}
> END:VEVENT
> END:VCALENDAR
>
>
> Kind regards,
>
> Annet
>
> --
> 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/groups/opt_out.
>

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


Re: [web2py] Re: Master / Detail with field value in the detail and overall value in the master

2013-10-03 Thread 黄祥
yes, can, sqlform.grid have ondelete too. 
e.g.
def __oncreate_function(form):
your function/query here

def __onupdate_function(form):
your function/query here

def __ondelete_function(table_involved, id_of_the_deleted_record):
your function/query here

def grid_function():
grid = SQLFORM.grid(db.table_name, oncreate=__oncreate_function, 
onupdate=__onupdate_function, ondelete=__ondelete_function)
return locals()

please notice that ondelete function have different arguments than onupdate 
and oncreate function.
for detail explaination and example please take a look at :
https://groups.google.com/forum/#!topic/web2py/ShebcblC9pM

hope this can help.

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


[web2py] Re: Strange behaviour of URL.verify() / @requires_signature() with big vars

2013-10-03 Thread Massimo Di Pierro
What's into files? How long are the strings? There are limits to how long 
the query string can be. I thing the files should be saved in a session and 
retrieved by the target page

On Thursday, 3 October 2013 01:52:47 UTC-5, D. wrote:
>
> I'm still struggeling with this problem - does anyone have an idea?
>
> I narrowed it a bit further down:
>
> If the list I'm passing as vars contains 10 items or less 
> @auth.requires_signature() validates correctly and access to the function 
> is granted. However, if the list has 11 or more items I get "Insufficient 
> priviledges".
>
> Best 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/groups/opt_out.


[web2py] Re: Change SQLFORM.grid Submit button label

2013-10-03 Thread Massimo Di Pierro
if grid.create_form or grid.update_form: grid.element(_type='submit')[
'_value'] = T("something")

On Wednesday, 2 October 2013 23:15:07 UTC-5, P T wrote:
>
> Hello All,
>
>
> I want change the label of Submit button in the SQLFORm.grid. I found two 
> solutions in the forum and both seems to be not working. 
>
> The first solution given here Changing SQLFORM.grid submit label from 
> python without 
> javascript?
>   
> is 
>
> grid.element(_type='submit')['_value'] = T("something")
>
> But, the above code is changing the label of the "Search" button. 
>
> The second solution given here SQLFORM.RID 
> Selectable
>  is
>
> grid.element('.web2py_table input[type=submit]')['_value'] = T('something'
> )
>
> This indeed changes the label of the Submit button but break the 
> functionality of other buttons such as Edit, View and Delete and issues a 
> ticket. 
>
> What I am doing wrong? By the way I am using the latest version 
> 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the 
> controller function:
>
> def listscenarios():
>query = (db.scenario.created_by == auth.user.id)  
>grid = SQLFORM.grid(query, 
>links = [lambda row: A(I('',_class="icon-picture")+' Results',_class
> ='btn', _href=URL("default","calculate", args=[row.id], user_signature=
> True, hash_vars=True))],
>selectable=lambda ids: compare(ids), csv=False, 
>fields=[db.scenario.id, db.scenario.name, db.scenario.description, 
>db.scenario.avg_mass, db.scenario.cell_type, db.scenario.
> tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle],
>oncreate=scenario_create)
>
>
> ##   grid.element('.web2py_table input[type=submit]')['_value'] = 
> T('Something') ## this causes problems with View and Edit buttons
> ##   grid.element(_type='submit')['_value'] = T("something") ## this 
> chnages the label of the Search button?
>grid.element('.web2py_counter', replace=None) 
>
>
>return dict(grid=grid)
>
>
>
> Thanks,
> PT
>

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


RES: [web2py] Re: Master / Detail with field value in the detail and overall value in the master

2013-10-03 Thread Meir
Thank you! I will test now!

But in the case of JavaScript that calls a delete, event exists to delete?

For this case must deduct the value in the header ...

 

De: web2py@googlegroups.com [mailto:web2py@googlegroups.com] Em nome de ??
Enviada em: quinta-feira, 3 de outubro de 2013 10:09
Para: web2py@googlegroups.com
Assunto: [web2py] Re: Master / Detail with field value in the detail and
overall value in the master

 

did you mean header detail? i think you can do it with oncreate (function
run on create event) and onupdate (function run on update event). first
create oncreate and onupdate function after then call it from your grid
function. 

e.g.

def __oncreate_function(form):

your function/query here

 

def __onupdate_function(form):

your function/query here

 

def grid_function():

grid = SQLFORM.grid(db.table_name, oncreate=__oncreate_function,
onupdate=__onupdate_function)

return locals()

 

hope this can help.

 

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

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


[web2py] Re: User Login causes error on GAE

2013-10-03 Thread Massimo Di Pierro
Something is resetting auth.settings.table_user. Do you have that your 
code. Do you use lazy tables?

On Wednesday, 2 October 2013 23:06:09 UTC-5, Andy W wrote:
>
> Version 2.6.4
> Upgrade seemed to go OK. Soon after the upgrade I added 
> auth.settings.extra_fields in db.py to add an extra field to the user. This 
> seemed to trigger the login error, and removing that extra field has not 
> resolved the problem.
>
> On Thursday, October 3, 2013 3:18:12 AM UTC+4, Massimo Di Pierro wrote:
>>
>> Which web2py version? Was this on upgrade of what triggered the problem?
>>
>> On Tuesday, 1 October 2013 23:48:18 UTC-5, Andy W wrote:
>>>
>>> My application works fine locally with rocket/SQLlite but on GAE it now 
>>> fails when a user logs in.
>>> It was working previously. The problem appeared when I added an extra 
>>> field to auth_user. I have now removed this field but the error remains.
>>> I do not understand the error log sufficient to know where to start - 
>>> any suggestions?
>>>
>>> ERROR2013-10-02 04:33:36,354 restricted.py:166] Traceback (most 
 recent call last):

   File "/Users/andy/www/web2py/gluon/restricted.py", line 217, in 
 restricted

 exec ccode in environment

   File 
 "/Users/andy/www/web2py/applications/nurserymgr/controllers/default.py", 
 line 75, in 

   File "/Users/andy/www/web2py/gluon/globals.py", line 371, in 

 self._caller = lambda f: f()

   File 
 "/Users/andy/www/web2py/applications/nurserymgr/controllers/default.py", 
 line 37, in user

 return dict(form=auth())

   File "/Users/andy/www/web2py/gluon/tools.py", line 1297, in __call__

 return getattr(self, args[0])()

   File "/Users/andy/www/web2py/gluon/tools.py", line 2364, in login

 self.login_user(user)

   File "/Users/andy/www/web2py/gluon/tools.py", line 1973, in login_user

 user = Row(self.settings.table_user._filter_fields(user, id=True))

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

>>>

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


[web2py] Re: Master / Detail with field value in the detail and overall value in the master

2013-10-03 Thread 黄祥
did you mean header detail? i think you can do it with oncreate (function 
run on create event) and onupdate (function run on update event). first 
create oncreate and onupdate function after then call it from your grid 
function. 
e.g.
def __oncreate_function(form):
your function/query here

def __onupdate_function(form):
your function/query here

def grid_function():
grid = SQLFORM.grid(db.table_name, oncreate=__oncreate_function, 
onupdate=__onupdate_function)
return locals()

hope this can help.

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


[web2py] Master / Detail with field value in the detail and overall value in the master

2013-10-03 Thread Meir
Hello community, all right?

 

I resolve an impasse ... I have a screen with Master / Detail. Detail is in
the SQLFORM.grid and I would like to update or insert a record in the detail
he added up the total value of a field that is in the Master.

 

What better way for this?

 

Remembering: The Detail SQLFORM.grid I use standard, non customizei nothing
...

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


[web2py] On moving incremental changes to production

2013-10-03 Thread Jayadevan M
I have deployed version 1 of an application in production. Let us say we 
used the admin console and created a project (.w2p) file and that was how 
we deployed it. Which is the best way to roll out the next release? If we 
use the same approach, it will also move to prod the files under databases 
folder and result in conflicts?

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


Re: [web2py] "Not indexable" error when disabling app from admin

2013-10-03 Thread Marin Pranjić
I think this is fixed in trunk.

Marin


On Thu, Oct 3, 2013 at 2:36 PM, keiser1080  wrote:

> Hi,
>
> "Not indexable" error when disabling app from admin.
> My setup:
>
> 2.6.4-stable+timestamp.2013.09.22.01.43.37
> (Running on nginx/1.1.19, Python 2.7.3) in a virtual env
>
>
> On other virtual environment that work under
>
> 2.5.1-stable+timestamp.2013.06.06.15.39.19
> (Running on nginx/1.1.19)
>
>
>
>  --
> 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/groups/opt_out.
>

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


[web2py] "Not indexable" error when disabling app from admin

2013-10-03 Thread keiser1080
Hi,

"Not indexable" error when disabling app from admin.
My setup:

2.6.4-stable+timestamp.2013.09.22.01.43.37
(Running on nginx/1.1.19, Python 2.7.3) in a virtual env


On other virtual environment that work under

2.5.1-stable+timestamp.2013.06.06.15.39.19
(Running on nginx/1.1.19)   



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


[web2py] Re: displaying associated information

2013-10-03 Thread Mihir Lade
my understanding behind how it should work is.. 

"when the products button is hit, it should grab the auth_id and pass it to 
some function, maybe something like "getProducts()" which then queries the 
products database and only returns the results which are associated with 
the auth_id"

could be wrong.

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


[web2py] Re: Issue running doctest with decorated functions

2013-10-03 Thread Mirko
Hi all,

I confirm "*python web2py.py -T a/b/c"* is not working with 2.5.1 when 
function c is decorated with *@auth.requires_login()* 
It works fine without that decoration and I don't know how to authenticate 
when running doctests from command line, any suggestions ?

Many thanks!
Mirko


On Friday, October 16, 2009 5:11:49 PM UTC+2, mdipierro wrote:
>
> I cannot say on top of my head. I would look into the 
> build_environment when/where that is set. 
> Thanks for looking into this. It is an important problem that needs to 
> be solved. 
>
> Massimo 
>
> On Oct 16, 10:03 am, rboissat  wrote: 
> > One issue though, with the code given above for instantiating a dummy 
> > env, 
> > I get this traceback:http://oxynux.org/pastebin/lbc6tu-534 
> > 
> > It seems that in the line: 
> > 
> > SQLDB._set_thread_folder(os.path.join(request.folder, 'databases')) 
> > 
> >  request.folder is NoneType, therefore making os.path.join fail. 
> > 
> > This is rather odd, cause in the tested controller, a: 
> > 
> > print request.folder 
> > 
> > gives me the the right path to my application. 
> > 
> > Any idea?

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


[web2py] displaying associated information

2013-10-03 Thread Mihir Lade
hi guys,

i am working on a part of a project where i need to display data associated 
with each author.. 

the author's page currently looks like:
http://webeng.gwillz.com/suzannecollins/default/authors

which is generated using the code:
{{extend 'layout.html'}}
Authors

{{for Author in Authors:}}
{{=Author.first_name}} {{=Author.last_name}}
Products
About

    

{{pass}}


my part is to display the products associated with each author when the 
product button is clicked.
because the products button is being printed out in a for loop i am having 
difficulty getting my head around it. i can use js/ajax/json or any other 
ways to get this working but can't seem to understand how i can get it to 
work

any suggestions?

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


Re: [web2py] Re: Multiple domains accessing all apps through URL

2013-10-03 Thread Anthony
On Thursday, October 3, 2013 12:36:34 AM UTC-4, Jonathan Lundell wrote:

> On 2 Oct 2013, at 10:36 PM, Anthony > 
> wrote:
>
> A couple years ago, Jonathan seemed to think this behavior was a bug and 
> alluded to a fix in trunk: 
> https://groups.google.com/d/msg/web2py/elnV_6Ntw3E/KWNlpoJfpWAJ.
>
>
> See if setting exclusive_domain=True in the router helps.
>

>From that earlier discussion, it sounded like this was supposed to be the 
behavior even without setting exclusive_domain to True. Was the old 
behavior kept for backward compatibility?

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


[web2py] Re: HA/Cluster Feature Request?

2013-10-03 Thread Anthony
Database sessions are also discussed in the main book section on 
sessions, 
along with the cookie based session option (which can also be helpful for 
high availability).

Anthony

On Thursday, October 3, 2013 4:55:24 AM UTC-4, Niphlod wrote:
>
> why doesn't anyone search the book before asking ??? :-P
>
>
> http://web2py.com/books/default/chapter/29/13/deployment-recipes#Efficiency-and-scalability
>
> Il giorno mercoledì 2 ottobre 2013 15:45:21 UTC+2, damona ha scritto:
>>
>> Any thoughts on this for clustering and High Availability?
>>
>> Could a feature be added to web2py to store session information in the 
>> DB, so using sticky session is optional, or if a server goes down it can 
>> get the session information.
>>
>> e.g.
>>
>> Proxy with stick session too server A and B
>> Web2py on servers A and B store session information in DB when it changes.
>> Server B goes down, everyone ones requests goes to server A
>> Server A is sent a session which it does no know about, it looks it up in 
>> the DB.
>> Users never knows that server B went down.
>>
>> You could also as part of the session record a modification date, and if 
>> it does not match what web2py has recorded locally it then looks it in the 
>> DB as well.   This would also allow you not to have sticky sessions.
>>
>> Cheers.
>>  PS I would have thought GAE would have to store session information in 
>> Datastore/MySQL already?
>>
>

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


[web2py] Re: how to build windows binary?

2013-10-03 Thread step
Thanks Niphlod. By the way, when I build web2py.exe should I uncomment line 
17 of web2py.py or should I leave it commented out as it is?

On Tuesday, October 1, 2013 8:43:52 PM UTC+2, Niphlod wrote:
>
> it's because of a bug in widget.py. Sending a PR and notifying @massimo 
> right now. 
>
> On Tuesday, October 1, 2013 6:37:49 PM UTC+2, step wrote:
>>
>> Sorry, it's line 17 of web2py.py that I uncommented, not gluon\main.py
>> import gluon.import_all # This should be uncommented for py2exe.py
>>
>> On Tuesday, October 1, 2013 6:12:21 PM UTC+2, step wrote:
>>>
>>> I noticed a comment on line 17 of gluon\main.py, uncommented the line 
>>> and rebuilt with py2exe to no avail, I still get the same error message.
>>>
>>>

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


[web2py] Re: CREATE DATABASE cannot run inside a transaction block

2013-10-03 Thread at

thank you richard!

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


[web2py] Re: Is is possible to create a postgres database from web2py application?

2013-10-03 Thread at

Thanks all for replies and assistance; I've now a better understading of 
DAL's scope and limitations.

Regards,
AT

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


[web2py] Re: HA/Cluster Feature Request?

2013-10-03 Thread Niphlod
why doesn't anyone search the book before asking ??? :-P

http://web2py.com/books/default/chapter/29/13/deployment-recipes#Efficiency-and-scalability

Il giorno mercoledì 2 ottobre 2013 15:45:21 UTC+2, damona ha scritto:
>
> Any thoughts on this for clustering and High Availability?
>
> Could a feature be added to web2py to store session information in the DB, 
> so using sticky session is optional, or if a server goes down it can get 
> the session information.
>
> e.g.
>
> Proxy with stick session too server A and B
> Web2py on servers A and B store session information in DB when it changes.
> Server B goes down, everyone ones requests goes to server A
> Server A is sent a session which it does no know about, it looks it up in 
> the DB.
> Users never knows that server B went down.
>
> You could also as part of the session record a modification date, and if 
> it does not match what web2py has recorded locally it then looks it in the 
> DB as well.   This would also allow you not to have sticky sessions.
>
> Cheers.
>  PS I would have thought GAE would have to store session information in 
> Datastore/MySQL already?
>

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


[web2py] Re: PATCH(?) DAL with MSSQL and windows authentication

2013-10-03 Thread Niphlod


Il giorno giovedì 3 ottobre 2013 01:20:40 UTC+2, Josh Myers ha scritto:
>
> I'm not a database expert.  
>
> Aren't both of those connection strings equivalent in the DAL?  Why are 
> you saying they are different?  I will try it in the other format, the 
> non-@ format.
>
> ehm.
mssql://Provider=SQLNCLI11;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
vs
mssql://myUsername:myPassword@myServerAddress/myDataBase

to me are different.
That being said, there are a few options (especially with integrated auth) 
that aren't "included" in the usual notation, so the only way is to use the 
former notation.

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


[web2py] Re: Scheduler question

2013-10-03 Thread Niphlod


Il giorno giovedì 3 ottobre 2013 08:19:48 UTC+2, Andrew W ha scritto:
>
> Hi Niphlod,
> If I could add to the questions (I'm having some success with the 
> scheduler but there's a few gaps in my understanding):
> What process removes the rows from the scheduler_worker table ?  
> Does it make any difference to Kill a worker by updating it's status or by 
> just Ctl-C (Or closing the window in Windows) to stop the task ?
>
>  
ctrl+c means killing from outside. setting to KILL means killing (still 
abruptly) but within inside the process. YMMV but I assume it's always best 
to avoid ctrl+c in production :D
 

> I have one worker row with a status of KILL.  The scheduler worker process 
> has stopped correctly.   Does there need to be at least one active worker 
> to clean up this table ?  Will this row be removed when I restart a worker 
> instance?
>  
>
yes. all workers do a cleanup at the start and every once in a while
 

> What happens when I have several Assigned Tasks, but the worker to which 
> they are assigned is Killed ?  Will they be reassigned automatically ? 
>

yes.
 

>   
> Does KILLing a worker terminate the task that the worker is running as 
> well as the specific worker instance ?  I expect so but to be clear there 
> are two things running - the worker instance, and the specific task that 
> the worker has initiated.   Some of the wording talks about the worker 
> task, but is that referring to both or just one of these two processes ?
>

when you KILL a worker, the task gets terminated abruptly and the worker 
exits as soon as the task process has been shut down
 

>  
> Probably just a general web2py question, but I have a menu item that calls 
> a controller which runs " scheduler.queue_task(" .  Unfortunately I get 
> two rows inserted into scheduler_task and i can't work out why.  The 
> controller appears to be called twice. 
>

log a line before calling queue_task. then it's just a matter to see where 
the request comes from :D
 

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


[web2py] logging controller output for specific session

2013-10-03 Thread Geo
Greetings,
I have a controller that generates many log messages. Most of them are 
currently used for debugging but some (warnings and errors) are also useful 
for users.
Logs are currently handled with a module similar to this: 
http://www.web2pyslices.com/slice/show/1416/logging

I have tried attaching a StringIO handler to capture messages to a string

import logging
import StringIO

def index():
log_capture_string = StringIO.StringIO()
ch = logging.StreamHandler(log_capture_string)
ch.setLevel(logging.ERROR)
logger.addHandler(ch)

#controller actions

logger.removeHandler(ch)
notifications = log_capture_string.getvalue()
notifications = notifications.split('\n')
log_capture_string.close()

#controller return
return dict(notifications = notifications, myothervars=myothervars)


This works well if I run this controller "alone" (no other sessions, no 
other controllers running at the same time). But as soon as I run something 
else concurrently, the handler will capture that too.

Do you know if there is a way to capture the output of a controller when 
ran in a specific session?
I thought about mimicking the internal error handler (the one that 
generates error tickets) but without success.

Thanks in advance
Geo

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