Re: [web2py] Re: About web2py_component and redirect

2016-11-09 Thread 黄祥
i think you can use comment for that, n modify the css class to your own 
css (assuming you have your own css)
e.g.
db.test.user.comment = A(_class="glyphicon glyphicon-plus-sign", 
**{"_data-toggle":"modal", "_data-target":"#modal_auth_user"} ) if 
has_membership_admin else None

best regards,
stifan

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


[web2py] Arbitrary args/kwargs with service?

2016-11-09 Thread Brendan Barnwell
Hi, I've been experimenting the web2py services functionality.  Very neat!  
But what I'm wondering is whether it is possible to expose a service that 
accepts arbitrary URL parameters and receives them as *args and/or 
**kwargs.  That is, I'd like to have code like this:

@service.json
def myfinc(this, that, *args, **kwargs):
# ...

And if I visit 
myapp/default/call/json/this/that/something/else?key=foo&otherkey=bar , 
then I would get ("something", "else") in args, and {"key": "foo", 
"otherkey": "bar"} in kwargs.  Is such a thing possible.  Looking at the 
code in gluon.tools.py (specifically the "universal_caller" function), I'm 
guessing no, because it doesn't seem to just silently swallow any extra 
arguments that don't match with the function signature, and it doesn't 
check to see whether the function accepts varargs.  Has there been any 
discussion about adding such a feature?

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


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-09 Thread Mike Stephenson
It's messed up.
Can you help out with a code snippet? Will be of much help.

On Thursday, November 10, 2016 at 12:17:17 AM UTC+5:30, Leonel Câmara wrote:
>
> What do you mean? What are you trying to do? How are you putting the json 
> there? Are you getting it using $.getJSON or something like that?
>

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


Re: [web2py] Re: About web2py_component and redirect

2016-11-09 Thread Marco Mansilla
El Wed, 9 Nov 2016 15:45:55 -0800 (PST)
黄祥  escribió:

> *pls try :*
> *controllers/default.py*
> def modal_auth_user():
> table = db.auth_user
> fields = None
> target_response = '(function($) 
> {$("#modal_auth_user").modal("hide");}(jQuery));'
> form = SQLFORM(table, fields = fields)
> if form.process(formname = 'form_modal').accepted:
> response.js = target_response
> redirect(request.env.http_web2py_component_location, client_side =
> True) elif form.errors:
> response.flash = 'form has errors'
> return dict(form = form)
> 
> *views/default/index.html*
> {{extend 'layout.html'}}
> 
> {{=H3(T('Test'), _class = 'text-info') }}
> 
> {{=LOAD('default', 'test.load', ajax = True, 
> target = 'test') }}
> 
> *views/default/test.load*
> {{=form}}
> 
>  role="dialog" aria-labelledby="myModalLabel">
> 
> 
> 
>  aria-label="Close">×
> {{=DIV(T('User') ) }}
> 
> 
> {{=LOAD('default', 'modal_auth_user.load', ajax = True) }}
> 
> 
> 
> 
> 
> best regards,
> stifan
> 

Thank you both, everything seems to work nice now, so next step would
be create a plugin/widget to add a + button next to item list field. I
think there was a plugin, documented on web2py slices but last time I
tried didn't work for compatibility issues, so will do that by myself.

Thanks for the help, and sorry for the lazy question.

Marco.

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


Re: [web2py] Re: About web2py_component and redirect

2016-11-09 Thread 黄祥
*pls try :*
*controllers/default.py*
def modal_auth_user():
table = db.auth_user
fields = None
target_response = '(function($) 
{$("#modal_auth_user").modal("hide");}(jQuery));'
form = SQLFORM(table, fields = fields)
if form.process(formname = 'form_modal').accepted:
response.js = target_response
redirect(request.env.http_web2py_component_location, client_side = True)
elif form.errors:
response.flash = 'form has errors'
return dict(form = form)

*views/default/index.html*
{{extend 'layout.html'}}

{{=H3(T('Test'), _class = 'text-info') }}

{{=LOAD('default', 'test.load', ajax = True, 
target = 'test') }}

*views/default/test.load*
{{=form}}





×
{{=DIV(T('User') ) }}


{{=LOAD('default', 'modal_auth_user.load', ajax = True) }}





best regards,
stifan

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


Re: [web2py] Re: About web2py_component and redirect

2016-11-09 Thread Anthony
No, use response.js. See 
http://web2py.com/books/default/chapter/29/12/components-and-plugins#markmin_client_server_coms.

Anthony

On Wednesday, November 9, 2016 at 4:54:11 PM UTC-5, marco mansilla wrote:
>
> Would please provide minimal examples?... for some reason in controller:
>
> return "jQuery(('.modal').modal('hide'))"
>
> shows the line as text inside .modal-body.
>
> Thanks in advance.
>
> 2016-11-09 13:15 GMT-03:00 Anthony:
>
>> So, fixed it partially with web2py_component in the view, the web2py 
>>> component calls the form in the modal-body, and a few lines of js 
>>> toggle the modal, in this case the info is submited, but the modal 
>>> doesn't close and I would like to know if there's some way to catch the 
>>> web2py_component after de post event.
>>>
>>
>> In the controller that handles the form submission, you could use 
>> response.js to return some Javascript code, which will be evaluated by the 
>> browser when the response is received. Alternatively, you could just add 
>> your own event handler in the browser to react to the form submission.
>>
>> Anthony
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> -BEGIN GEEK CODE BLOCK-
> version 3.1
> GCS/GTW/| d? s+:+>+++ a-- C+++(+) UL>$ P++>+++ L+++>+$ E->+ W++>+ 
> N>+++ o K- w---() 
> O(--) M>-- V-- PS++ PE++>+ Y-->+ PGP+>+++ t-(?) 5? X++ R+ !tv b+++> 
> DI+++ D--- G+++>+ 
> e+++> h* r++>+++ y++ 
> --END GEEK CODE BLOCK--
>

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


Re: [web2py] Re: About web2py_component and redirect

2016-11-09 Thread Marco Mansilla
Would please provide minimal examples?... for some reason in controller:

return "jQuery(('.modal').modal('hide'))"

shows the line as text inside .modal-body.

Thanks in advance.

2016-11-09 13:15 GMT-03:00 Anthony :

> So, fixed it partially with web2py_component in the view, the web2py
>> component calls the form in the modal-body, and a few lines of js
>> toggle the modal, in this case the info is submited, but the modal
>> doesn't close and I would like to know if there's some way to catch the
>> web2py_component after de post event.
>>
>
> In the controller that handles the form submission, you could use
> response.js to return some Javascript code, which will be evaluated by the
> browser when the response is received. Alternatively, you could just add
> your own event handler in the browser to react to the form submission.
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-BEGIN GEEK CODE BLOCK-
version 3.1
GCS/GTW/| d? s+:+>+++ a-- C+++(+) UL>$ P++>+++ L+++>+$ E->+ W++>+
N>+++ o K- w---()
O(--) M>-- V-- PS++ PE++>+ Y-->+ PGP+>+++ t-(?) 5? X++ R+ !tv b+++>
DI+++ D--- G+++>+
e+++> h* r++>+++ y++
--END GEEK CODE BLOCK--

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


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-09 Thread Leonel Câmara
What do you mean? What are you trying to do? How are you putting the json 
there? Are you getting it using $.getJSON or something like that?

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


[web2py] I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-09 Thread Mike Stephenson
I have totally messed up. Can you write the required snippet for me or 
share a helpful link?

Thanks for the same.

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


[web2py] Re: About web2py_component and redirect

2016-11-09 Thread Anthony

>
> So, fixed it partially with web2py_component in the view, the web2py 
> component calls the form in the modal-body, and a few lines of js 
> toggle the modal, in this case the info is submited, but the modal 
> doesn't close and I would like to know if there's some way to catch the 
> web2py_component after de post event.
>

In the controller that handles the form submission, you could use 
response.js to return some Javascript code, which will be evaluated by the 
browser when the response is received. Alternatively, you could just add 
your own event handler in the browser to react to the form submission.

Anthony

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


Re: [web2py] Re: form error: duplicate field in table no_table

2016-11-09 Thread Alex Glaros
got it.  Thanks 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/d/optout.


Re: [web2py] Unit Testing in PyCharm

2016-11-09 Thread Richard Vézina
Not exactly what you want but it could help you understand testing with
web2py :

https://github.com/viniciusban/web2py.test

https://github.com/niphlod/welcome_augmented

New initiative here :
https://groups.google.com/d/msg/web2py/hcsHgJiFEwc/apeBhnf0AgAJ

Good read!

RIchard


On Thu, Nov 3, 2016 at 4:56 PM, 'Roman' via web2py-users <
web2py@googlegroups.com> wrote:

> Hi people.
>
> Short question: is there a way to run unit tests for my web2py controllers
> from PyCharm?
>
> I am running the latest web2py with version:  2.14.6-stable
>
> What i found out so far:
>
> There is an approach to run unit tests from command line. Following this
> blogpost: http://web2py.com/AlterEgo/default/show/260 i am able to run a
> unit test for my controller. BUT just for convinience i want to let my IDE
> manage those tests (i.e. start them and show me the results in a PyCharming
> way).
>
> To let PyCharm run a unit test, you have to create a new run/debug
> configuration, you have to enter the location of a unit test script, to run
> it directly. PyCharm does some thing with "utrunner.py" (unit_test_runner?).
> I tried to give the run/debug configuration the path to web2py.py and as
> parameter the "--shell= --import_models --run=my_script.py" thing.
> But unfortunately the "utrunner.py" needs well formatted unit test scripts.
>
> Prior to the mentioned blogpost, there was another approach to run unit
> tests for web2py controllers: http://www.web2py
> .com/AlterEgo/default/show/213
> Unfortunately, as mentioned in the other post, going that way, my
> controller action is not able to see the db :-(
>
> Fazit:
> Does anybody know a way how to run unit tests for my web2py controllers
> from PyCharm?
> Or
> Does anybody know how to run a unit test for my web2py controllers
> directly from command line (without web2py.py) and how can i pass a DAL
> object to the environment of my controller?
>
> Many thanks in advance and greetings from Berlin
>
> Roman
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: form error: duplicate field in table no_table

2016-11-09 Thread Richard Vézina
You can manipulate the field name, you can handle the insert/update by
yourself instead of using _filter_fields(), to do so you can create cutstom
fields with Field() or .clone() field (better)...

But the way you make it, if the resulting form satisfy you, you may
consider changing FK name from table to table (not the best option if your
db is used by other application or if you follow strong convention field
name), but it would be the simpler way to fix that. You may check it you
not include field that causing error with readble, writable = False and you
copy/populate the "missing" FK field ID in a onvalidation function.

How to solve this is a matter of choice...

Would need to understand what you want to achieve to help more,
"SuperObject" is abstract for me...

Richard

On Fri, Nov 4, 2016 at 12:54 PM, Alex Glaros  wrote:

> just re-read documentation for factory which says: This only works when
> the tables don't have field names in common.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Copy and insert a row in a database

2016-11-09 Thread Simon Andersson

On Tuesday, 8 November 2016 17:54:48 UTC, Anthony wrote:
>
>
> The second argument to .store() should be the original filename (which 
> will then be encoded again), not a full file path. To get the original 
> filename, use the .retrieve() method instead of manually constructing the 
> file path and opening the file:
>
> filename, stream = db.name.file.retrieve(a.file)
> db.name.insert(..., file=db.name.file.store(stream, filename))
>
> Also, your use of a.file implies the upload field is named "file", but in 
> your insert code, you use "file_up" -- not sure which is correct.
>
> Anthony
>

 Thanks this is exactly what I was after! 

(I had edited the original code down to something more readable so it 
should have been consistent as "file")

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