--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am a Web Developer for the web2py sites that I host because:
That's the best i can do at this time in expressing my desires.
Thanks, Richard, for the question.
Thanks to all for a GREAT Framework & Community.
Love and peace,
Joe
Dear Richard,
Regarding your comment, "I don't understand the dichotomy of your question?".
I have been thinking about it. Here's what i have come up with.
I am a Website Administrator for a WordPress site that I host because:
- I don't care to write/read/understand ANY WordPress/PHP code in supporting that site.
- I NEVER want to read any source code of the WordPress Implementation Layer because i don't want to understand the above
- I just want to "push the buttons" of the Admin Interface and get plugins that work.
I am a Web Developer for the web2py sites that I host because:
- I ALWAYS want to write/read/understand the Application Layer code for my site.
- I want to INFREQUENTLY have to read the source code of the Web2py Implementation Layer to understand the above, preferring instead to work from the Book.
- I want to "push the buttons" (install plugins and/or use wizards) thatgenerate Application Layer code that i can easily understand and that fits within the established norms of a well coded stand alone web2py app.
That's the best i can do at this time in expressing my desires.
Thanks, Richard, for the question.
Thanks to all for a GREAT Framework & Community.
Love and peace,
Joe
On Tuesday, January 27, 2015 at 11:03:29 AM UTC-8, Richard wrote:
--
I will try to think of more suggestions as they come to me.
Thanks again.
Love and peace,
Joe
Dear Leonel,
I agree that you can and should do both. For my web2py projects, I am BOTH Developer and Administrator, at least initially, before i hand it over to my user.
Regarding my suggestions to improve the help web2py gives me with the Administration Tasks for my users, my suggestion is to help me, as developer, customize the web2py Administrative capabilities for them. Possibly choosing from an easily understood menu of options of say registration/login types, etc..
Regarding my suggestions to improve the help web2py gives me with the Website Creation Tasks for me as a developer, I'd love, for example to have a Form Designer that would generate easily understandable/tweak-able web2py MVC code, to take the repeated drudgery out of form generation. I am thinking here, of the process i used to use in Microsoft Development. I would
- first, use the MS form designer to help me flesh out my user interface View, making sure to get user buy in,
- and then, hook that/those View(s) up with Model/Controller code for implementation.
Thanks to all for a GREAT discussion.
Love and peace,
Joe
On Friday, January 30, 2015 at 2:17:51 PM UTC-8, Leonel Câmara wrote:
For points 2.2 & 2.3, updates to the book have helped a lot. Still, the form is not specified in a View, at least as far as i can figure out.
Lastly, I want to mention 1 more suggestion/request for improving web2py support for web-devs:
Please find a process to keep the book updated with answers given by trusted members of the community (Massimo, etc.) given on this group (and other groups?).
There was significant effort on my part required to research this subject, which, in my estimation, could have been better spent on thinking about my user's requirements.
I consider the book the be web2py's Principles of Operation. I.e.it is the document that specifies the web2py Framework, describing each structure/object/function at the level of detail needed to prepare an Application Programmer to make apps. I borrowed/modified this definition of Principles of Operation, as an old IBMer, from "z/Architecture Principles of Operation".
Thanks again, Dave.Dear Dave,
Thanks for the reply. I partially agree. I agree that, "SQLFORM already takes a lot of the drudgery out of form" [now my words] generation from an existing table. However, for me, two things apply to SQLFORM:
- It breaks MVC, meaning if I want to customize the form I do it in a Model or in a Controller Action, not in a View. Maybe there's a way to do this in a View, but I don't know how. Here's a couple of my blog posts motivated by customizing SQLFORM:
- I find customization difficult:
- adding buttons
- specifying custom validation
- specifying custom widgets
For points 2.2 & 2.3, updates to the book have helped a lot. Still, the form is not specified in a View, at least as far as i can figure out.
Lastly, I want to mention 1 more suggestion/request for improving web2py support for web-devs:
Please find a process to keep the book updated with answers given by trusted members of the community (Massimo, etc.) given on this group (and other groups?).
My motivation for this request comes from the fact that within the last couple of weeks [Jan 2015], i decided to integrate a web2py app with Dropbox:
- I copied the code from the book-Other Recipes. I got an error for which Massimo said, on this group in 2012, "You need to install: https://github.com/enginous/python-dropbox". which i did.
- Then I got a subsequent error for which Massimo said, on this group again in 2012, "Typo in the book ...".
- There MAY have been other intervening errors of a similar nature.
There was significant effort on my part required to research this subject, which, in my estimation, could have been better spent on thinking about my user's requirements.
I consider the book the be web2py's Principles of Operation. I.e.it is the document that specifies the web2py Framework, describing each structure/object/function at the level of detail needed to prepare an Application Programmer to make apps. I borrowed/modified this definition, as an old IBMer, from "z/Architecture Principles of Operation".
Thanks again, Dave.
Thanks to all for the GREAT Community and Framework.
Love and peace,
Joe
On Monday, February 2, 2015 at 12:55:50 PM UTC-8, Dave S wrote:
--
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
Rather than speaking abstractly about "breaking MVC," it would be helpful to see code examples along with an explanation of why they are problematic and how they can be improved.
I believe one of the motivations behind MVC (or MTV if you prefer the Django/Flask terminology) is to de-couple independent functions so you can make changes in one place without worrying about other areas of the code. In web2py, when you define a model, you can also specify some field attributes that affect how the data are displayed in forms and grids (e.g., label, comment, represent, widget). However, moving these definitions to a controller or view (which web2py certainly allows) does not necessarily facilitate de-coupling. For example, if you add a field or change the name of a field in a model, you then have to add or change that field in the form or grid code in any relevant views as well. This actually makes things more complicated because you have to track down code in multiple places when you change the model.
The advantage of defining some of the display attributes along with the model definition is that everything related to a given model is in a single place and will therefore affect all forms/grids based on that model. If you need to override these defaults for a particular form or grid, you can easily do so within the controller or view. And if you need to a completely customized form, you can do so by writing a formstyle function, using form.custom, or with hand-coded HTML. With the latter two options, if you need to re-use the form code, you can put it in a template and "include" it where needed.
Anthony
On Wednesday, February 4, 2015 at 2:44:39 PM UTC-5, Carlos Cesar Caballero Díaz wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It also depends on how you choose to look at it. From my point of view the message for a label for a field is part of the model. The only difference is that you aren't putting it in a database (which you certainly could). The view should only be concerned with how to display the label not with the contents.So from my POV there is no breakage of MVC whatsoever with labels in fields.
>
>I find customization difficult:
>adding buttons
As you have python in views, you can manipulate server side DOM in your view, i.e add/remove class names, create id for elements, etc. Or you can make it through javascript. It's up to you.
I know it's not the best way, but it is what we can achieve today.
- I find customization difficult:
- adding buttons
- specifying custom validation
- specifying custom widgets
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In the very first web2py code example in the manual, in the image blog example, we find this code in the controller:
def index():
images = db().select(db.image.ALL, orderby=db.image.title)
return dict(images=images)
Accessing from controller to the dal, in a simple query could not be a problem, but, what happen with a more complex query? With a three or four lines of code query, if we write it every time that we need the data in controllers, we are breaking DRY and MVC. But let´s supouse that we have a simple query like that, and we are using it in many controllers, if in some moment we need to change it, we need to go function by function in controllers to fix the problem. I know that I can put it with a function in the model, but the manual is saying that in web2py, the query goes in the controller.
Another example is in the search function on the simple wiki:
def search():
"""an ajax wiki search page"""
return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup="ajax('callback', ['keyword'], 'target');")),
target_div=DIV(_id='target'))
Why create a form that not need any kind of postprocessing, even adding a onkeyup attribute, in the controller, when all this code, following MVC should go in the view?
In the very first web2py code example in the manual, in the image blog example, we find this code in the controller:
def index():
images = db().select(db.image.ALL, orderby=db.image.title)
return dict(images=images)
Accessing from controller to the dal, in a simple query could not be a problem, but, what happen with a more complex query? With a three or four lines of code query, if we write it every time that we need the data in controllers, we are breaking DRY and MVC. But let´s supouse that we have a simple query like that, and we are using it in many controllers, if in some moment we need to change it, we need to go function by function in controllers to fix the problem. I know that I can put it with a function in the model, but the manual is saying that in web2py, the query goes in the controller.
Does the book actually specifically recommend that all queries go in controllers? If so, can you point that out, as it should be changed.
Anyway, nothing about web2py requires you to put queries in controllers. If it is a single query used in a single action, then sure, put it in the controller. But if you re-use the same query in multiple places, of course you should move it to a model or module -- this is the recommended practice. web2py even allows you to define methods on database tables that execute common queries. I don't see anything wrong with the example above -- there would be no point to moving the query into a model file or module for such a simple example.
Another example is in the search function on the simple wiki:
def search():
"""an ajax wiki search page"""
return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup="ajax('callback', ['keyword'], 'target');")),
target_div=DIV(_id='target'))
Why create a form that not need any kind of postprocessing, even adding a onkeyup attribute, in the controller, when all this code, following MVC should go in the view?
I agree that could just as easily go in the view, but I don't see the harm in having it here. Because most forms do involve processing/validation, they are typically defined in controllers, so it makes sense to stick with that standard even when no processing is happening. It's odd to say that FORM(...).process() belongs in the controller but FORM(...) without the .process() must go in the view.
Also, keep in mind that the overview chapter is just a relatively simple introductory tutorial. It is not meant to communicate how one ought to architect a large and sophisticated application. I'm not saying we couldn't consider changing some of the code examples, but I don't see it as a major indictment of MVC violation.
Anthony--
{{=form.custom.end}}
</form>
You asked, "Can you share examples...?".
Here are links to a couple of app pages i remember finding difficult to achieve using my level of understanding of standard web2py techniques, for the version available at development time. To be sure web2py has improved since then.
..snip..
Another example is in the search function on the simple wiki:
def search():
"""an ajax wiki search page"""
return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup="ajax('callback', ['keyword'], 'target');")),
target_div=DIV(_id='target'))
Why create a form that not need any kind of postprocessing, even adding a onkeyup attribute, in the controller, when all this code, following MVC should go in the view?
I agree that could just as easily go in the view, but I don't see the harm in having it here. Because most forms do involve processing/validation, they are typically defined in controllers, so it makes sense to stick with that standard even when no processing is happening. It's odd to say that FORM(...).process() belongs in the controller but FORM(...) without the .process() must go in the view.
Also, keep in mind that the overview chapter is just a relatively simple introductory tutorial. It is not meant to communicate how one ought to architect a large complex application. I'm not saying we couldn't consider changing some of the code examples, but I don't see it as a major indictment of MVC violation.
Anthony
I personally do not use html helpers *at all*, but I can see why for some folks it can be a time saver.
Now the fact that one can use them in controllers does not mean one should do that.
form=FORM('Your name:', INPUT(_name='name'), INPUT(_type='submit'))
form=FORM(LABEL('Your name:', _for='name'), INPUT(_name='name', _class='form-control', _placeholder='Name Surname'), INPUT(_type='submit', _class='btn btn-primary'))
By definition, the model doesn't need the label to anything.
Take a webservice as an example, doesn't have a form to present. Does the model need it?
> Does the book actually specifically recommend that all queries go in
> controllers? If so, can you point that out, as it should be changed.
>
No, but in all examples, queries are in controllers, sufficient for a
reader to infer that.
> I agree that could just as easily go in the view, but I don't see the
> harm in having it here.
Because it confuses the designers, who on many occasions not know python
or web2py, this makes a big difference when you are working alone, but
complicated when a third party needs to make changes
--
Can you point to an example of a query in the book that you think should instead have been shown in a model?
Of course, if you are working with designers who don't know and are not interested in learning Python, it makes sense to keep as much as possible in pure HTML. But that is not the only context within which web2py is used. If you don't want to use the HTML helpers, you don't have to, but that doesn't mean they should not appear in any book examples.
Can you point to an example of a query in the book that you think should instead have been shown in a model?
All of them, or at least mention that queries should go in controllers, even a simple query, will represent a problem, if we need to change it and is used many times, new users, that read the image blog and simple wiki examples, should explicitly known that in web2py, the recommended way is putting the queries in models (or modules), all this in my opinion of course.
Of course, if you are working with designers who don't know and are not interested in learning Python, it makes sense to keep as much as possible in pure HTML. But that is not the only context within which web2py is used. If you don't want to use the HTML helpers, you don't have to, but that doesn't mean they should not appear in any book examples.
We are moving away a bit from the main point, imagine that I made an application and my designer is learning how web2py views work and how helpers are used (which is exactly what is happening to me now), my designer does not have to look at the controllers, that is the goal of MVC, if I'm going to make changes in views, I do not have to know what is happening in the controllers. In the example that i mentioned, how I ask to a designer that modify a view that says:
{{extend 'layout.html'}}
{{=form}}
Web designers normally know html and css, and if there is a way to easily separate views and controllers, then web2py is going to be easily adopted in teams with specialized members. But if I read in the main doc examples with view related code in controllers, then I not adopt the framework.
> Take a webservice as an example, doesn't have a form to present. Does the model need it?
>
>Just because one consumer of a model doesn't require a particular attribute does not mean that attribute doesn't belong to the model. The webservice might not need the model's validators either, but that doesn't mean the model shouldn't have validators.
Yes, the webservice need them. To insert, update and delete, data need to be validated.
I disagree that all queries belong in models. A complex query that needs to be re-used in multiple places should go somewhere centralized (not necessarily a model file, but perhaps a module). However, not all queries need to be re-used. Furthermore, some queries are so simple, there is no point in abstracting them into a re-usable function/class (e.g., selecting all records and fields from a single table).
The first two examples in the tutorial show forms in pure HTML. Furthermore, in the forms chapter, there is a section on using HTML for forms as well as a section on custom forms, which shows how you can use custom HTML but still take advantage of some attributes provided by the FORM helper. I think it would be fine to add some verbiage to the book making it more explicit that these techniques might be particularly beneficial when working with designers (e.g., "If you are working with designers who only know HTML, you might want to lay out your forms via the methods described in the Custom Forms section."). That doesn't mean it's wrong to have some examples showing the use of helpers.
Also, encountering {{=form}} in a template doesn't have to stop a designer from contributing. If the form is laid out as desired via {{=form}}, then the only thing the designer need touch is the CSS. On the other hand, if the form is not laid out as desired via {{=form}}, then you need custom HTML anyway, and at that point, the designer can just go ahead and implement the HTML in the template (which you might later abstract into a custom formstyle function).
--
I disagree that all queries belong in models. A complex query that needs to be re-used in multiple places should go somewhere centralized (not necessarily a model file, but perhaps a module). However, not all queries need to be re-used. Furthermore, some queries are so simple, there is no point in abstracting them into a re-usable function/class (e.g., selecting all records and fields from a single table).
Apps grow in time and we never known if in a future we will need to reuse a query,
what happen if a client, in some moment decides that he don´t want to work with the data of more than one year ago, but it should remain in the DB? (Because so much data bothered and there is other software for data analisys) Then will be necessary to change so simples queries one by one.
I do not really like to continue this discussion, from the beginning I just wanted to comment on the reasons why some experienced web developers I know have rejected web2py after reading only part of the manual.