[web2py] web2py | video course | license terms
Hello guys, I have become familiar with web2py over the last months and am now playing with the idea of creating a video course. However, I have been wondering for quite some time why there is no current video course on web2py. The only useful video material are the videos from Massimo on Vimeo. They are very informative, but sometimes a bit exhausting to watch, because they are very long and there is no table of contents with time stamp. Also, the video quality is not the best. Now I'm wondering if there are any licensing restrictions for creating a commercial video course. I looked at the LGPLv3, but I can't really figure it out, because it only refers to web2py as a framework, but not to it, if the framework is used as visual material for a course. It would be nice if someone could explain to me if and what there is to consider. Many thanks in advance. Friendly greetings Jay -- 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/5d78519c-bb96-4585-a2ec-7a309ba2e782%40googlegroups.com.
[web2py] Re: Validator IS_NOT_IN_DB not working | web2py
Wow, that's actually how it works! Thank you very much! Am Freitag, 18. Oktober 2019 12:32:17 UTC+2 schrieb Annet: > > What about > > > form = SQLFORM() > if form.process(...).accepted > > > > instead of > > form = SQLFORM().process() > if form.accepted: > > > Best, > Annet > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/12260de3-c9d8-47f5-bcfc-91ed550193e6%40googlegroups.com.
[web2py] Validator IS_NOT_IN_DB not working | web2py
Hello guys, I'm struggling with a problem that's driving me crazy. The validator IS_NOT_IN_DB which I use for my object "tag" does not work for me. # TAG db.define_table('tag', Field('name', requires=(IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB( db, 'tag.name'))), Field('is_public', 'boolean', default=False, readable=False, writable=False), auth.signature, common_filter = lambda query: db.tag.is_public == True) db.tag.name.requires = IS_NOT_IN_DB(db, 'tag.name') As you can see, there are two ways I made sure that no duplicates can be created, in the name field itself and outside of the table definition. Registered user can suggest tags: Although the tag "test" has already been submitted twice I could submit it a third time. The function looks as follows: What I already tried (without improvement): - adding "unique=True" to the name field - just using .process() without "onvalidation" - "ignore_common_filters" on and off - inside the "my_form_processing"-method I checked if the amount of db objects with the given name is > 0 , but i could not figure out how to stop the form from processing Please let me know how I can fix that problem. Thanks! Jay -- 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/d05b3734-a26a-4005-8ae2-d32b0bea7487%40googlegroups.com.
[web2py] Re: How to easily implement another CSS-Framework
So, do you delete all views or just the layout view? Am Freitag, 11. Oktober 2019 19:01:07 UTC+2 schrieb Ruslan Gareev: > > Hi. Yes, you can delete files. For me it's normal and i use that way in my > projects. > > пятница, 11 октября 2019 г., 10:38:52 UTC+5 пользователь Jay B написал: >> >> Hello guys, >> >> I'm trying to figure out how to include another CSS framework instead of >> bootstrap. But the fact that the layout.html and other files point to the >> bootstrap files makes it harder than I thought. >> >> I would like to test other CSS frameworks like Semantic UI or Bulma >> instead of Bootstrap and wonder how to do it best. Or am I forced to delete >> all CSS files and standard views? >> >> I would be happy if you could help me and thank you in advance for all >> the tips. >> >> Greetz >> Jay >> > -- 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/bf44df7c-ac30-43ff-ae83-aeb61e995f8c%40googlegroups.com.
[web2py] Changing the css framework
Hello guys, i'd like to use another css framework for my web2py app. Is there a easy way to replace it and start with a fresh new app? Greetz Jay -- 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/b7c8be62-36a9-4f3d-a077-cdcff2dc72df%40googlegroups.com.
[web2py] How to easily implement another CSS-Framework
Hello guys, I'm trying to figure out how to include another CSS framework instead of bootstrap. But the fact that the layout.html and other files point to the bootstrap files makes it harder than I thought. I would like to test other CSS frameworks like Semantic UI or Bulma instead of Bootstrap and wonder how to do it best. Or am I forced to delete all CSS files and standard views? I would be happy if you could help me and thank you in advance for all the tips. Greetz Jay -- 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/0ab50fdb-5d9c-442a-a6d7-2a2bcad2bec7%40googlegroups.com.
Re: [web2py] Re: auth.messages.verify_email html template
@Lisandro, would happen to have these code snippets handy to share? I'm interested in using the mailgun api too. Either way, thanks for checking! My best, Jay On Tuesday, October 29, 2013 5:46:51 PM UTC-4, Lisandro wrote: ... For those interested in doing that, is just as simple as instantiating Auth class and overwriting wanted methods, for example, I overwrited register and email_reset_password methods in Auth class, that is, to send my custom emails on register and request reset password respectively. Regards, Lisandro. -- 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: auth.messages.verify_email html template
Extremely helpful! Thanks Lisandro. I'll be sure to share any tweaks... On Saturday, November 22, 2014 8:56:06 AM UTC-5, Lisandro wrote: ... I hope it helps! -- 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: admin access under gunicorn on Heroku
I followed this step with the exception of the -u www-data because that user isn't present on my os x system and heroku nor gunicorn docs mention it. I still receive the access denied message admin disabled because unable to access password file even though I have a parameters_443.py file. My site https://teststeps.herokuapp.com/ now has 2 paramters_port.py files. The port 5000 file works for running locally with 'foreman start web'. Each heroku dyno sets the PORT var. I'm not sure why its not working. Any suggestions are appreciated... My best, Jay On Thursday, May 2, 2013 9:14:49 AM UTC-4, Massimo Di Pierro wrote: sudo -u www-data python -c from gluon.main import save_password; save_password(raw_input('admin password: '),443) replace 443 with PORT -- 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: Correction for setup-web2py-heroku.sh script
Thanks Massimo, I'll try it out and submit a PR if the new way doesn't break anything. My best, Jay On Thursday, October 23, 2014 10:20:59 AM UTC-4, Massimo Di Pierro wrote: It is a matter of preference but I think you are right. Your approach is best. On Wednesday, 22 October 2014 14:31:09 UTC-5, Jay Martin wrote: Currently the setup-web2py-heroku.sh script includes these commands: sudo pip install virtualenv sudo pip install psycopg2 virtualenv venv --distribute source venv/bin/activate pip freeze requirements.txt Shouldn't we want to install psycopg2 into the virtualenv named venv by moving the psycopg2 install command after venv is created? Like so: sudo pip install virtualenv virtualenv venv --distribute source venv/bin/activate sudo pip install psycopg2 pip freeze requirements.txt My best, Jay -- 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] Correction for setup-web2py-heroku.sh script
Currently the setup-web2py-heroku.sh script includes these commands: sudo pip install virtualenv sudo pip install psycopg2 virtualenv venv --distribute source venv/bin/activate pip freeze requirements.txt Shouldn't we want to install psycopg2 into the virtualenv named venv by moving the psycopg2 install command after venv is created? Like so: sudo pip install virtualenv virtualenv venv --distribute source venv/bin/activate sudo pip install psycopg2 pip freeze requirements.txt My best, Jay -- 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] Seeking advice on Heroku db parity
According to this Heroku article https://devcenter.heroku.com/articles/development-configuration#dev-prod-parity, subtle differences between Postgres and Sqlite may cause hard to troubleshoot problems when using Sqlite locally and Postgres in production. Web2py includes a script heroku.py that uses a Sqlite db for local development. I'm curious if anyone has tried using Postgres for local development and whether it created more problems than it intends to prevent. Is there anything about web2py in particular that would caution me against following Heroku's recommended best practice? Thank you for any experience or advice! My best, Jay -- 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] Init Script in Web2Py
I'm confused as to why this scenario needs caching. Isn't it true that for an empty user table: if cache.ram('init',lambda:db(db.auth_user).isempty(),None): arbitrary_function() will only cache the boolean value True and keep that value (True) in cache forever (until the app is restarted), associated with the given key 'init'? Therefore, only this initial state is remembered. All future executions of this code will only ever return this initial value (True), therefore the subsequent arbitrary function will continue to be executed every cycle of execution. Am I missing something? Many thanks! On Friday, August 10, 2012 11:23:56 PM UTC-4, Massimo Di Pierro wrote: you stil want to cache that if cache.ram('init',lambda:db(db.mytable).isempty(),None): -- 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: Latest thinking -- Bootstrap vs. Foundation?
Hi Arnon, Please see this post if you're interested in helping to test BS3 or want to keep up with the progress: https://groups.google.com/forum/#!topic/web2py/oSABtjmnYM0 My best, Jay On Tuesday, March 11, 2014 1:18:41 PM UTC-4, Arnon Marcus wrote: Any news on this? When should BS3 be expected to be int the default (welcome) app? -- 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 official site erroneously displays mobile view from google search
I shouldn't have reduced the size of my screenshot to save bits, because it makes my viewport look small. My monitor is 1920 x 1080 and chrome is full screen. The mobile view is only returned from google's search results and not from directly visiting the site. I think incognito mode should rule out cookies. I'm not sure what might be causing this, but its been going on for a couple months. Thanks you all for testing. My best, Jay On Tuesday, March 4, 2014 1:29:00 PM UTC-5, Jim S wrote: I should clarify. I can reproduce it but don't feel it is an issue. In my opinion, this is the way responsive sites are supposed to work. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] SSL CDN (free)
Just found a free SSL CDN and wanted to share with everyone: http://www.jsdelivr.com/ Hope this helpful for someone... -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py components and browser history
Thanks for the great detail. I'm curious if you were able to smooth out the flakiness you mentioned or have made any new discoveries since last year? Thanks! Jay On Saturday, January 21, 2012 6:30:58 AM UTC-5, LightDot wrote: It seems that nobody cares much for web2py, ajax and browser back buttons :) Nevertheless, I made some progress and thought I'd post some findings here If anyone searches the group with a similar goal. Let me describe the problem once again. Imagine a scenario: 1) visitor is on Google, searches for a web2py powered site, finds it, follows the link 2) site loads 3) visitor sees an internal link which loads a web2py component (ajax call) with new content, follows the link, component loads 4) visitor reads the content, wants to go back, uses the browser back button... 5) KABOOM, user is back on Google instead on the first page of the site which is pretty bad as far as user experience goes. Anyway, our site has a number of components that can work as regular pages (.load and .html do the same thing) so what I really need is a way for a component to tell the browser it has loaded. To solve this, i need to manipulate the browser history manually. Sadly, current state of things is pretty messy on the browser side. After looking at what's available, I found several solutions but none of them perfect. I decided to give up on Internet Explorer 8 and 9 completely. Sorry folks, you're on your own. IE 10 *should* work as it comes out... yes, I believe in Santa. :) So, the first thing I tried was using the native browser's history API [1], which all modern HTML5 browsers have (yes, forget IE9). It looks fine on paper, but the implementation has some problems. Chromium / Chrome behaves differently than Firefox/Opera/Safari in one crucial point (fires initial onpopstate, I even managed to crash Chromium) [2], so I had to abandon using this API directly. If it wasn't for this Chromium issue, it would be the perfect solution. Then I tried using the history.js [3]. This project has a long history of successfully coping with ajax/browser history issues, so I was optimistic. But sadly, history.js's master branch (version 1.7.1) also works in a way that pushState and replaceState will immediately trigger onpopstate, which is not what I wanted [4]. Luckily, the devel branch (1.8.0-dev) got an additional State.internal [5] with this commit [6], so I can tell if onpopstate is triggered by the browser's buttons or not. Ok, long story is coming to an end. It's time for some code. This is what I'm currently at: - set the history entry in the component's controller: response.js = History.pushState({isMyPageName:1},'','+URL('some','thing',extension=False)+') -at the end of layout.html: script (function(window,undefined){ var History = window.History; if ( !History.enabled ) { return false; } History.Adapter.bind(window,'statechange',function(){ var State = History.getState(); if (( State.data.isMyPageName == 1 ) ( State.internal == false )) { //alert(data: + JSON.stringify(State.data) + title: + State.title + url: + State.url + internal: + State.internal); window.location = State.url; } }); })(window); /script Ok, that's about it... The solution is flaky at times and I still need to manipulate document.title, haven't gotten to that yet. But it works, web2py components can silently change the browser url as they load. And no #%/ URL hashes and hashbangs... [1] https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history [2] https://github.com/balupton/history.js/wiki/The-State-of-the-HTML5-History-API [3] https://github.com/balupton/history.js [4] https://github.com/balupton/history.js/issues/47 [5] https://github.com/balupton/history.js/tree/dev [6] https://github.com/balupton/history.js/commit/c79c17f9801373f5218f144088c387f1935f3462 -- --- 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] SPA vs ROCA (and greetings)
Greetings All, I'm new here. Congratulations on building a great framework and community! I hope to learn and contribute along with you. I don't have a specific technical problem. However, I will share a question stemming from my current state of curiosity about web app architectures that you might enjoy chiming in on: *Where does web2py fall between the polar extremes of Single Page Applications (SPA) http://en.wikipedia.org/wiki/Single-page_applicationand Resource Oriented Client Architecture (ROCA) http://roca-style.org/, and in which direction would you personally like to see it shift in the future (for web3py and web3py backports to web2py)? *(It's possible that by ignorance, I've selected a poor choice of opposites. In which case you might suggest your own pair.) *Personal Context* (in case your curious): *Motivation: *To create food planning/shopping related web app to disrupt the way things are currently done ; Fall-back plan to become expert in all things web app related (development and design). I'm in it for the long haul! *Stack History:* I started studying web dev a year ago and studied an immature SPA framework for several months, after learning the basics of JavaScript, HTML and CSS. Through my naivety I only recently discovered the problems involved with SPA regarding SEO crawlability etc. Instead of JavaScript Everywhere! as advertised, PHP was recommended to handle the server-side stuff. I choose not to learn PHP out of concern for its security and overall design incohesiveness. I compared Rails and Django. Python's readability won out. While Django's community is larger, I sense something special going on here and I want to be a part of it. Also, the web2py components and built in ajax support clinched it for me. I enjoyed the free CS101 course in Python at Udacity.com, but it didn't cover OO, so I'm now reading Monty/Karel in Pythonhttp://www.amazon.com/Monty-Karel-Introduction-Object-Oriented-Programming/dp/0970579527. I hope to be up to speed soon. In the mean time, *if I can help with anything at all, please let me know.* * * All my best, Jay Meals7, Inc. webapphero.com -- --- 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: SPA vs ROCA (and greetings)
Thanks for letting me know about web2py's flexibility, Derek. Per your take on OO relevance, I'll slow down on that and dig right into the nuts and bolts of web2py. Fun! On Monday, May 20, 2013 1:22:55 PM UTC-4, Derek wrote: Where does it fall? Probably more near ROCA than SPA, but you can build your apps however you want. It's open enough to allow both of those use cases. OO may be helpful, but it's not necessary with Web2py. Web2py just gives you all the help you need to build your app as quickly as possible. It does so in a way that by default will be secure. As far as future direction? I'm happy with how it is now, I wouldn't want to change it, except perhaps to fork it's core to a smaller wsgi toolset framework. I've written all kinds of web apps, my favorite right now is SPA because it reduces latency, and bandwidth. It seems like so much waste with loading everything again on each page load for each user action. On Monday, May 20, 2013 1:10:49 AM UTC-7, Jay Martin wrote: Greetings All, I'm new here. Congratulations on building a great framework and community! I hope to learn and contribute along with you. I don't have a specific technical problem. However, I will share a question stemming from my current state of curiosity about web app architectures that you might enjoy chiming in on: *Where does web2py fall between the polar extremes of Single Page Applications (SPA) http://en.wikipedia.org/wiki/Single-page_applicationand Resource Oriented Client Architecture (ROCA) http://roca-style.org/, and in which direction would you personally like to see it shift in the future (for web3py and web3py backports to web2py)? *(It's possible that by ignorance, I've selected a poor choice of opposites. In which case you might suggest your own pair.) *Personal Context* (in case your curious): *Motivation: *To create food planning/shopping related web app to disrupt the way things are currently done ; Fall-back plan to become expert in all things web app related (development and design). I'm in it for the long haul! *Stack History:* I started studying web dev a year ago and studied an immature SPA framework for several months, after learning the basics of JavaScript, HTML and CSS. Through my naivety I only recently discovered the problems involved with SPA regarding SEO crawlability etc. Instead of JavaScript Everywhere! as advertised, PHP was recommended to handle the server-side stuff. I choose not to learn PHP out of concern for its security and overall design incohesiveness. I compared Rails and Django. Python's readability won out. While Django's community is larger, I sense something special going on here and I want to be a part of it. Also, the web2py components and built in ajax support clinched it for me. I enjoyed the free CS101 course in Python at Udacity.com, but it didn't cover OO, so I'm now reading Monty/Karel in Pythonhttp://www.amazon.com/Monty-Karel-Introduction-Object-Oriented-Programming/dp/0970579527. I hope to be up to speed soon. In the mean time, *if I can help with anything at all, please let me know.* * * All my best, Jay Meals7, Inc. webapphero.com -- --- 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: why won't web2py create the databases
@Likit, ProgrammingError: (1146, uTable 'jodb.joke_category' doesn't exist) It looks as though you have '.' (period) in the table name and that is probably causing the problem. If that is not the case, could you show us your db.py file? We could really help then. On Jan 12, 12:03 am, Likit lewis_le...@hotmail.com wrote: I mean, why won't web2py create the tables through its famous DAL. I have created the database directly in mysql. On Jan 11, 8:44 pm, Likit lewis_le...@hotmail.com wrote: I guess I like SQL better than frameworks. SQL is a query language for DDL and DML that is well documented and completely explicitly. Frameworks are opaque and invent a new syntax subject to ambiguities of parens, square braces, curly braces, dotted names, sometimes tablenames being implicit, sometimes fieldnames being implicit. Why? So, I have repeatedly tried to make a link table like the famous dogs and owners tables in the Web2py book to no avail. Each time there is a problem I must do the following: - drop the database from mysql - stop apache - stop mysql - delete the web2py application via the filesystem - restore the web2py application via the filesystem making sure that the cache and session files have been deleted - restart apache - restart mysql - create the empty database in mysql - run the web2py application But, web2py's DAL fails to create the tables. Because the errors appear to be in the framework itself, the diagnostics are completely opaque through several layers of calls. The ultimate error is that one of the tables is not being created. But, that is circular--that is because the DAL failed to create the table for a brand new web2py application in an empty database. Judging from the references below it is because of a faulty migration. it's not like the most trivial migrations EVER work. it appears that some detritus of the previous application or tables exists so that web2py attempts its failed magic by doing a migration. So, perhaps the real question is how does one purge every possible vestige of both the tables and application so that web2py does not try any of its so-called magic (which is supposed to be very unpythonic, in any case). I've wasted nearly 60 hours on web2py and am about to stop wasting any more time. There seem to be many reasons that php, jquery, and RonR have dusted python for web development. Here is the traceback: TRACEBACK Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 204, in restricted exec ccode in environment File C:/web2py/applications/pyjokes/models/db.py, line 55, in module Field('category_id', 'integer')) File C:\web2py\gluon\dal.py, line 5097, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 728, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 816, in migrate_table self.execute(sub_query) File C:\web2py\gluon\dal.py, line 1359, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1353, in log_execute ret = self.cursor.execute(*a, **b) File C:\web2py\gluon\contrib\pymysql\cursors.py, line 108, in execute self.errorhandler(self, exc, value) File C:\web2py\gluon\contrib\pymysql\connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue ProgrammingError: (1146, uTable 'jodb.joke_category' doesn't exist)
[web2py] Validators
In my app some input fields are optional. As an example, currently IS_DATE() forces the date to be present. I was wondering if it makes sense to allow Null or '' (empty) dates and then use IS_NOT_EMPTY() to force a value to be present in that field. In general, does it appeal to web2py users to use this approach? Can we change validators to allow this? I am happy to supply patches for all affected validators, if it is agreeable. It would certainly be more flexible. For now I have been writing a changed copy of the needed validators in my db.py file. Is there a better way to do it?
[web2py] Re: Validators
Thanks. IS_EMPTY_OR() will do just fine. On Nov 15, 2:08 pm, Richard Vézina ml.richard.vez...@gmail.com wrote: IS_EMPTY_ORhttp://web2py.com/book/default/chapter/07IS_EMPTY_OR Search for IS_EMPTY_OR in this page : http://web2py.com/book/default/chapter/07 I think : requires = IS_EMPTY_OR http://web2py.com/book/default/docstring/IS_EMPTY_OR(IS_DATE http://web2py.com/book/default/docstring/IS_DATE()) Do what you want.. Richard On Tue, Nov 15, 2011 at 2:03 PM, Jay jkel...@gmail.com wrote: In my app some input fields are optional. As an example, currently IS_DATE() forces the date to be present. I was wondering if it makes sense to allow Null or '' (empty) dates and then use IS_NOT_EMPTY() to force a value to be present in that field. In general, does it appeal to web2py users to use this approach? Can we change validators to allow this? I am happy to supply patches for all affected validators, if it is agreeable. It would certainly be more flexible. For now I have been writing a changed copy of the needed validators in my db.py file. Is there a better way to do it?
[web2py] Re: MongoDB and Web2py
Here is what I use (in a file models/0.py): import pymongo from pymongo import ASCENDING, DESCENDING def make_mongo_connection(): mdb = pymongo.Connection() return mdb mdb = cache.ram('mongodb', make_mongo_connection, 0) # in the code I use mdb as needed. # On a busy site, it may make sense to have several of these connections available to use in a pool
[web2py] Re: CAS Auth redirect loop
The only comment I have is that there may be problem in the code at redirect. Raising an exception in redirect does not seem to work. I would look there. My $.02. Jay
[web2py] Re: Speeding up model execution for large models
Massimo, Would it be possible to only load db.py if it has changed and when changed generate a python object that is the db, and save/load it as required? I know it would work, But would it be too slow? Slower then running all of db.py. I am looking at using web2py to write a small ERP like app. It could have 100's of tables. So keeping up the conditional models could be a nightmare! Regards, Jay Kelkar P.S. Happy 4th Birthday web2py! Many happy returns.
[web2py] Re: MySQL query not reflecting actual state of db
This is required because you are using the DAL outside web2py framework, from gluon import * import time db = DAL('mysql://web2py:web2p ... When used like above, you have to call db.commit to complete the transaction. Normally all database insert/updates/deletes are committed at the end of each action by the framework.
[web2py] Re: How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?
ArrC, the proper way is to start the database using xampp (using control panel, or script) then use web2py. Actually web2py will come up even when the database it not up, but to actually interact with it the db needs to be up. So if yo get something like, failed to ... after 5 tries, just start the db via xampp. db is accessed by network location that is host and port, if those are correct you are good to go. On Jul 23, 4:03 am, ArrC justmailnav...@gmail.com wrote: I somehow manged to install to install Postgres into Xampp directory ( by following a tutorial i found on web ) to use it under xampp environment which is working perfectly fine. But now i think that python dosnt know where is Postgres located on my machine. I have instlled Psycopg2 usinghttp://www.stickpeople.com/projects/python/win-psycopg/ and MinGW GCC. Will web2py will work with this kind of postgres installation or i have to install it the normal way i.e outside of xampp directory? Thanks.
[web2py] Making a field non-editable, but writable using SQLFORM
I have a situation where I need to adjust an SQLFORM field to be non-editable. I can do that with .writable = False, but that seems to also prevents database I/O for that field. What I'm trying to do is set a default that cannot be changed. Is there a way to set an SQLFORM field so that it appears as a label on the form itself, but is still writable for the database? For reference, I'm doing this with a field in the form returned by auth.register, so I cannot insert code between the form creation and the accepts call. I believe I'm restricted to working with the model before calling auth.register, or by using custom forms. Jay
Re: [web2py] Making a field non-editable, but writable using SQLFORM
That doesn't seem to affect the HTML form output at all for me. I've also tried changing the widget to LABEL, but that results in the same problem with the value not being transmitted back via the form. What I'd like to be able to do is set the readonly attribute of the input tag; but I don't know how to do that in this context, where I cannot insert code between the creation on the SQLFORM and the accepts call. Jay On Thu, Jun 16, 2011 at 2:21 PM, Bruno Rocha rochacbr...@gmail.com wrote: Sorry, I answered before read entire message, if you want to chamhe it in form only, better to use the 'represent' attribute db.table.field.represent = lambda f: label %s /label % f -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Thu, Jun 16, 2011 at 3:05 PM, Jay Shaffstall jshaffst...@gmail.com wrote: I have a situation where I need to adjust an SQLFORM field to be non-editable. I can do that with .writable = False, but that seems to also prevents database I/O for that field. What I'm trying to do is set a default that cannot be changed. Is there a way to set an SQLFORM field so that it appears as a label on the form itself, but is still writable for the database? For reference, I'm doing this with a field in the form returned by auth.register, so I cannot insert code between the form creation and the accepts call. I believe I'm restricted to working with the model before calling auth.register, or by using custom forms. Jay
Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM
I'd been thinking I needed to do that between form creation and the accepts call, but you're right, it works even after that point. I make the call to auth.register, and then modify the readonly attribute, and it works fine. Thanks! Jay On Thu, Jun 16, 2011 at 5:06 PM, DenesL denes1...@yahoo.ca wrote: Jay, you can do: form.element('#tablename_fieldname')['_readonly']=True On Jun 16, 2:57 pm, Jay Shaffstall jshaffst...@gmail.com wrote: That doesn't seem to affect the HTML form output at all for me. I've also tried changing the widget to LABEL, but that results in the same problem with the value not being transmitted back via the form. What I'd like to be able to do is set the readonly attribute of the input tag; but I don't know how to do that in this context, where I cannot insert code between the creation on the SQLFORM and the accepts call. Jay On Thu, Jun 16, 2011 at 2:21 PM, Bruno Rocha rochacbr...@gmail.com wrote: Sorry, I answered before read entire message, if you want to chamhe it in form only, better to use the 'represent' attribute db.table.field.represent = lambda f: label %s /label % f -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Thu, Jun 16, 2011 at 3:05 PM, Jay Shaffstall jshaffst...@gmail.com wrote: I have a situation where I need to adjust an SQLFORM field to be non-editable. I can do that with .writable = False, but that seems to also prevents database I/O for that field. What I'm trying to do is set a default that cannot be changed. Is there a way to set an SQLFORM field so that it appears as a label on the form itself, but is still writable for the database? For reference, I'm doing this with a field in the form returned by auth.register, so I cannot insert code between the form creation and the accepts call. I believe I'm restricted to working with the model before calling auth.register, or by using custom forms. Jay
[web2py] Controller specific models
I've been unable to get my controller specific model to work in 1.96.4. Here's what I've got set up, can anyone point out the error? Controller: email.py, in app/controllers/email.py Model: email/settings.py in app/models/email/settings.py My understanding is that email/settings.py should be run for any page invoked in email.py. That isn't happening (verified with a print statement, just to make sure something else weird wasn't going on). Alternatively, if anyone has an example app that demonstrates using controller specific models, I can try running that to see if I've somehow broken web2py. Thanks, Jay
[web2py] Changing columns for TEXTAREA
I thought this might have gotten lost in the philosophical discussions about line breaks, so figured I'd post it as a separate thread: Using the advice given in a previous post, I'm doing this to try to change the rows and columns for a TEXTAREA: form=SQLFORM(db.contest,record=contest,submit_button=T(Save Changes),fields=[name,description],_style='width:100%') form.element('textarea')['_rows']=30 form.element('textarea')['_cols']=80 This works, in that the HTML output does have cols=80 and rows=30. And the number of rows does change appropriately. However, the number of columns displayed for the textarea does not change, despite the HTML having the right value. Is there something else that could be overriding the number of columns? Something in Javascript perhaps? Jay
[web2py] Two questions: one about markmin and one about SQLFORM
I've searched, but not found any information that helps me at my current level of web2py experience. Question 1: how do you insert a single line break (e.g. br/) in markmin? I've seen two spaces at the end of lines, but that doesn't seem to work for me. I've seen that you can use br as a separator instead of p, but that isn't what I want. I just want to put a single line break in specific spots in the content. Question 2: How can I alter the attributes of form elements using SLQFORM? Specifically, I want to change the number of rows and columns in a textarea, but I could see wanting to alter attributes of any form element. The answer is probably to create a custom widget for the field in the model, but I haven't been able to come up with anything that has any effect.
[web2py] Re: DB may not be updating fast enough...
Just a thought Jason. If this is happening on a MySQL database this may be the problem. This may have to do with transaction isolation. You may have to set the isolation level to READ-COMMITTED. Here is more info: http://www.databasejournal.com/features/mysql/article.php/3393161/MySQL-Transactions-Part-II---Transaction-Isolation-Levels.htm and http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html If database is not MySQL, what database and OS are you using? On Apr 16, 2:32 pm, Jason Brower encomp...@gmail.com wrote: When I do certain forms that jump back to a page listing all the items in that database, it doesn't include the new item I just added with that form unless I refresh the page. How do I fix such an issue? --- Best Regards, Jason Brower
[web2py] Re: Multi-Tenant Web2py
SAP the world's biggest ERP program uses the option #3 above. They can host many companies in one system (a system has only one database). Each company has a client number (3 digits). The login screen has four fields. 1. userid, 2. password 3. client# and 4. Language. In the data dictionary - that is the schema - SAP has a field named mandt (shortened german for client) in *every* table that houses user data, but not in tables used by the over all system. The clever thing their runtime does is translate all queries by adding a where clause to include the client number for tables that have the mandt field in them. This is important because users can program the system. Hence cross company data access is prevented. Do you plan to treat all your tenants identically? I have not had a need to do this. I have worked with SAP schema for many years, I just thought you might get some ideas from this. On Apr 11, 12:57 pm, pbreit pbreitenb...@gmail.com wrote: I'm not sure there are (m)any silver bullets. The three basic approaches are 1) separate DBs, 2) separate tables and 3) shared db/tables:http://msdn.microsoft.com/en-us/library/aa479086.aspx I don't know if there are an silver bullets for this so you might just have to brute-force code it. If the app is fairly simple, just check who's logged in and show the appropriate data. You might also research if Web2py's group functionality would help. Sorry, this isn't too helpful.
[web2py] Re: Dynamic virtual fields
Good one Serbitar. Much better than my solution. When I saw your I dont get it post, I was reminded of why JavaScript functions return functions instead of values. So they can capture the scope too. Now you have to call this every time you have to access this table, is that right? On Apr 10, 5:58 am, Serbitar rserbi...@googlemail.com wrote: OK got it. Lambda functions dont save their scope. Here is the right code: list = [a,b,c,d] fields = [] for entry in list: fields += [Field(entry, type=string)] db.define_table('test', *fields) class MyVirtualFields(object): pass def get_func(value): def func(self): return getattr(self.test, value) return fun for entry in list: setattr(MyVirtualFields, entry +_, get_func(entry)) db.test.virtualfields.append(MyVirtualFields())
[web2py] Re: Dynamic virtual fields
I use this method for generating totally dynamic forms. 1. Create an array, say out 2. Append Field(name, type, etc. etc.) to this array for all fields I need - note this is a string, no function calls 3. Wrap the above in an SQLFORM statement. formstring = 'SQLFORM.factory(' +','.join(out)+')' 4. Then eval the formstring to get the form form = eval(formstring) You can use a similar method to create a table in the database *** WARNING: I have not tested table creation, but it should work WARNING: You can create the table, but because the definition of the table in not in models dir, you will need to keep creating the table each time you want to access the table. If this table is to exist long term, you can write the generated text (like formstring in #3 above) to a file and manually include it in a model file. So to answer your question: Do #1-2 as above 3. Wrap the above in a define_table statement deftabstring = define_table('tablename,' + ','.join(out)+')' -- add migrate=... as necessary 4. Eval the deftabstring to create the table mytab = eval(deftabstring) Assuming you use 'db' to get to the database, you can now user db.tablename to get to your table. *Keep the second warning in mind.* Aside: Many people out there do not like the use of eval, and will criticize it right away. I use it when it is necessary. NEVER USE EVAL WHEN THERE IS CHANCE OF USER INPUT IN UNPROCESSED FORM BEING PART OF WHAT YOU EVAL, because you open a way to get hacked. NEVER FORGET THIS! This is where programming gets interesting. Jay On Apr 9, 7:34 am, Serbitar rserbi...@googlemail.com wrote: Sorry, misstyped and sent the message early. So once again: I can create database fields from a list like this: list = [a,b,c,d] fields = [] for entry in list: fields += [Field(entry, type=string)] db.define_table('test', *fields) Now I want to have a virtual field for each field in the list. Any way to do this? As virtual field names are not strings but function names I got no idea how to do this.
[web2py] Re: Major Speedup in trunk 10x
Thanks Jonathan and Massimo. This makes web2py EVEN more attractive for high end apps. I have one further request: A little history, I use web2py for all heavier lifting (forms and db processing etc.) but use Tornado for serving pages (see http://fon.st ) with links and redirecting links. I want to turn off DAL for some actions like the ones above. The model exists and it is being used for the 'heavy lifting', but for serving links and redirecting I am going through the cache and the loading happens if the request misses in the cache. If I could switch off DAL for either some actions OR some controller(s), I could replace the actions served by Tornado completely with web2py. Under Tornado I can currently serve about 850 URL re-directions per second (checked on the local server) if they are in cache, a lot slower if reading from db. Tornado is running behing Nginx. So, to translate http://host/CVGFsdf87 to http://google.com (assuming data in cache), what is the fastest way to do it using web2py? Regards, Jay On Mar 16, 1:57 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You should also thank Jonathan, we have been working together on this. Massimo On Mar 16, 11:40 am, Ross Peoples ross.peop...@gmail.com wrote: Ok, here are the results from testing the welcome app: BEFORE TRUNK UPDATE = Time taken for tests: 91.843 seconds Requests per second: 10.89 Time per request: 91.843 ms BEFORE TRUNK UPDATE WITH MIGRATE=FALSE AND BYTECODE COMPILED = Time taken for tests: 63.323 seconds Requests per second: 14.85 Time per request: 67.323 ms AFTER TRUNK UPDATE = Time taken for tests: 47.295 seconds Requests per second: 21.14 Time per request: 47.295 ms AFTER TRUNK UPDATE WITH MIGRATE=FALSE AND BYTECODE COMPILED = Time taken for tests: 29.588 seconds Requests per second: 33.80 Time per request: 29.588 ms As you can see, the improvements you made make a huge difference. I tested my own app as well, and that runs about 25% faster. Of course my app is not bytecompiled, and all of my tables are set to migrate=True since it is still being developed. Overall, I'd say this was a great addition to web2py. Great job Massimo!
[web2py] Custom functions in Model
Execute functions in Model Hi Guys, first i´ve to say i am n(oob)ew to Python and Database things, so please be patient. Is there any general way to execute custom functions in Model, which not only validate and how to implement them? I´ll try to explain with a few examples: First the simple one: I have a table with 2 fields: db.define_table(table1, Field(field1, string), Field(field2, string)) field1 is required so there should be two options: 1. the user enters something in field1 and field2 2. the user enters something in field1 and leaves field2 blank In the second case i want to use a function that takes the value from field1 splits the first word and then stores it in field2. something like: def function(): field1_value=word1 word2 word3 valuesplit= field1_value.split( )[:1] joinvalue= .join(valuesplit) return joinvalue Everthing should work from model... I have already tried the solution from the thread Populate field based no other fields: def _compute(): return request.vars.field1 Field(field2, string, compute=_compute It works but field2 wont be visible in appadmin. Second Example: I have 2 tables with 2 fields: db.define_table(table1, Field(field1, string), Field(field2, string)) db.define_table(table2, Field(field1, string), Field(field2, string)) Now user enters value in table1.field1 then funktion should split first part of the value then looking up if value is present in table2.field1 (.like(%value)) and if true store the table2.field2 value in table1.field2 Can anybuddy help? -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: Custom functions in Model
Hi, yes i think it is an requirement... because in my scenario the input for the first field is entered either by user via the form or by an script which only inserts this single value and the other field vlaues should be automatic generated by the functions in my Model. But may i be wrong? and there is another way to do this? The way from above works for automatic operations: def _compute(): return request.vars.field1.split( )[:1] Field(field2, string, compute=_compute) But as i said, its not visible in the form for the user. Thanks, JAY On 17 Feb., 13:00, Tiago Almeida tiago.b.alme...@gmail.com wrote: Why does everything need to work from model? Is it some requirement? Can't you do a function that takes the form and implements that logic? you can probably make it so that you pass that function to the onvalidation (or something like that) of the form.accepts.. Regards, Tiago On Wed, Feb 17, 2010 at 11:07 AM, JAY jwi...@web.de wrote: Execute functions in Model Hi Guys, first i´ve to say i am n(oob)ew to Python and Database things, so please be patient. Is there any general way to execute custom functions in Model, which not only validate and how to implement them? I´ll try to explain with a few examples: First the simple one: I have a table with 2 fields: db.define_table(table1, Field(field1, string), Field(field2, string)) field1 is required so there should be two options: 1. the user enters something in field1 and field2 2. the user enters something in field1 and leaves field2 blank In the second case i want to use a function that takes the value from field1 splits the first word and then stores it in field2. something like: def function(): field1_value=word1 word2 word3 valuesplit= field1_value.split( )[:1] joinvalue= .join(valuesplit) return joinvalue Everthing should work from model... I have already tried the solution from the thread Populate field based no other fields: def _compute(): return request.vars.field1 Field(field2, string, compute=_compute It works but field2 wont be visible in appadmin. Second Example: I have 2 tables with 2 fields: db.define_table(table1, Field(field1, string), Field(field2, string)) db.define_table(table2, Field(field1, string), Field(field2, string)) Now user enters value in table1.field1 then funktion should split first part of the value then looking up if value is present in table2.field1 (.like(%value)) and if true store the table2.field2 value in table1.field2 Can anybuddy help? -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/web2py?hl=en. -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py:37451] Re: Switch from http to https within app
I cant seem to make this work. I created the file in models and modified a url helper to use it and received the following error: TypeError: URL() got an unexpected keyword argument 'secure' A few follow up questions: 1. Did you intend to say 'model' rather than module? 2. How do I integrate 0_redefine_url.py into my app such that the URL helper will accept the keyword argument 'secure'? Thanks - Jay On Dec 17, 1:20 am, mdipierro mdipie...@cs.depaul.edu wrote: I do not think it is a idea because would encourage people to use it and build non-portable applications. If users were doing that, the applications may break when running on port 8000 or would break when being a proxy if it where to detect the port. There is no definitive way for the app to know the public URL. Moreover it would only form when called with URL(r=request,...) but not when called with URL(app,...) because it would have no knowledge of the request object. I think whether to use https and/or https should be handled outside the application. Massimo On Dec 16, 10:52 pm, Jonathan Lundell jlund...@pobox.com wrote: On Dec 16, 2009, at 6:58 PM, Álvaro Justen [Turicas] wrote: On Thu, Dec 10, 2009 at 20:50, mdipierro mdipie...@cs.depaul.edu wrote: I would suggest creating a model 0_redefine_url.py that contains: _URL=URL def URL(*a,**b): if not 'secure' in b: return _URL(*a,**b) elif b['secure']: del b['secure'] return 'https://'+request.env.http_host + _URL(*a,**b) else: del b['secure'] return 'http://'+request.env.http_host + _URL(*a,**b) and use URL(,secure=True), URL(...secure=False) as required I think this is very useful. Can we add this in trunk? It *would* be useful, I think. If URL() defaults secure=None ... Massimo 'https://'+request.env.http_host +'/app/default/logon') On Dec 10, 2:11 pm, Wes James compte...@gmail.com wrote: Actually, I don't think it would matter if there were a proxy or not?? On Thu, Dec 10, 2009 at 1:06 PM, Wes James compte...@gmail.com wrote: As long as you don't have a proxy between your users and the server something with request.env could be used def login(): if request.env.port != 443: redirect('https://'+request.env.http_host +'/app/default/logon') -wes On Thu, Dec 10, 2009 at 11:42 AM, Jay j...@unclehenrys.com wrote: I am new to web2py and Apache w/mod_ssl and I have been searching for a solution related to this topic but I must be missing a basic understanding of the necessary pieces in order to accomplish this. Our web2py apache setup seems to be fine. I can access our app's pages using both http and https if I manually add the 's' to the url. What we are trying to do is smoothly transition from one controller/ function using http to another using https. Example, a user arrives athttp://init/default/indexandthenthe user selects ‘Login’ and they are sent to https:/init/default/login. We need some controller functions to use http and some https. Can this be done from within the controller/function? If not, what is the ‘best practice’ approach to accomplishing this? - Jay --- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py:37468] Re: Switch from http to https within app
The file is named 0_redefine_url.py and is in my applications/init/ models folder. It contains: _URL=URL def URL(*a,**b): if not 'secure' in b: return _URL(*a,**b) elif b['secure']: del b['secure'] return 'https://'+request.env.http_host + _URL(*a,**b) else: del b['secure'] return 'http://'+request.env.http_host + _URL(*a,**b) Here is the complete traceback: Error traceback Traceback (most recent call last): File /home/jayr/workspace/newsite/app/gluon/restricted.py, line 178, in restricted exec ccode in environment File /home/jayr/workspace/newsite/app/applications/init/controllers/ profile.py, line 248, in module File /home/jayr/workspace/newsite/app/gluon/globals.py, line 102, in lambda self._caller = lambda f: f() File /home/jayr/workspace/newsite/app/gluon/tools.py, line 1418, in f return action(*a, **b) File /home/jayr/workspace/newsite/app/applications/init/controllers/ profile.py, line 199, in notes print_notes = URL(r=request, a=request.application, c='profile', f='notes_print', secure='True') TypeError: URL() got an unexpected keyword argument 'secure' Thanks, - Jay On Dec 17, 10:58 am, Jonathan Lundell jlund...@pobox.com wrote: On Dec 17, 2009, at 6:38 AM, Jay wrote: I cant seem to make this work. I created the file in models and modified a url helper to use it and received the following error: TypeError: URL() got an unexpected keyword argument 'secure' It might help to see the entire traceback. A few follow up questions: 1. Did you intend to say 'model' rather than module? 'models' 2. How do I integrate 0_redefine_url.py into my app such that the URL helper will accept the keyword argument 'secure'? The idea is to stick it in applications/yourapp/models/, which makes it visible to the entire app. The prepended '0' makes it sort to the beginning, so it's also available to the other model files. Thanks - Jay On Dec 17, 1:20 am, mdipierro mdipie...@cs.depaul.edu wrote: I do not think it is a idea because would encourage people to use it and build non-portable applications. If users were doing that, the applications may break when running on port 8000 or would break when being a proxy if it where to detect the port. There is no definitive way for the app to know the public URL. Moreover it would only form when called with URL(r=request,...) but not when called with URL(app,...) because it would have no knowledge of the request object. I think whether to use https and/or https should be handled outside the application. Massimo On Dec 16, 10:52 pm, Jonathan Lundell jlund...@pobox.com wrote: On Dec 16, 2009, at 6:58 PM, Álvaro Justen [Turicas] wrote: On Thu, Dec 10, 2009 at 20:50, mdipierro mdipie...@cs.depaul.edu wrote: I would suggest creating a model 0_redefine_url.py that contains: _URL=URL def URL(*a,**b): if not 'secure' in b: return _URL(*a,**b) elif b['secure']: del b['secure'] return 'https://'+request.env.http_host + _URL(*a,**b) else: del b['secure'] return 'http://'+request.env.http_host + _URL(*a,**b) and use URL(,secure=True), URL(...secure=False) as required I think this is very useful. Can we add this in trunk? It *would* be useful, I think. If URL() defaults secure=None ... Massimo 'https://'+request.env.http_host +'/app/default/logon') On Dec 10, 2:11 pm, Wes James compte...@gmail.com wrote: Actually, I don't think it would matter if there were a proxy or not?? On Thu, Dec 10, 2009 at 1:06 PM, Wes James compte...@gmail.com wrote: As long as you don't have a proxy between your users and the server something with request.env could be used def login(): if request.env.port != 443: redirect('https://'+request.env.http_host +'/app/default/logon') -wes On Thu, Dec 10, 2009 at 11:42 AM, Jay j...@unclehenrys.com wrote: I am new to web2py and Apache w/mod_ssl and I have been searching for a solution related to this topic but I must be missing a basic understanding of the necessary pieces in order to accomplish this. Our web2py apache setup seems to be fine. I can access our app's pages using both http and https if I manually add the 's' to the url. What we are trying to do is smoothly transition from one controller/ function using http to another using https. Example, a user arrives athttp://init/default/indexandthenthe user selects ‘Login’ and they are sent to https:/init/default/login. We need some controller functions to use http and some https. Can this be done from within the controller/function? If not, what is the ‘best practice’ approach to accomplishing this? - Jay --- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web
[web2py:37420] Re: Switch from http to https within app
Thanks very much for your suggestions. I created the file in models and modified a url helper to use it and received the following error: TypeError: URL() got an unexpected keyword argument 'secure' A few follow up questions: 1. Did you intend to say 'model' rather than module? 2. How do I integrate 0_redefine_url.py into my app such that the URL helper will accept the keyword argument 'secure'? Thanks - Jay On Dec 10, 5:50 pm, mdipierro mdipie...@cs.depaul.edu wrote: I would suggest creating a model 0_redefine_url.py that contains: _URL=URL def URL(*a,**b): if not 'secure' in b: return _URL(*a,**b) elif b['secure']: del b['secure'] return 'https://'+request.env.http_host + _URL(*a,**b) else: del b['secure'] return 'http://'+request.env.http_host + _URL(*a,**b) and use URL(,secure=True), URL(...secure=False) as required Massimo 'https://'+request.env.http_host +'/app/default/logon') On Dec 10, 2:11 pm, Wes James compte...@gmail.com wrote: Actually, I don't think it would matter if there were a proxy or not?? On Thu, Dec 10, 2009 at 1:06 PM, Wes James compte...@gmail.com wrote: As long as you don't have a proxy between your users and the server something with request.env could be used def login(): if request.env.port != 443: redirect('https://'+request.env.http_host +'/app/default/logon') -wes On Thu, Dec 10, 2009 at 11:42 AM, Jay j...@unclehenrys.com wrote: I am new to web2py and Apache w/mod_ssl and I have been searching for a solution related to this topic but I must be missing a basic understanding of the necessary pieces in order to accomplish this. Our web2py apache setup seems to be fine. I can access our app's pages using both http and https if I manually add the 's' to the url. What we are trying to do is smoothly transition from one controller/ function using http to another using https. Example, a user arrives athttp://init/default/indexandthen the user selects ‘Login’ and they are sent to https:/init/default/login. We need some controller functions to use http and some https. Can this be done from within the controller/function? If not, what is the ‘best practice’ approach to accomplishing this? - Jay -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/web2py?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py:36977] Switch from http to https within app
I am new to web2py and Apache w/mod_ssl and I have been searching for a solution related to this topic but I must be missing a basic understanding of the necessary pieces in order to accomplish this. Our web2py apache setup seems to be fine. I can access our app's pages using both http and https if I manually add the 's' to the url. What we are trying to do is smoothly transition from one controller/ function using http to another using https. Example, a user arrives at http://init/default/index and then the user selects ‘Login’ and they are sent to https:/init/default/login. We need some controller functions to use http and some https. Can this be done from within the controller/function? If not, what is the ‘best practice’ approach to accomplishing this? - Jay -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.