[web2py] web2py delimiters conflict with vue.jsz
I am currently running web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47. Even though that is old, it is meeting my needs. I am currently learning vue.js and hoping to include it in my offerings. The obvious problem is that both web2py and vue.js use "{{" and "}}" as delimiters in their templates. Is there a single place in web2py that I can change this to something else? In web2py\gluon\globals.py there is: class Response(Storage): and within the __init__ there is: self.delimiters = ('{{', '}}') Could this be the place? -- 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/810cc803-0448-402f-8d17-cd861f8af321%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Field set the default value +1 on insert
The following is something that I have used in MySQL. MySQL statement: CREATE TABLE IF NOT EXISTS autonumbering ( Year char(4) not null default '', Type varchar(10) not null default '', IDint(11) not null auto_increment, Notes varchar(64) not null default '', CreatedOn timestamp not null default current_timestamp, PRIMARY KEY (Year, Type, ID) ) ENGINE=MyISAM AUTO_INCREMENT=1; Code in a model: autoNumbering.define_table('autonumbering', Field('Year', 'string', length=4, notnull=True, default='', required=True, label='Year', readable=True, writable=True), Field('Type', 'string', length=10, notnull=True, default='', required=True, label='Type', readable=True, writable=True), Field('id','id'), Field('Notes', 'string', length=64, notnull=True, default='', required=False,label='Notes', readable=True, writable=True), Field('CreatedOn', 'datetime',notnull=True, default=datetime.datetime.now(), required=False,label='Created On', readable=True, writable=True), migrate=False ) Code in a module: def getWorkOrderNumber(Year): # Year is 4-digits, as in 2015 r = autoNumbering.autonumbering.insert(Year=Year, Type='WorkOrder') autoNumbering((autoNumbering.autonumbering.Year == Year) & (autoNumbering.autonumbering.Type == 'WorkOrder') & (autoNumbering.autonumbering.id == str(r - 1))).delete() return Year[2:] + session.CurrentYearPOLetter + str(r).rjust(5, '0') This returns a unique, sequential 5-digit number prefixed by the last two digits of the provided year. -- 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] ajax issue/question
I am encountering what I think is a weird problem with an ajax call. My web page contains an iframe, which is loaded with a normal controller/view web2py request. When a button is clicked that should cause the javascript in the iframe to send an ajax request to web2py, I am seeing only a request header in the FireBug console but not a response header. In debug code in the web2py controller, I display when the ajax request is received, and it is never executed. This is the same procedure I use for ajax all the time, but the only difference here is that it is executing within an iframe. What mistake did I make? -- 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: ajax issue/question
I am looking to reduce the amount of data transferred by making this page of my application behave like an SPA (single-page application). I have searching built into the master page, and then individual records are loaded into the iframe, one at a time. When a user wants another record, they can recall the search results in a pop-up, and select the next record into the iframe. The ajax call is from javascript running in the iframe to get the results in the iframe. The call is acting like it can't find the controller. FireBug shows the code being executed, but the debug code in the web2py controller is not showing the request being received. The code works if not run in an iframe. -- 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: how about setting a standard fadeout to response.flash?
How about including jQuery jNotify? http://www.myjqueryplugins.com/ On Tuesday, March 26, 2013 12:55:12 PM UTC-4, LightDot wrote: I prefer to keep web2py.js stock, to ease updates, so I add a similar fadeout js to layout.html when I need it. I'm not sure I'd alter the default though. App user can miss a message that fades out quickly, so I prefer to leave such decisions to the UI designer. We have apps that have flash messages with a fixed timeout (4-8 sec if I remember correctly), apps that have flash messages with no time out at all and apps entirely without flash messages. All this is a valid design approach and I see no benefit to changing the default, since one solution will never fit all usage cases. Perhaps it would benefit web2py users if fadeout was pre-set in code as a variable (ie. off or value in seconds)? It would be easier to hack the setting. But then again, web2py is a programming framework. web2py users are expected to know how to alter such things or at least search trough the docs and google groups. I like the idea of having flash messages with different categories (ie. error, warning, info), which could be treated differently (sticky, fadeout, different graphical design etc.). But isn't this pushing it too far..? I mean, isn't it getting too complex? It does sound like a nice idea, though... Regards, Ales On Tuesday, March 26, 2013 4:36:43 PM UTC+1, Mika Sjöman wrote: Hi Had a user pointing out how irritating it was that the response.flash never goes away automatically. Found this fix thou in the group, how about making a standard 4 second fadeout on it? in web2py.js: var flashBox = jQuery(.flash), flashTimer; flashBox.click(function(){ if (flashTimer) clearTimeout(flashTimer); flashBox.fadeOut(400, function(){jQuery(.flash).html('')}); }); flashTimer = setTimeout(function(){flashBox.fadeOut(400, function(){ jQuery(.flash).html('')});}, 4000); -- --- 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: using a virtual machine
I downloaded it - thanks. Too bad you can't get web2py to host it as a virtual appliance. It would certainly save people a lot of time. On Thursday, June 14, 2012 10:43:22 AM UTC-4, peter wrote: Okay, here you are. It is over 1GB so I will not leave it up too long. http://ukjazz.net/british_jazz/static/abc.vdi If you do chkconfig --add uwsgi_nginx chkconfig uwsgi_nginx on you will have both uwsgi and nginx set up as services that will start at boot up. 127.0.0.1 should bring up the welcome app. Peter On Thursday, 14 June 2012 05:37:40 UTC+1, Craig Matthews wrote: Hi. Can you put this vm image up and provide a link to it? On Wednesday, June 13, 2012 2:47:51 PM UTC-4, peter wrote: If you are setting up a website on a remote server you are hiring, then life is difficult. Setting things up often requires a lot of trial and error. Googling how to do it is useful but comes up with many many bum steers. Using a virtual machine on your own laptop with a duplicate of the operating system on the remote machine makes life a lot easier. I wasted a lot of time finding out how to best set up a virtual machine, so here are some tips to ease the path for other users. Use virtual box. This allows you to have snapshots. These are brilliant as they allow you to return the system to this point at a later date. So after each successful step you can take a snapshot. This really helps with the trial and error approach. Do not use livecds. Most operating systems income with a simpe livecd and a much larger multiple DVD installation. Do not use the livecds, these will cause unexpected and unpredictable problems. However the full installation approach works reliably. Use 1GB of ram for the virtual machine. When you do the installation of a linux OS, it rather alarmingly asks if it can format your hard disk, destroying all the data on it. It evens names your actual hard drive. However provided that it says the size of the disk is 8GB, then you can safely let it format the drive, it is only formatting the virtual drive not your hard disk. The easiest way of communicating between your normal OS and the virtual machine is via a flash USB drive. By clicking on 'devices' and then USB devices, you can switch the usb drive to work with either system (only one at a time). Clearly ensure all files are closed before switching the flash drive. The virtual box does successfully access the internet using a bridge with your main operating system's connection. I used this virtual box approach to develop a script for Nginx with Uwsgi and Web2py on Centos 5. This prevented my site being down for significant amounts of time. Peter
[web2py] Re: using a virtual machine
Hi. Can you put this vm image up and provide a link to it? On Wednesday, June 13, 2012 2:47:51 PM UTC-4, peter wrote: If you are setting up a website on a remote server you are hiring, then life is difficult. Setting things up often requires a lot of trial and error. Googling how to do it is useful but comes up with many many bum steers. Using a virtual machine on your own laptop with a duplicate of the operating system on the remote machine makes life a lot easier. I wasted a lot of time finding out how to best set up a virtual machine, so here are some tips to ease the path for other users. Use virtual box. This allows you to have snapshots. These are brilliant as they allow you to return the system to this point at a later date. So after each successful step you can take a snapshot. This really helps with the trial and error approach. Do not use livecds. Most operating systems income with a simpe livecd and a much larger multiple DVD installation. Do not use the livecds, these will cause unexpected and unpredictable problems. However the full installation approach works reliably. Use 1GB of ram for the virtual machine. When you do the installation of a linux OS, it rather alarmingly asks if it can format your hard disk, destroying all the data on it. It evens names your actual hard drive. However provided that it says the size of the disk is 8GB, then you can safely let it format the drive, it is only formatting the virtual drive not your hard disk. The easiest way of communicating between your normal OS and the virtual machine is via a flash USB drive. By clicking on 'devices' and then USB devices, you can switch the usb drive to work with either system (only one at a time). Clearly ensure all files are closed before switching the flash drive. The virtual box does successfully access the internet using a bridge with your main operating system's connection. I used this virtual box approach to develop a script for Nginx with Uwsgi and Web2py on Centos 5. This prevented my site being down for significant amounts of time. Peter
[web2py] Re: Dynamic MySQL Database selection
When a user logs on, there is a field in the profile that contains the designation of the database for the institution associated with that user. On Monday, May 14, 2012 4:54:54 PM UTC-4, Anthony wrote: The connection string in the call to DAL() can be determined dynamically based on information in the request, such as an arg or a subdomain. How do you determine which institution a given request is associated with? Anthony On Monday, May 14, 2012 3:21:39 PM UTC-4, Craig wrote: I am testing Web2Py for use at my institution. We serve several other institutions. I have each institution set up in its own database (as in use xxx;). How can this be accomplished with the DAL in Web2Py? Thank you.
[web2py] Re: Dynamic MySQL Database selection
Yes, there is a master database that has the database designation for the institutions. I guess one of the things I am unclear on is how granular the Web2Py framework is. Is there one db.py running for all sessions or is there a db.py running for each user session? If a db.py runs for for each user session independent of the other users, then customizing the DAL setup in the db.py should work. I wish there were more thorough documentation of the DAL. On Tuesday, May 15, 2012 10:49:05 AM UTC-4, Anthony wrote: On Tuesday, May 15, 2012 10:13:42 AM UTC-4, Craig wrote: When a user logs on, there is a field in the profile that contains the designation of the database for the institution associated with that user. Does that mean there's a master database that stores the user records so you can access it to log in the user (i.e., before you know the user's institution and therefore database)? In that case, maybe something like this in the db.py model file: auth_db = DAL('[auth db URI]') from gluon.tools import Auth auth = Auth(auth_db, hmac_key=Auth.get_or_create_key()) if not auth.user and not request.function == 'user': redirect(URL('default', 'user')) auth.define_tables() db = DAL(auth.user.db_uri if auth.user else None) If the user isn't logged in, that will redirect to the /default/user URL for login. Note, the URI for the call to DAL() that defines the db connection is either auth.user.db_uri (when the user is logged in) or None. The reason for the None is so you still have a db instance when the user is going to the /default/user URL for login (otherwise, any subsequent db.define_table calls would generate errors). I think None will work, but if not, you could also use a dummy 'sqlite:memory' URI, or even a regular SQLite URI. Anthony
[web2py] Re: Dynamic MySQL Database selection
Thank you very much Anthony. That is exactly what I was looking for. When I started this project, I read the first few chapters, but then dived in. I must have missed the thread part. On Tuesday, May 15, 2012 6:46:33 PM UTC-4, Anthony wrote: I guess one of the things I am unclear on is how granular the Web2Py framework is. Is there one db.py running for all sessions or is there a db.py running for each user session? If a db.py runs for for each user session independent of the other users, then customizing the DAL setup in the db.py should work. I wish there were more thorough documentation of the DAL. I think the DAL is fairly well documented. This isn't really a question about the DAL, though, but about the workflow of requests coming into a web2py application. It might help if you review http://web2py.com/books/default/chapter/29/1#Model-View-Controller and http://web2py.com/books/default/chapter/29/4#Workflow. Note, the db.py file is freshly executed (in a separate thread) for each request that comes into the application. So, you can dynamically determine the database URI for a given request, and it will only apply to that particular request. Anthony
[web2py] Dynamic MySQL Database selection
I am testing Web2Py for use at my institution. We serve several other institutions. I have each institution set up in its own database (as in use xxx;). How can this be accomplished with the DAL in Web2Py? Thank you.