[web2py] Re: Generator for web2py
Hi, Must be... you can download it from olympic.co.uk/download/generv-1.tar.gz it has the code and the PDFs - make sure you read the 'how to use' document graham -- 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] Generator for web2py - part 2
I see that the web2pyslices still doesn't have the entry I posted a few days ago and neither has my reply to Carlos' posting. The latter may be because I don't/cannot use google groups because Google don't want to let me create a user, which is fine by me if they want to be like that... so just go to http://www.olympic.co.uk/pythondev/ to download and read through the how to use document at least. I'll use that web page in the future for updates. I will, yet again, point out that this is a work in progress with lots of gaps and almost certainly a few bugs and certainly with a lot of diagnostics that really will go soon. My excuse is that I really haven't had a lot of tmie to work on it over the past three months or so - blame that on the warmest and wettest December (probably bot since records began...) which has had an impact on some of my other horticultural and small-scale sheep raising activities - fortunately most of the plants and sheep have survived... And again, don't be too concerned about the quality of the code: firstly it will be changed quite a lot in the not too distant future; and secondly it is my first Python program. If anyone is interested then please let me have your comments and ideas. graham -- 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] Generator for web2py
Further to my previous posting I have just published the details of my generator tool in web2pyslices. Just download and read through the how to use document at least. I will, yet again, point out that this is a work in progress with lots of gaps and almost certainly a few bugs and certainly with a lot of diagnostics that really will go soon. My excuse is that I really haven't had a lot of tmie to work on it over the past three months or so - blame that on the warmest and wettest December (probably bot since records began...) which has had an impact on some of my other horticultural and small-scale sheep raising activities - fortunately most of the plants and sheep have survived... And again, don't be too concerned about the quality of the code: firstly it will be changed quite a lot in the not too distant future; and secondly it is my first Python program. If anyone is interested then please let me have your comments and ideas. graham -- 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: Grails for web2py - anyone interested ?
Thanks for the responses. I suspect that in the short term it would be simplest to put the code etc. on web2pyslices and then it's available for anyone to look at and use. But probably in the longer term it belongs on somewhere like Github. It does appear to work at the moment although I am still making some, hopefully only small-scale, changes to it and so I should be able to upload it within a couple of weeks, and I'll post here when I do. graham -- 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] Grails for web2py - anyone interested ?
I don't know whether any of you are familiar with Grails (www.grails.org); I was using it for a few years but for a variety of reasons have moved to Python. However there are features of Grails that I did find particular useful and I felt that there may be some benefit, to me at least, in reproducing some of the features of Grails. To summarise: I've written a little Python script that you can use to create a skeleton model file with the model as a class in its own file; you then complete the model by adding Field(...) definitions to the define_table () entry and optionally add a few other attributes etc. The generator script can then write the controller and the set of views for that model. And then repeat for your various models. You will then have a working application immediately without writing any code but, of course, in reality most will want to tailor the views and controllers to their own requirements but the generated Python scripts provide a sound base from which anyone can work. It can cope with one to one and one to many relationships, dealing with the data presentation by the use of modal pop-ups and with appropriate code in the controllers. Currently it works although I am in the process of putting the final touches and, needless to say, there are a good many little things that are still required. And there are some, but not many, conventions that must be used in order that the generator can make sense of the model. I'm posting this to discover whether there is anyone else who may be interested in this type of application development and who may be interested in the generator script. I am minded to make the whole thing open source as it's hardly any of my ideas and others may want to make use of it to take a slightly different direction or whatever... If you are interested then either reply here or email me. I would point out that the generated code does not make use of some web2py features: it does not use self-submission nor does it make use of features like SQLFORM, I did not feel that in my particular applications these offered me any great benefits and may have complicated some matters. If anything it tries to keep the whole thing simple with very visible code and HTML and I suppose could very readily be applied to other environments. The starting point was actually Bruno Rocha's http://www.web2pyslices.com/slice/ show/1478/using-modules-in-web2py where he describes using model classes in /modules. And I do understand that this whole approach may be seen as not in the spirit of web2py so I'll apologise in advance if I am causing any distress. graham -- 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: web2py and self-submission/postbacks - a newcomer asks
Thanks for all the replies - I'll close this particular discussion now and get on with writing some exploratory code, unfortunately, as always seems the case, the past week or so has had rather too many, apparently urgent, distractions... But there is one thing I did want to mention re. http://web2py.com/books/ default/chapter/29/07/forms-and-validators#Sharing-forms. Indeed I did read that section but it was the comment: "What we discuss here is possible but not recommended, since it is always good practice to have forms that self-submit." that prompted me to start the thread, I was interested in why it was "not recommended". But, as the saying goes, I'll be back...(well very likely with more questions) And I will make at least a future post about the comparisons of the frameworks. graham -- 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: web2py and self-submission/postbacks - a newcomer asks
Anthony writes: > > > It would probably help if you show some code, or at least explain in more detail an example where self submission is not possible or overly difficult. Note, your code can always distinguish between a form creation request and a form submission request by checking whether request.post_vars is None or whether request.env.http_method == "POST". As Jim suggested, if you are using SQLFORM, the easiest way to pre-populate is by setting field default values before form creation.Anthony > > Well, I cannot show any code - because I haven't written any real stuff yet - and I cannot give an example of where self-submission could not work because I haven't gotten to that point, yet (if at all). As I said I'm just investigating but self-submission is one aspect of web2py that did stand out to my superficial run through its features. My experience in web-type applications is of the 'single purpose code' type: one method assembles the data for the web page, from a database or some default values etc., and then 'returns' it to the web client; then an entirely separate method is the target for the subsequent HTML form submission, it receives the data and creates the necessary data structure (object or whatever) and populates it from the data on the POST, stores it in the DB etc. This has a complete separation of functions. And to some extent it is this lack of a clean separation that I find a problem in the self-submission case, perhaps more philosophically than practically, I'll agree. But to return to the example I gave: I did quote from the book: "It is always possible to pre-populate a form using the syntax: form.vars.name = 'fieldvalue' Statements like the one above must be inserted after the form declaration and before the form is accepted, whether or not the field ("name" in the example) is explicitly visualized in the form." but are you suggesting that it is better to populate the db.tablename object's defaults before the 'form=SQLFORM(...' statement ? And I did suspect that there was some indicator used within the FORM object - you mention request.post_vars being None, so if there were any complex code to establish the pre-population values I should enclose that in a condition like: if request.post_vars == None: # # put pre-population data acquisition here # including calls to other methods - if lengthy code # form = SQLFORM(... Sorry to go on so... Graham -- 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: web2py and self-submission/postbacks - a newcomer asks
Anthony writes: > If your going to use the web2py FORM or SQLFORM functionality, then the same code both defines and processes the form, so self submission makes sense. If you would rather build all of your form creation and processing code from scratch, then sure, do whatever you want. Anthony That's the issue really - whether my design lends itself to self-submisson and if not whether not using those features of web2py that are built around self-submission rather reduce the benefits of using web2py at all. It's not that I cannot see a way to use self-submission but there are then oddities - well they seem so to me - I notice that the book says: "Pre-populating the form It is always possible to pre-populate a form using the syntax: form.vars.name = 'fieldvalue' Statements like the one above must be inserted after the form declaration and before the form is accepted, whether or not the field ("name" in the example) is explicitly visualized in the form." and to use the example from a few lines earlier: def display_form(): record = db.person(request.args(0)) or redirect(URL('index')) url = URL('download') link = URL('list_records', args='db') form = SQLFORM(db.person, record, deletable=True, upload=url, linkto=link) # pre-population would go here ?! if form.process().accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form) in the example that I was thinking about that would involve a couple of DB reads followed by the form.vars... assignments. Now if the same code is then executed after submission how do these statements get handled ? I can only suppose that re-executing the form=SQLFORM(...) has some magic in it, but presumably not in the DB access and the form... assignments. How does it deal with those ? I've been otherwise occupied in the past few days and still haven't actually done any work wit web2py yet... graham -- 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: web2py and self-submission/postbacks - a newcomer asks
Don O'Hara writes: > > Hi Graham - Welcome to web2py ! I think you'll find that this group > has many people who can share many types of design patterns. > Thanks for the replies... Just to mention the others: I had looked at Django and Turbogears briefly - Django certainly gets the most mentions - at least sufficiently to feel that they would do what I want and then I came to web2py. I've started more seriously with web2py first simply because it was fresh in my mind, I'll return to the others later; I've sort-of decided on a few small apps, say a few days for each framework, although in order to keep the test apps meaningful they won't be that trivial otherwise it could be a completely unrepresentative exercise - so it may end up at more than a few days. The sort of application that I am planning are not really web apps, but intended for SMEs where there would run on a local network but, of course, by using a web approach it is easy to run the same applications on the Internet, a VPN, the cloud, use tablet/smartphone devices etc. and many of those options are very likely to be used. As for the self-submission: I cannot see much, if any, of the code that would be involved in the preparation and creation of the 'new' form and would be required for the validation and subsequent DB processing. Take as an example an Employee and payroll function: there would need to be a preliminary enquiry to establish whether creation of an Employee is required or whether the employee already exists, this could be a separate transaction or handled via Ajax when the relevant key fields (say name or reference) were entered (fully or use a bit of auto-complete) Then on confirmation that a new record was needed it would be necessary to read a couple, at least, of parameter records to acquire a few default values: some site preferences, some statutory; then the data for the 'create' page could be assembled, bearing in mind that a good number of fields would not be user-editable, and some not normally user-viewable. Then there are a good few one-to-manys in this example: there would possibly be more than one address; probably more than one additional contact (next of kin sort of thing); an employment history; set of skills and more especially related to payroll. While it is not likely that everything would be entered at the very first transaction there would be quite an amount entered at the start. A lot of 'validation' can be done on the client either by using selection boxes (perhaps the options constrained by the site preferences) in javascript but at the end there would need to be some validation by the application and, of course, dealing with the creation of the two or three (or more) subsidiary rows of the manys I cannot see how that sort of interaction can be made to work with self- submission and I cannot see how such a really not very complex data creation procedure could be made any simpler. graham -- 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] web2py and self-submission/postbacks - a newcomer asks
I'm new to python and web2py...I have a small, but non-trivial, web application and was looking at the various python web frameworks and decided to look more closely at web2py and a couple of others and to write a couple of small example applications to see how they work... I've had a quick read of the web2py book but I was a little surprised by the emphasis on self-submission/postbacks, it's not a technique that I would choose myself. I was wondering whether there was anything in python or web2py that make this technique particularly appropriate ? Being new to python etc. I thought it worthwhile asking. The application that I have in mind has a number of one to many and a few many to many relationships and in a number of cases I will want to use a combined form with both the 'one' and one or some of the 'many' (perhaps on a tabbed layout, or scrollable perhaps) almost certainly using Ajax to deal with the different parts of the page. It is interesting to look at the different frameworks and see the different emphasis that each one has, and to see if that does have far-reaching consequences, it's worthwhile spending a little time to try to make the right choice. thanks graham -- 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.