[web2py] Re: LOAD in py4web

2020-02-25 Thread RHC
Just to confirm, will that call to foo(0 return the html generated using 
that function and it's template?

My view on the various follow up questions about LOAD is that we should use 
existing frameworks where possible rather than complicating py4web. The 
appeal of py4web is that it has less of it's own javascript which in web2py 
was awkward to work around if it didn't work the way you needed it to.

On Monday, February 24, 2020 at 12:02:01 AM UTC, Val K wrote:
>
> for server side you can
> @action("foo")
> @action.uses("foo.html")
> def foo():
> return dict(...)
>
> @action("bar")
> @action.uses("bar.html")
> def bar():
> return dict(foo_content = foo())
>
> # bar.html
> [[=XML(foo_content)]]
>
>
> for the client side, I suppose, you have to do it by yourself using pure 
> js or some lib (JQuery, axios, Vue.js ... )
>
>
>
> On Sunday, February 23, 2020 at 9:18:51 PM UTC+3, RHC wrote:
>>
>> HI,
>>
>> I am beginning to experiment with py4web, I like the sound of it and I am 
>> looking to convert a web2py project to py4web to see how they compare.
>>
>> It appears that the LOAD (helper?) that was available in web2py templates 
>> is not available in py4web. I was using this to populate part of a web 
>> page, I liked the way you had the option to use LOAD to call a separate URL 
>> (within the same app) and insert the result into your page before returning 
>> the page to the client.
>>
>> What is the reason for the absence of LOAD in py4web? is there a 
>> recommended alternative method of achieving the same effect? I have used a 
>> mixture of ajax=True and ajax=False options for this feature.
>>
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8ffd5a19-8ad7-4d88-971b-91d1c07b0231%40googlegroups.com.


[web2py] py4web URL helper documentation missing?

2020-02-23 Thread RHC
HI,

Looking at the py4web documentation at 
http://py4web.com/_documentation/static/index.html#chapter-08 I see the 
following where I expected to find details of the URL helper.

URL

The URL helper is documented in [[Chapter 4 URL ../04#URL]]

I go to Chapter 4: 
http://py4web.com/_documentation/static/index.html#chapter-04


but the documentation isn't in there either. I needed to look it up as args 
is reported to be an unexpected keyword (web2py used args judging by some 
of my old code, but py4web uses vars instead it seems by looking at the 
py4web source code).


Regards,


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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f1bd171c-5825-459e-8fbf-6c484bf40858%40googlegroups.com.


[web2py] LOAD in py4web

2020-02-23 Thread RHC
HI,

I am beginning to experiment with py4web, I like the sound of it and I am 
looking to convert a web2py project to py4web to see how they compare.

It appears that the LOAD (helper?) that was available in web2py templates 
is not available in py4web. I was using this to populate part of a web 
page, I liked the way you had the option to use LOAD to call a separate URL 
(within the same app) and insert the result into your page before returning 
the page to the client.

What is the reason for the absence of LOAD in py4web? is there a 
recommended alternative method of achieving the same effect? I have used a 
mixture of ajax=True and ajax=False options for this feature.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b2481e63-3a6f-4206-b1ca-7adc62487fa9%40googlegroups.com.


[web2py] Re: User Registration Form POSTed to Application Root

2014-05-30 Thread RHC
Well your response prompted me to check the nginx logs which confirm it was 
going straight to /CMS, no redirect. I then switched to a minimal 
layout.html file as that was the one component that was still not a default 
file. This then registered a user okay. When I went through the original 
head section to start adding stuff in I found this line:

base href={{='/%s/' % request.application if URL().startswith('/' + 
request.application) else '/'}}/

Adding this to the minimal layout.html broke the user registration again, 
presumably because the form was taking the new base of /CMS/ as its target 
for POSTing data. I confirmed the base href was /CMS/ by inspecting the 
head element. I can't figure out why this didn't cause a problem in my 
original web2py 2.0.9 installation of this app though, the user register 
page on there also has the base element with href set to /CMS/ on the user 
registration page, yet user registration isn't broken there. I could 
understand a different browser handling the interaction between BASE and 
FORM elements differently, but I don't see why a different server would.

I found this article on stack overflow about 
base: 
http://stackoverflow.com/questions/1889076/is-it-recommended-to-use-the-base-html-tag
 
and decided I should avoid using the base anyway. I now just have to figure 
out why I used it in the first place (find out what breaks when I take it 
out) and find a better solution. I understand web2py much better now, so 
I'm sure I'll find a better way.

Thanks for taking the time to look at my post, and confirming that the 
browser should normally post to the original URL.





-- 
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] User Registration Form POSTed to Application Root

2014-05-29 Thread RHC
I have a strange problem with an application I have copied from an old 
web2py 2.0.9 installation to another machine running web2py 2.9.5

When I try and register a new user using the standard user function, the 
register button POSTS to the application root /CMS/#, instead of the 
/CMS/default/user/register which is the URL the form is loaded from.

I have the default user method defined in the default.py controller:

def user():

exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control

return dict(form=auth())

I have renamed my user.html to xuser.html to force web2py to use the 
generic.html view. I have switched off javascript in Firefox to rule out 
anything odd going on in some javascript somewhere. I have checked the form 
HTML, there is no separate URL defined anywhere in the form HTML to send 
the POST request anywhere other than the same URL that the form is loaded 
from. I have copied the web2py_ajax.html, web2py.js and jquery.js from the 
new web2py install into my application folder in case out of date code in 
these is causing any problems. A new test application in the web2py 2.9.5 
installation works fine for user registration.

Yet every time I click on the register button the form is submitted to 
/CMS/#, this I have checked using Firefox developer tools (Network tab). I 
can see the parameters I enter to the form are being submitted (using the 
view POST Params feature in Firefox developer tools). 

I am completely out of ideas, and cannot think of any reason the POST does 
not get sent to the originating URL. Does anyone have any suggestions?

If it is of any relevance Web2py is running on ubuntu with an nginx web 
server, the same for both 2.0.9 and 2.9.5 installations.

-- 
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: User Registration Form POSTed to Application Root

2014-05-29 Thread RHC
Yes, that's right. And after the form submission the address bar says 
http://www.yourdomain.com/CMS/ 
http://www.google.com/url?q=http%3A%2F%2Fwww.yourdomain.com%2FCMS%2Fdefault%2Fuser%2Fregistersa=Dsntz=1usg=AFQjCNHsw-UKYhz6n9Cfl7FrNNETgfldTA
#. 

I should add, that the user does not get registered as they should be. On a 
working test application, where the user is registered successfully, the 
address bar is still showing the original url and a blank user registration 
form (the _next parameter is not supplied during my tests) after 
registration.

On Thursday, May 29, 2014 11:15:38 PM UTC+1, Anthony wrote:

 So, the address bar in the browser says 
 http://www.yourdomain.com/CMS/default/user/register 
 http://www.google.com/url?q=http%3A%2F%2Fwww.yourdomain.com%2FCMS%2Fdefault%2Fuser%2Fregistersa=Dsntz=1usg=AFQjCNHsw-UKYhz6n9Cfl7FrNNETgfldTA,
  
 and the form has action=#?

 On Thursday, May 29, 2014 5:24:13 PM UTC-4, RHC wrote:

 I have a strange problem with an application I have copied from an old 
 web2py 2.0.9 installation to another machine running web2py 2.9.5

 When I try and register a new user using the standard user function, the 
 register button POSTS to the application root /CMS/#, instead of the 
 /CMS/default/user/register which is the URL the form is loaded from.

 I have the default user method defined in the default.py controller:

 def user():
 
 exposes:
 http:///[app]/default/user/login
 http:///[app]/default/user/logout
 http:///[app]/default/user/register
 http:///[app]/default/user/profile
 http:///[app]/default/user/retrieve_password
 http:///[app]/default/user/change_password
 use @auth.requires_login()
 @auth.requires_membership('group name')
 @auth.requires_permission('read','table name',record_id)
 to decorate functions that need access control
 
 return dict(form=auth())

 I have renamed my user.html to xuser.html to force web2py to use the 
 generic.html view. I have switched off javascript in Firefox to rule out 
 anything odd going on in some javascript somewhere. I have checked the form 
 HTML, there is no separate URL defined anywhere in the form HTML to send 
 the POST request anywhere other than the same URL that the form is loaded 
 from. I have copied the web2py_ajax.html, web2py.js and jquery.js from the 
 new web2py install into my application folder in case out of date code in 
 these is causing any problems. A new test application in the web2py 2.9.5 
 installation works fine for user registration.

 Yet every time I click on the register button the form is submitted to 
 /CMS/#, this I have checked using Firefox developer tools (Network tab). I 
 can see the parameters I enter to the form are being submitted (using the 
 view POST Params feature in Firefox developer tools). 

 I am completely out of ideas, and cannot think of any reason the POST 
 does not get sent to the originating URL. Does anyone have any suggestions?

 If it is of any relevance Web2py is running on ubuntu with an nginx web 
 server, the same for both 2.0.9 and 2.9.5 installations.



-- 
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: response.files.append in component plugin

2013-07-01 Thread RHC
Thanks for pointing out that the script won't get cached. I'd better sort 
that out :-)

I didn't know about that modernizr feature, useful to know how it works and 
what it's for, but that is for another time I think. I will probably skip 
the modernizr stuff in this component, I use jquery all the time but not 
modernizr. Admittedly the small amount of code I use here could be done 
without jquery as well, but I'm not inclined to try to avoid jquery so much.

-- 

--- 
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: response.files.append in component plugin

2013-06-27 Thread RHC
Thanks for your response Anthony and Niphlod.

For the record I went with dynamically loading css and javascript as 
follows:

/* Load required css dynamically */
function loadcss(path) {  
if (document.createStyleSheet) {/* check if need to use an IE 
compatible method */
document.createStyleSheet(path)  /* use IE method */
} else {
$(head).append($('link rel=stylesheet href=' + path + ' 
type=text/css /'))
}
}

and for javascript

$.getScript({{=URL('static','plugin_spectrum/spectrum/spectrum.js')}}, 
function() { 
   /* Some code here to run after script loaded */
})

-- 

--- 
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] response.files.append in component plugin

2013-06-25 Thread RHC
I am trying to create a component plugin. I would like to add in some 
javascript and css files from the plugin with as little editing as possible.

I have a view.load file as part of the plugin and I tried to add something 
like this to the top of this view file:

{{
response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.css'))
response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.js'))
response.files.append(URL('static','plugin_spectrum/plugin.js'))
}}

However, these files are not being loaded. I would like to make it as easy 
to add the component into a web page as possible using a {{=LOAD()}} 
command in the relevant views. It seems a bit cumbersome to have to add 
these into the relevant layout.html as well as in the specific views.

Is what I am trying to do possible? If not, is there another way to load up 
the associated files along with the plugin automatically wherever the 
component is loaded into the view?

Thanks,

Richard.

-- 

--- 
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: response.files.append in component plugin

2013-06-25 Thread RHC
Niphlod,

Thanks, I wasn't aware of these other ways to append these files. That's 
certainly useful to know.

Richard.


On Tuesday, June 25, 2013 9:16:35 PM UTC+1, Niphlod wrote:

 response.files gets only called inside web2py_ajax.html, that is evaluated 
 only when you load the layout.html

 in HTML, all static assets must be in the head to be sure all are loaded 
 when you try to execute some code. 

 If you need to include a js file and you're sure all the dependencies are 
 fullfilled (btw, it's not that easy.if you include a plugin that 
 depends on jquery, you need to be sure that jquery is already loaded  
 have fun with it) you can use the usual script src= directive within your 
 .load view.

 ATM there's no facility to inject just the files you need within 
 web2py: you should code your own loader, or use a third-party loader.

 PS: you can use a model for your plugin that does response.files.append() 
 to be sure that all pages will have loaded all the files you want. The only 
 drawback is that those files will be loaded even if your fragment doesn't 
 get actually inserted within a LOAD() statement. 
 If you're not facing something that needs to load 300KB of different 
 assets for every different fragment, it's not as bad as it sounds. Given 
 that usually you enable client-side cache for all the /static/ files, they 
 get actually transmitted once. 

 On Tuesday, June 25, 2013 9:24:35 PM UTC+2, RHC wrote:

 I am trying to create a component plugin. I would like to add in some 
 javascript and css files from the plugin with as little editing as possible.

 I have a view.load file as part of the plugin and I tried to add 
 something like this to the top of this view file:

 {{

 response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.css'))

 response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.js'))
 response.files.append(URL('static','plugin_spectrum/plugin.js'))
 }}

 However, these files are not being loaded. I would like to make it as 
 easy to add the component into a web page as possible using a 
 {{=LOAD()}} command in the relevant views. It seems a bit cumbersome to 
 have to add these into the relevant layout.html as well as in the specific 
 views.

 Is what I am trying to do possible? If not, is there another way to load 
 up the associated files along with the plugin automatically wherever the 
 component is loaded into the view?

 Thanks,

 Richard.



-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-25 Thread RHC
Thanks to all of you for your suggestions. I'm not sure which way I'll 
tackle this, but I have a good understanding now of what my options are to 
tweak the SQLFORM feature. Your help is much appreciated.

-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-22 Thread RHC
Thanks for that Alan. Yes I realise that the server creates the form for 
the clientapi, my wording was not very good.

The as_json() and as_dict() methods looks useful, but still generates the 
HTML component for the various inputs which I would then have to pull the 
relevant information out of. It occurs to me that I could create a custom 
widget for the various fields which might be the way forward for me. I am 
unsure how this affects validation though. I have looked in the 
gluon/validators.py but I have not been able to follow how the form object 
is used to process the returned variables. I got as far as seeing a 
traverse method being called but didn't see how that called the individual 
validation methods.

Also, is it possible to override the widget methods in SQLFORM rather than 
define custom widgets and have to then assign these widgets to every field 
in the models?

-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-20 Thread RHC
Thanks for that link to the web3py code, that looks much neater, but I 
guess not all the functionality is there yet which might help. It looks 
like the From initialisation and process methods skip the HTML generation 
completely and the various style_x methods create the HTML version as 
per the various needs, is that correct?

I guess web3py is in it's early stages yet, but from what I've read about 
it it looks like a good step forward. What is the expected timescale for 
web3py being ready for general use? I guess I shouldn't expect a stable 
release in the next year or so.

What is the plan for getting to a stable release of web3py? Would it begin 
as a limited feature set compared to web2py and then get more complete over 
time or would it wait until it is more or less complete before it would be 
considered stable and ready for general use? As I am only just beginning to 
seriously use web2py I should probably be keeping an eye on web3py as I 
won't have much in the way of legacy systems to adapt. Also I probably 
don't use a very extensive range of web2py features at the moment either.


-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-19 Thread RHC
Thinking about this some more, what I would like would be for a controller 
to generate this json:

{ form: 
{ fields: 
[ {name: 'id', type: 'int', value: 234, error: '', comment: ''},
  {name: 'title', type: 'string', length: 100, value: 'My Test 
Record', error: '', comment: ''},
  {name: 'start_date', type: 'date', value: '2013-11-15', error: 
'', comment: ''},
  {name: 'end_date', type: 'date'}, value: '2013-12-20', error: '', 
comment: ''}
  {name: 'type', type: int, value: 2, error: '', comment: '',
   select: [{id: 1, string: 'Type One'},{id: 2, string: 'Type 
Two'}]}
]},
  meta:
{ _formkey: '4237yad87fw75398yt39y',
  _formname: 'myform',
  ... }
}

Then the client side framework (be it Angular or whatever else) could use 
this to generate the form interface however it wishes. When the end user 
then submits the data the client side framework POSTs the same JSON data 
back to the controller which will validate the record and return the JSON 
back reporting whether the submit was successful and populating the error 
parameter if any fields failed the validation.

plugin-clientapi is a bit different from what I am aiming to do as far as I 
can tell. I stand corrected in that it does not just use web2py as a 
database back end. It seems it basically allows you to do some stuff, such 
as creating a form from javascript on the client side, which would normally 
be done in a web2py controller. My aims are different; I would like the 
web2py controller to keep control over what forms and data are presented to 
the client, but give the client side framework control over how that form 
and data is presented.

Looking at the SQLFORM, FORM and the process/validate methods it seems to 
me that the HTML generation and form generation and validation are bound 
too closely together for the MVC approach. As a result it is difficult to 
customise the way a form gets presented on the client, as the DOM structure 
is already generated by the SQLFORM class within the controller. I find 
myself using {{=form.custom.widget.blahblah}} a lot in my views to take 
back control of the forms appearance and function. Exploring the idea of 
generating the view using a client side framework has highlighted for me 
that with SQLFORM the controller is doing stuff that the view should be 
doing.

I would have thought a better approach would be for SQLFORM to create an 
object with the structure similar to what I outlined above (plus a lot of 
stuff I have probably missed out) and then in the view you use a method to 
generate the HTML (e.g. {{=form.asHTML()}}). The object would have all the 
details needed to generate HTML, XML, or JSON along with the clever methods 
to validate, insert, or update the form and CSRF prevention which would 
remain in the controller as I would expect in a MVC approach. We could then 
create our own custom methods to generate the HTML as we wish or even use 
the view templates to generate the HTML in a more long winded but 
customisable fashion.



-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-18 Thread RHC
Thanks for the responses, a number of useful pointers there.

I have had a look at the sqlhtml.py and html.py to see if I can adapt one 
of these to effectively produce a json version of a form which can be 
validated when it is submitted. I came to the conclusion that I didn't 
understand enough of what was going on in these to adapt them. Also, I 
don't need a lot of the stuff done in these. So maybe I should create my 
own methods

I have narrowed down the functionality I want to the following:
- CSRF and double submit prevention.
- prevent changes to records changed since form download
- Validation of the fields, followed by an insert, update, or delete. Or 
return of field specific errors if validation fails.

I can see how the CSRF and double submit is prevented, and preventing the 
update of a record that has changed. However, I have not found where the 
methods web2py uses to validate each field and generate select lists etc. 
Can anyone point me to where these are so I can re-use these?

I would like to be able to send an array of multiple records to the client 
along with some basic model information such as data types and selection 
items, then the client would allow the editing of any of the items using a 
generic form and then submit data for all modified, deleted, or new items.

I might take another look at the plugin_clientapi, but that looks to me 
like it is aimed at using web2py just as as a database backend. I would 
like to keep the control within web2py but use angular to keep the client 
side code more concise.

-- 

--- 
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] Alternative to SQLFORM for Angular

2013-04-17 Thread RHC
I have recently been exploring the possibilities of AngularJS and so far it 
looks like a great framework for interactive forms and general data editing.

I would love to use it with web2py as I love the way web2py works and much 
prefer python to javascript :-)

My main concern is that web2py's form validation and security features are 
really useful but would clash with the angular way of doing things. It 
seems to me that the way to get the two working together would be to create 
an alternative to FORM/SQLFORM/CRUD that instead of generating HTML would 
generate a json object containing all the field details and data for 
angular to then use to build the form or whatever interface is required.

I would like to have a go at this but I know a lot gets done behind the 
scenes to generate forms and then validate the forms and generate error 
messages where validation fails. I don't want to try and recreate all these 
features from scratch so I'm thinking that maybe it is possible to reuse 
various methods and functions already used by the current form methods to 
do the same thing but generate json instead of HTML. What I would like to 
do is to be able to send a set of data (or a blank template) to the client 
using json and then have this data all posted back to web2py as json and 
have web2py validate this data and update/insert the relevant records.This 
data could be a single record, or a record and many linked records from 
another table.

Does this sound feasible to those who know a bit more about how all these 
form methods work behind the scenes? Can anyone give me a few pointers? 
Even better has anyone already tackled this challenge who can share their 
work? It seems to me that this kind of feature could be very useful for the 
growing number of javascript front end frameworks available.

Thanks.

-- 

--- 
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: Bootstrap btn class in ajax components

2013-03-04 Thread RHC
Thanks Anthony, that's very useful to know. 

I'll have a look and try the simplest option :-). I'll have to update 
web2py first so I'm not tinkering with old code to start with. I'll post my 
code in one of those places if it works as expected.

On Saturday, March 2, 2013 12:59:45 AM UTC, Anthony wrote:

 I have had a little look through the web2py source on github and it seems 
 to me it would be more consistent for components if a function was called 
 here: 
 https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py.js#L120that
  re-ran the same code found in web2py_bootstrap.js. Possibly this 
 function could act just on the loaded/reloaded content.


 web2py_bootstrap.js is specific to the scaffolding app, whereas web2py.js 
 is more general, so I don't think we should include 
 Bootstrap/scaffold-specific code in web2py.js. However, something like this 
 in web2py_bootstrap.js might do the trick:

 jQuery(document).ajaxSuccess(function() {
   jQuery('button, form input[type=submit], form input[type=button]').
 addClass('btn');
 });

 That will add the 'btn' class every time an Ajax request completes (so it 
 will work even work for Ajax requests that are not for components).

 If for some reason we want to be more targeted and only run this for 
 components, we could have web2py_ajax_page() use .trigger() to trigger a 
 custom event, and web2py_bootstrap.js could define a handler for that event 
 using .on(). I suppose it could be useful more generally to have a custom 
 event fire every time a component loads/re-loads.
  

 Incidentally how would I go about submitting or requesting a change like 
 this if I did give it a go?


 You can always post on the developers list. Another option is to submit 
 an issue https://code.google.com/p/web2py/issues/list along with your 
 proposed change.

 Anthony


-- 

--- 
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: Bootstrap btn class in ajax components

2013-03-01 Thread RHC
Thanks. It certainly looks like that code makes the change I'm thinking of. 
However, I don't have a web2py_bootstrap.js in my application's static 
folder. I am a few versions behind the latest, so maybe this file is a 
recent addition, and another script used to perform this function in older 
versions? I can't check what web2py version I'm running right now, but will 
check later and post another update,

On Friday, 1 March 2013 08:42:05 UTC, Niphlod wrote:

 it's pobably due to this


 https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py_bootstrap.js#L27

 On Thursday, February 28, 2013 11:29:19 PM UTC+1, Anthony wrote:

 Please show some code.

 On Thursday, February 28, 2013 5:15:06 PM UTC-5, RHC wrote:

 I have a view which consists of several web2py compnents. I load these 
 components initially using the ajax=False option so they get loaded in with 
 the rest of the page, they then get reloaded via an ajax trapped submit 
 button within that component. The only problem is that the buttons start 
 off as bootstrap styled buttons (using the .btn class as far as I can see), 
 but the reloaded component then has normal styled buttons which are missing 
 the .btn class.

 I have not been able to find out what process adds the .btn class to 
 these button so I can ensure the reloaded component ends up with the same 
 class and styling. Does anyone have any idea how and when the .btn class 
 gets added and the best way to re-run this process for an ajax reloaded 
 component?



-- 

--- 
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: Bootstrap btn class in ajax components

2013-03-01 Thread RHC
I am running web2py 2.0.9 and this code is in the layout.html file in this 
version.

I am wondering what the best way to ensure dynamically loaded or reloaded 
components get the same styling as the rest of the page. I don't want to 
add my own hack to my pages, becuase if web2py changes what it does my 
stuff will then be doing something different or not work.

I have had a little look through the web2py source on github and it seems 
to me it would be more consistent for components if a function was called 
here: 
https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py.js#L120
 
that re-ran the same code found in web2py_bootstrap.js. Possibly this 
function could act just on the loaded/reloaded content.

Does this sound a reasonable change? I'd consider making this change 
myself, but I'm not sure enough of what goes on here to start messing 
around and submitting any changes. Incidentally how would I go about 
submitting or requesting a change like this if I did give it a go?


On Friday, 1 March 2013 11:32:26 UTC, RHC wrote:

 Thanks. It certainly looks like that code makes the change I'm thinking 
 of. However, I don't have a web2py_bootstrap.js in my application's static 
 folder. I am a few versions behind the latest, so maybe this file is a 
 recent addition, and another script used to perform this function in older 
 versions? I can't check what web2py version I'm running right now, but will 
 check later and post another update,

 On Friday, 1 March 2013 08:42:05 UTC, Niphlod wrote:

 it's pobably due to this


 https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py_bootstrap.js#L27

 On Thursday, February 28, 2013 11:29:19 PM UTC+1, Anthony wrote:

 Please show some code.

 On Thursday, February 28, 2013 5:15:06 PM UTC-5, RHC wrote:

 I have a view which consists of several web2py compnents. I load these 
 components initially using the ajax=False option so they get loaded in 
 with 
 the rest of the page, they then get reloaded via an ajax trapped submit 
 button within that component. The only problem is that the buttons start 
 off as bootstrap styled buttons (using the .btn class as far as I can 
 see), 
 but the reloaded component then has normal styled buttons which are 
 missing 
 the .btn class.

 I have not been able to find out what process adds the .btn class to 
 these button so I can ensure the reloaded component ends up with the same 
 class and styling. Does anyone have any idea how and when the .btn class 
 gets added and the best way to re-run this process for an ajax reloaded 
 component?



-- 

--- 
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: URL Helper and application root

2013-02-28 Thread RHC
If I use {{=URL(request.application)}} in the view I get

/Test/default/Test

It has added on the current application and controller path.

I would like to get just /Test/ or, if I have used routes.py to set the 
default application to Test, maybe just /. This is why I am trying to use 
the URL helper rather than just generate the string using 
request.application on it's own.

On Wednesday, 27 February 2013 21:32:48 UTC, Niphlod wrote:

 ehm ... request.application !

 On Wednesday, February 27, 2013 10:26:51 PM UTC+1, RHC wrote:

 I'm trying to use javascript to automatically insert a link to a plugin 
 web page within an application. However, the javascript, being a static 
 file, has no way of generating a valid URL in the proper web2py fashion 
 using a URL helper.

 I thought perhaps I could use the base element to re-define the root of 
 the application using the URL helper. Then my javascript could then just 
 insert a link to /plugin_myplugin/index.html for example.

 For example in the layout.html I was hoping to use

 base href={{=URL(...)}/

 Hoiwever, I am stuck for a way to get the URL helper just to create a url 
 path to the application itself. e.g. /myapp/

 I want to use the URL helper so that if I start customising the routes.py 
 then the generated url will still be valid.

 Any ideas? Is this even possible, if not is there another way to approach 
 this?

 Thanks,

 Richard.



-- 

--- 
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: URL Helper and application root

2013-02-28 Thread RHC
Niphlod, Antony: Thanks for your prompt replies. 

I can see that request.application will function correctly as web2py will 
still handle a URL beginning with the application name even if I have used 
routes.py to default to this application, Doing it this way does mean that 
I would end up with the application name in some of my URLs, and if I use 
the html base element approach then URLs all over the place would end up 
getting the application name in them. This seems to negate the benefit of 
using routes to hide the application name, except for the initial request 
to the domain name, which is unfortunate. I was hoping to keep that 
benefit, but I think I will have to manage without it.

On Thursday, 28 February 2013 16:42:53 UTC, Anthony wrote:

 No, just do:

 {{='/%s/' % request.application}}

 Anthony

 On Thursday, February 28, 2013 11:30:53 AM UTC-5, RHC wrote:

 If I use {{=URL(request.application)}} in the view I get

 /Test/default/Test

 It has added on the current application and controller path.

 I would like to get just /Test/ or, if I have used routes.py to set the 
 default application to Test, maybe just /. This is why I am trying to use 
 the URL helper rather than just generate the string using 
 request.application on it's own.

 On Wednesday, 27 February 2013 21:32:48 UTC, Niphlod wrote:

 ehm ... request.application !

 On Wednesday, February 27, 2013 10:26:51 PM UTC+1, RHC wrote:

 I'm trying to use javascript to automatically insert a link to a plugin 
 web page within an application. However, the javascript, being a static 
 file, has no way of generating a valid URL in the proper web2py fashion 
 using a URL helper.

 I thought perhaps I could use the base element to re-define the root of 
 the application using the URL helper. Then my javascript could then just 
 insert a link to /plugin_myplugin/index.html for example.

 For example in the layout.html I was hoping to use

 base href={{=URL(...)}/

 Hoiwever, I am stuck for a way to get the URL helper just to create a 
 url path to the application itself. e.g. /myapp/

 I want to use the URL helper so that if I start customising the 
 routes.py then the generated url will still be valid.

 Any ideas? Is this even possible, if not is there another way to 
 approach this?

 Thanks,

 Richard.



-- 

--- 
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: URL Helper and application root

2013-02-28 Thread RHC
Ah, that looks like it would do what I need. Thanks!

On Thursday, February 28, 2013 7:43:35 PM UTC, Anthony wrote:

 {{='/%s/' % request.application if URL().startswith('/' + request.
 application) else '/'}}

 Anthony

 On Thursday, February 28, 2013 12:26:32 PM UTC-5, RHC wrote:

 Niphlod, Antony: Thanks for your prompt replies. 

 I can see that request.application will function correctly as web2py will 
 still handle a URL beginning with the application name even if I have used 
 routes.py to default to this application, Doing it this way does mean that 
 I would end up with the application name in some of my URLs, and if I use 
 the html base element approach then URLs all over the place would end up 
 getting the application name in them. This seems to negate the benefit of 
 using routes to hide the application name, except for the initial request 
 to the domain name, which is unfortunate. I was hoping to keep that 
 benefit, but I think I will have to manage without it.

 On Thursday, 28 February 2013 16:42:53 UTC, Anthony wrote:

 No, just do:

 {{='/%s/' % request.application}}

 Anthony

 On Thursday, February 28, 2013 11:30:53 AM UTC-5, RHC wrote:

 If I use {{=URL(request.application)}} in the view I get

 /Test/default/Test

 It has added on the current application and controller path.

 I would like to get just /Test/ or, if I have used routes.py to set 
 the default application to Test, maybe just /. This is why I am trying 
 to 
 use the URL helper rather than just generate the string using 
 request.application on it's own.

 On Wednesday, 27 February 2013 21:32:48 UTC, Niphlod wrote:

 ehm ... request.application !

 On Wednesday, February 27, 2013 10:26:51 PM UTC+1, RHC wrote:

 I'm trying to use javascript to automatically insert a link to a 
 plugin web page within an application. However, the javascript, being a 
 static file, has no way of generating a valid URL in the proper web2py 
 fashion using a URL helper.

 I thought perhaps I could use the base element to re-define the root 
 of the application using the URL helper. Then my javascript could then 
 just 
 insert a link to /plugin_myplugin/index.html for example.

 For example in the layout.html I was hoping to use

 base href={{=URL(...)}/

 Hoiwever, I am stuck for a way to get the URL helper just to create a 
 url path to the application itself. e.g. /myapp/

 I want to use the URL helper so that if I start customising the 
 routes.py then the generated url will still be valid.

 Any ideas? Is this even possible, if not is there another way to 
 approach this?

 Thanks,

 Richard.



-- 

--- 
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] Bootstrap btn class in ajax components

2013-02-28 Thread RHC
I have a view which consists of several web2py compnents. I load these 
components initially using the ajax=False option so they get loaded in with 
the rest of the page, they then get reloaded via an ajax trapped submit 
button within that component. The only problem is that the buttons start 
off as bootstrap styled buttons (using the .btn class as far as I can see), 
but the reloaded component then has normal styled buttons which are missing 
the .btn class.

I have not been able to find out what process adds the .btn class to these 
button so I can ensure the reloaded component ends up with the same class 
and styling. Does anyone have any idea how and when the .btn class gets 
added and the best way to re-run this process for an ajax reloaded 
component?

-- 

--- 
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] URL Helper and application root

2013-02-27 Thread RHC
I'm trying to use javascript to automatically insert a link to a plugin web 
page within an application. However, the javascript, being a static file, 
has no way of generating a valid URL in the proper web2py fashion using a 
URL helper.

I thought perhaps I could use the base element to re-define the root of the 
application using the URL helper. Then my javascript could then just insert 
a link to /plugin_myplugin/index.html for example.

For example in the layout.html I was hoping to use

base href={{=URL(...)}/

Hoiwever, I am stuck for a way to get the URL helper just to create a url 
path to the application itself. e.g. /myapp/

I want to use the URL helper so that if I start customising the routes.py 
then the generated url will still be valid.

Any ideas? Is this even possible, if not is there another way to approach 
this?

Thanks,

Richard.

-- 

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