[web2py] Re: pagination issue redirecting to the current page
Put information about the current page in the request.args dictionary. You could use the session, but if your user opens a second browser window it becomes difficult to keep track of which session data corresponds to which browser tab. On Friday, November 14, 2014 8:37:25 PM UTC-5, Joe wrote: I am working on an app where the user can select items by clicking on a button for each item on the index page. It works fine, except after each item selected the user has to be redirected to index and ends up on the top of the first page at item 1. Then the user has to go back each time and try to find whatever page they were on before when they made the last selection. How can I fix this so when the user selects the item, he is redirected to the same page? def index(): if len(request.args): page=int(request.args[0]) else: page=0 items_per_page=11 limitby=(page*items_per_page,(page+1)*items_per_page + 1) rows=db().select(db.post.ALL, limitby=limitby) form = SQLFORM(db.post) if form.process().accepted: redirect() selected = db(db.post.selected == True).select() not_selected = db(db.post.selected == False).select() return dict(form=form, selected=selected, not_selected=not_selected, rows=rows, page=page, limitby=limitby,items_per_page=items_per_page) def select(): id = request.vars.id name = db(db.post.id == id).select().first() if name: name.selected = not name.selected name.update_record() return redirect(URL('index')) -- 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: second page to be accessed only from first page
I believe the book is correct. Are you sure the redirect doesn't work? request.function should be second if that was the requested function. The redirect occurs after the request is parsed. On Saturday, November 15, 2014 4:58:15 AM UTC-5, T.R.Rajkumar wrote: In book chapter 3 overview the following is given to restrict access to second page. if not request.function=='first' and not session.visitor_name: redirect(URL('first')) But if I print request.function it says 'second'. How to restrict access to second page only from first page? -- 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: Query of two dates sql server
The online manual explains it here: http://web2py.com/books/default/chapter/29/07/forms-and-validators#Date-and-time-validators If I recall correctly, it may also be necessary to make an entry in your language dictionary. But try it first without such an entry. On Monday, November 17, 2014 5:49:57 PM UTC-5, José Eloy wrote: Hi! I'm having troubles in making a query with 2 dates in SQL Server 2005. First, my table definition: db2.define_table('tabla_datos', Field('na', requires=IS_NOT_EMPTY()), Field('fecha', 'datetime', requires=[IS_NOT_EMPTY(), IS_DATETIME(format=T(%d/%m/%Y %H:%M:%S), error_message='Debe ser DD-MM- HH:MM:SS!')]), Field('ta', db2.tipos_de_asunto), Field('unidad', requires=IS_NOT_EMPTY()), Field('operador'), Field('carta', requires=IS_NOT_EMPTY()), Field('importe', 'decimal(15,2)', requires=IS_NOT_EMPTY()), Field('observaciones') ) In my controller I receive from a form (via ajax) two dates for searching in the database: def busca_consulta(): num_asunto = request.post_vars.input_na desde = request.post_vars.input_desde # User write a date using the Web2py widget. Format: %d/%m/%Y (time is not necessary) hasta = request.post_vars.input_al # User write a date using the Web2py widget. Format: %d/%m%Y (time is not necessary) rows= db2(((db2.tabla_datos.fecha=desde) (db2.tabla_datos.fecha=hasta)) (db2.tabla_datos.na ==num_asunto)).select() but I get error, Is it necessary to convert the variables desde and hasta to datetime? How can I convert them? I've checked the SQL Server datetime format, the datetime is saved in the records using the following format: %Y-%d-%m %H:%M:%S. I live in Mexico, the format we use is: %d/%m/%Y %H:%M:%S My english is not very good, I hope you can understand me. Regards. -- 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 do you issue a command to the operating system in web2py?
Why do you want to do that? On Friday, November 14, 2014 4:01:25 PM UTC-5, BitHui wrote: I'm trying to run a shell command in Linux from web2py? Is that possible and how would you accomplish that? Thanks in advance. -- 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: import app from one web2py server to another
Is there a modules/__init__.py ? On Monday, November 10, 2014 2:44:44 PM UTC-5, John Davis wrote: Hello I have an app written by someone which runs on our server. I have tried to copy this app from one server to a new one which also runs web2py. I use the admin site GUI for web2py to import the app, but when I try to run it, I get the following error. error: type 'exceptions.ImportError'(No module named configuration) I have a modules/configuration.py file and I also have a modules/configuration.pyc file. The stack trace shows that the code which generates the error looks like this: from configuration import local_time -- 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] Odd field validation issue
This field will not fail validation when submitted empty. Web2py 2.8.2 with lazy tables and archiving. REQUIRE_MSG = SPAN('Required', _style=color:orange;) Field( 'problem_title', length=512, required=True, comment=REQUIRE_MSG, ) Written this way, it works. Field( 'problem_title', length=512, required=True, comment=REQUIRE_MSG, requires=IS_LENGTH( minsize=1, maxsize=512, error_message='Problem title cannot be empty. Max 512 characters.' ) ) I didn't expect this ... -- 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: Odd field validation issue
OK, except I have other apps where required=True works as expected, that is, it causes a validation failure when the field is submitted empty. These other apps are running on the same Web2py instance, so this is puzzling. On Tuesday, November 11, 2014 10:54:21 AM UTC-5, Willoughby wrote: I think one is for forms, one is for the insert. From the book: Notice that requires=... is enforced at the level of forms, required=True is enforced at the level of the DAL (insert), while notnull, unique and ondelete are enforced at the level of the database. While they sometimes may seem redundant, it is important to maintain the distinction when programming with the DAL. On Tuesday, November 11, 2014 10:36:41 AM UTC-5, Cliff Kachinske wrote: This field will not fail validation when submitted empty. Web2py 2.8.2 with lazy tables and archiving. REQUIRE_MSG = SPAN('Required', _style=color:orange;) Field( 'problem_title', length=512, required=True, comment=REQUIRE_MSG, ) Written this way, it works. Field( 'problem_title', length=512, required=True, comment=REQUIRE_MSG, requires=IS_LENGTH( minsize=1, maxsize=512, error_message='Problem title cannot be empty. Max 512 characters.' ) ) I didn't expect this ... -- 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] In views: using globals().get('somevalue') vs response.somevalue in views
In views we might use code something like this {{bar = globals().get('foo')}} {{if bar:}} div Got bar! /div {{pass}} Why not just use the response instead? {{if response.foo:}} div Got foo! /div {{pass}} Seems like it would be less code, one less function call. Anything wrong with it? -- 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] Coding gotcha: views process commented-out html, can raise exceptions
Code like the following will raise an exception in a view. {{ foo='bar' # fubar='nothing' }} !-- input type=text value={{=fubar}} -- Even though the html is commented out, Web2py will process it and try to find an object named fubar. Since it's not defined in the view, you get an exception. I mention this because (a) it's puzzling the first time it happens and (b) it can take some time to figure out what's really going on. -- 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: In views: using globals().get('somevalue') vs response.somevalue in views
I would set response.foo in the controller. By attaching foo to the response object I don't have to put it in the return dictionary. Saves code on the controller side, too. On Friday, November 7, 2014 9:01:08 AM UTC-5, Leonel Câmara wrote: Nothing wrong with it. To me the globals way advantage is that it seems odd to me to have: {{response.foo = True}} {{extend 'layout.html'}} In a view. instead of: {{foo = True}} {{extend 'layout.html'}} -- 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: Coding gotcha: views process commented-out html, can raise exceptions
To be clear, I'm not arguing against the behavior. It just wasn't intuitive to me so I put it in the mental gotcha file. On Friday, November 7, 2014 9:47:11 AM UTC-5, Anthony wrote: For a more intuitive understanding of this behavior, consider that HTML comments are not excluded from the actual HTML markup -- they are merely instructions to the browser to ignore what's inside the comment (i.e., don't attempt to render it). The web2py template system generates HTML markup (among other things), and because an HTML comment is intended to be generated as part of the markup, there is no reason for the template system to ignore it. In fact, in some cases you may even need to execute template code inside a comment (e.g., it used to be common to wrap Javascript code inside an HTML comment tag to accommodate older browsers), so it would not be desirable for the template code inside HTML comments to be ignored. Anthony On Friday, November 7, 2014 9:03:34 AM UTC-5, Cliff Kachinske wrote: Code like the following will raise an exception in a view. {{ foo='bar' # fubar='nothing' }} !-- input type=text value={{=fubar}} -- Even though the html is commented out, Web2py will process it and try to find an object named fubar. Since it's not defined in the view, you get an exception. I mention this because (a) it's puzzling the first time it happens and (b) it can take some time to figure out what's really going on. -- 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: postgreSQL: restoring pg_dump using executesql
Do this instead: psql -U your web2py user - h localhost -d your web2py database your_dumpfile.sql psql will ask you for a password. Use your web2py user's password. Create the database first, but don't create any tables or anything else. On Wednesday, October 8, 2014 12:18:50 PM UTC-4, Manuele wrote: Hi! Is there a way to restore a dump from an sql file that comes from a pg_dump command using in someway the database object defined in my model for example using the executesql method? I ask because I tried without success... it raises the sequent error in corrispondence of the line where data start after tables definition: ProgrammingError: ERRORE: errore di sintassi a o presso 2644 LINE 107: 2644 {hide: false, uuid: 1:0, grp: 1, state: 1, e... Thanks a lot Manuele -- 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: Deploy Web2py on Windows Server 2008 VPS on godaddy
Sorry, no can help. On Friday, September 26, 2014 6:12:06 AM UTC-4, Viren Patel wrote: Hi Cliff, Actually i have already done investment in Server with godaddy for a year Let me know if you have done web2py with Windows Regards, Viren On Thu, Sep 25, 2014 at 8:57 PM, Cliff Kachinske cjk...@gmail.com javascript: wrote: Viren, There are better hosting solutions available. Pythonanywhere, for example, supports Webg2py out of the box. On Thursday, September 25, 2014 10:41:21 AM UTC-4, Viren Patel wrote: Hi all, i have bought the Windows server 2008 to deploy my Web2py application Wanted to know following Can i run on server using the Rocket server itself Do i need to have Apache running to host Web2py application There is just one Root Directory, where and how do i place my web2py applicaiton how do i start web2py server on the VPS Any one had similar deployment on Windows 2008. please let me know or if any useful links Regards, Viren -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Javascript in web2py view
First thing, read up on the ajax functionality in Web2py. It's way simpler than jQuery ajax and will work just fine for what you want to do.l Consider using the :eval target in Web2py ajax. It will allow you to send JavaScript snippets back to the server. That way you can do things like this on the server side: Function get_config_details(): try: # Your code goes here return $('#resultip').html(data); except: return $('.flash').text('Server has experienced an error. Please refresh the page.'); Also: What does the url going back to the server look like? It should be something like http://localhost/application/controller/function Use the network tab in Firebug or Chrome developer tools to watch the conversation between browser and host. Your JavaScript looks OK to me except I'm suspicious about that url. Or maybe your Web2py code is raising an exception. On Thursday, September 25, 2014 11:07:43 AM UTC-4, Sif Baksh wrote: I have this script that I've used with PHP and it works, but I'm moving everything from PHP to Web2PY easy to deploy to coworkers. PHP page (I left out the PHP part of the code that makes a REST API call to an appliance) html lang=en head meta charset=utf-8 / titleGet Current Running Config/title script src= https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js /script /head body h2Get Current Running Config/h2 Choose a Device Namebr select name=selectFrequency id=selectFrequency option value=- Select -/option ?php foreach ($json_a['devices'] as $devname) { echo option value=. $devname['DeviceID'].. $devname['DeviceName'] ./option; } ? /select div id=resultip/div script $(document).ready(function(){ $(#selectFrequency).change(function() { var selected = $(this).val(); $.ajax({ url: get.php, type: GET, data: {id : selected}, success: function(data) { $('#resultip').html(data); } }); }); }); /script /body /html Here is my view page: Enter code here...html lang=en head meta charset=utf-8 / titleGet Current Running Config/title script src= https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js /script /head body h2Get Current Running Config/h2 Choose a Device Namebr select name=selectFrequency id=selectFrequency option value=- Select -/option {{for tmp_name,tmp_id in zip(names,id):}} option value={{=tmp_id}}{{=tmp_name}}/option; {{pass}} /select div id=resultip/div script $(document).ready(function(){ $(#selectFrequency).change(function() { var selected = $(this).val(); $.ajax({ url: get_config_details, type: GET, data: {id : selected}, success: function(data) { $('#resultip').html(data); } }); }); }); /script /body /html I get the drop down populated correctly with all the device names. But when I select a device name it calls get_config_details with ?id=43 I changed it using the inspect element in the browser to get_config_details/43 still nothing shows up on the page. Any advice or am I approaching this incorrectly Thanks in advance Sif -- 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: class 'sqlite3.IntegrityError' foreign key constraint failed
This post on StackOverflow may help http://stackoverflow.com/questions/9636053/is-there-a-way-to-get-the-constraints-of-a-table-in-sqlite There is a code snippet you might try. On Monday, September 22, 2014 5:01:11 PM UTC-4, Anna Kostikova wrote: Hi everyone, I am having an issue when editing content of one of the tables in my database. When I try to edit a record in the table I have an error message class 'sqlite3.IntegrityError' foreign key constraint failed. The bizarre thing is that it doesn't matter which column I am trying to edit (via appadmin control panel) - i have exactly same message. For instance, I have a column description that doesn't have any keys on it (or references), but I can't edit the content of this field and I keep getting the error above. What might be causing the issue? I am using python 2.7.7 and web2py 2.9.5 Thanks Anna -- 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: Deploy Web2py on Windows Server 2008 VPS on godaddy
Viren, There are better hosting solutions available. Pythonanywhere, for example, supports Webg2py out of the box. On Thursday, September 25, 2014 10:41:21 AM UTC-4, Viren Patel wrote: Hi all, i have bought the Windows server 2008 to deploy my Web2py application Wanted to know following Can i run on server using the Rocket server itself Do i need to have Apache running to host Web2py application There is just one Root Directory, where and how do i place my web2py applicaiton how do i start web2py server on the VPS Any one had similar deployment on Windows 2008. please let me know or if any useful links Regards, Viren -- 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: ssl certificate?
+1 on Namecheap On Monday, September 15, 2014 10:16:12 AM UTC-4, Anthony wrote: For non-free certificates, various Comodo, GeoTrust or Thawte resellers have certificates in the 5 to 30 USD per year range (email / domain verification). If you need business entity verification, prices are higher. In any case, prices have plummeted in the last few years The $59.90 cert from StartSSL is probably about the cheapest wildcard cert you can get (allows unlimited subdomains). The lower cost ones mentioned above are typically for single domains (no wildcard). Namecheap.com seems to be a good place for discounted certs (relative to the price of buying direct from the CA). Anthony -- 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: Customize SQLFORM.grid
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#format--Record-representation Not entirely sure if the record representation technique will work, but maybe you could use the lambda to call a named function that renders the divs for each thumbnail. I think the css will be the hard part. maybe you could subclass SQLFORM. If I recall correctly, there are just a few lines of code that actually create the index table. Good luck. On Wednesday, September 10, 2014 1:35:12 AM UTC-4, Luciano Laporta Podazza wrote: Hello, I would like to take advantage of SQLFORM.grid search, listing and pagination capabilities to generate a listing from a table, but I need to customize the resulting rows like this: https://lh3.googleusercontent.com/-TbnhU4p9EOw/VA_hxFcXi_I/BYI/Ti2JNW4AdAg/s1600/Screen%2BShot%2B2014-09-10%2Bat%2B02.23.35.png Until now I only have this: users = SQLFORM.grid(db.users,fields=[db.users.id, db.users.first_name, db.users.last_name], headers={'users.id':'id','users.first_name':'Nombre', 'users.last_name':'Apellido'}, sortable=False, deletable=False, editable=False, create=False, csv=False, formstyle=div) Which results into this: https://lh4.googleusercontent.com/-E7cySzUy2Bw/VA_iuQU_5CI/BYQ/n5mLgALWJcs/s1600/Screen%2BShot%2B2014-09-10%2Bat%2B02.33.16.png I'm using Bootstrap 3. Any help will be appreciated. -- 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: Strange but useful THEAD trick!
Are you sure that's a feature and not a bug? On Wednesday, September 10, 2014 3:32:24 AM UTC-4, Joe Barnhart wrote: I often use the web2py helpers to build my tables on the fly. I've always thought it was strange that my THEAD() helper seemed to prefer wrapping its components inside a TD element instead of a TH. I mean, why not a TH? We already know its in a header. Playing around, I found this pattern works perfectly to wrap its members in TH instead of TD: THEAD( [ ('head1', 'head2', etc...) ] ) So if I create a TUPLE (not a list), wrap it in a LIST, and then hand it to THEAD, it creates TH elements inside the THEAD. Every other construction I've tried returns TD inside instead. -- Joe -- 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] map weirdness
Does anyone have a clue why this code def make_option(row): return OPTION(row[1], _value=row[0]) q = ''' SELECT id, name FROM products WHERE is_active = 'T' AND tenant_link = {} AND is_container ORDER BY name '''.format(self.tenant_link) rows = self.db.executesql(q) myselect = SELECT( OPTION('Choose'), map(make_option, rows), _id='container_selector', _name='container_selector', ) print XML(myselect) Would produce this result. Line breaks added for clarity. Comes out the same if not pushed through XML(). select id=container_selector name=container_selector option value=ChooseChoose/option option value=[lt;gluon.html.OPTION object at 0x7fa4bcfc1a50gt;, lt;gluon.html.OPTION object at 0x7fa4bcfc1a90gt;, lt;gluon.html.OPTION object at 0x7fa4bcfc1ad0gt;, lt;gluon.html.OPTION object at 0x7fa4bcfc1b10gt;, lt;gluon.html.OPTION object at 0x7fa4bcfc1b50gt;] option value=338OH Blue Drum/option option value=334RoCon Square Fiber Drum/option option value=335Round Fiber Drum/option option value=308TH Blue Drum/option option value=305Tote/option/option /select If I do this, it works as it should select = SELECT( OPTION('Choose'), _id='container_selector', _name='container_selector', ) for r in rows: select.append(OPTION(r[1], _value=r[0])) -- 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: map weirdness
Python does as below. SELECT does otherwise. I was curious as to why. In [1]: foo = ['bar', 'baz', 'bazzle'] In [2]: def func(str): ...: return 'fu{}'.format(str) ...: In [3]: map (func, foo) Out[3]: ['fubar', 'fubaz', 'fubazzle'] In [4]: def printem(lis): ...: for l in lis: ...: print l ...: In [5]: printem(map(func, foo)) fubar fubaz fubazzle On Wednesday, September 10, 2014 5:01:49 AM UTC-4, Leonel Câmara wrote: You need to argument expand (using *) the result of the map in the first case. myselect = SELECT( OPTION('Choose'), *map(make_option, rows _id='container_selector', _name='container_selector', ) -- 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: map weirdness
Got it. That's why I need to unpack the list. I even knew that. (palm to forehead) On Wednesday, September 10, 2014 11:23:41 AM UTC-4, Anthony wrote: SELECT is not expected to behave like your printem() function, which merely takes a list. SELECT can either take a list, or it can take a set of positional arguments. In your case, however, you have passed it one positional argument followed by a second positional argument that happens to be a list. It is not designed to take inputs this way. Either give it a single list (and no additional positional arguments): myselect = SELECT([OPTION('Choose')] + map(make_option, rows)) or give it only individual positional arguments (using * to expand your list into positional arguments): myselect = SELECT(OPTION('Choose'), *map(make_option, rows)) Anthony On Wednesday, September 10, 2014 10:10:47 AM UTC-4, Cliff Kachinske wrote: Python does as below. SELECT does otherwise. I was curious as to why. In [1]: foo = ['bar', 'baz', 'bazzle'] In [2]: def func(str): ...: return 'fu{}'.format(str) ...: In [3]: map (func, foo) Out[3]: ['fubar', 'fubaz', 'fubazzle'] In [4]: def printem(lis): ...: for l in lis: ...: print l ...: In [5]: printem(map(func, foo)) fubar fubaz fubazzle -- 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] a proposal for form improvement
SQLFORM is still gonna be there, just deprecated. Which I believe means bug fixes only at this point. As long as there are gluon.html and gluon.sqlhtml you can continue as accustomed. On Friday, September 5, 2014 1:06:17 PM UTC-4, viniciusban wrote: I don't agree with killing a way to send formed html to client. Web2py is for backend development, in spite of most clients run js, some of them, don't. There are non-js clients. wget is one of them. I know, it's not widely used, but depending on your application, it is a client of it. As I explained at the other message, I don't agree with killing a way to generate backend form html. On Fri, Sep 5, 2014 at 2:56 AM, Massimo Di Pierro massimo@gmail.com javascript: wrote: Please find attached a welcome4.zip with contains the following files: controllers/default.py views/layout.html vides/default/index.html modules/jform.py static/js/jform.js static/js/jform-bootstrap2.js static/js/jform-bootstrap3.js My proposal is the following: 1) deprecate SQLFORM (but keep it for backward compatibility) 2) replace form = SQLFORM(table).process() ... {{=form}} with form = JForm(table) ... {{=form}} what is the difference? SQLFORM generates html. JForm generates JSON metadata which is then converted into the form client-side by the js in jform.js. why? - it is much faster because all rendering is done client-side - it can optionally submit the form via Ajax without having to change your code. - it is much easier to style and create widgets for different css frameworks. For example include the right one: static/js/jform-bootstrap2.js static/js/jform-bootstrap3.js (I only provide a layout for bs2 and not bs3) - it is much more powerful because you can customize widgets in JS. We could also add a JTable, a JMenu and a JLogin and keep all the styling info in JS files as opposed to Python files. This would make web2py leaner and cleaner. Thoughts? Massimo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Philosophical help with REST
Your table primary key doesn't have to be an integer. Maybe you could abbreviate the club names and slugify them using IS_SLUG. Of course you then will have to jump through some legacy table hoops with the DAL. -- 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: two forms submitted into the same cotroller
Here is what I do. Your page should have one form only. Make 2 divs. Top div has your fixed fields including the one that triggers the variable content. Use jquery to catch the change event for the field. When the field changes send an Ajax request to the server. Let the server build the variable form and return it to the server to populate the second div. I build the individual form elements rather than using FORM or SQLFORM. That way I avoid form within a form problems. -- 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] smartgrid form submit button behaviour
Why not use a drop down field? -- 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: (Very) Slow raw SQL queries
Why is '\n', the newline character, sprinkled throughout your query? See what happens if you get rid of them. On Monday, August 25, 2014 4:54:53 AM UTC-4, Mehmet A. wrote: Hi, db.executesql() takes 30 seconds to return a result while page-loading, despite the fact that same query takes 0.5-1 second if I try it on MySQL console or web2py debug console or web2py shell. [4] dbs._timings [('SELECT 1;', 0.01632424926758), ('SET FOREIGN_KEY_CHECKS=1;', 0.00348501586914), (SET sql_mode='NO_BACKSLASH_ESCAPES';, 0.00800013542175293), (SELECT TIMESTAMPDIFF(...) AS 'duration',\n TIMESTAMPDIFF(...)\n - INTERVAL 1 HOUR, TIMESTAMP(...)\n + INTERVAL CAST(...) AS 'timediff',\n ris.ODATE as 'date',\n CONCAT(...) as 'service'\n FROM ... AS ris\n JOIN ... as sd on ris = sd\n WHERE ris != '-00-00 00:00:00'\n and ris != '-00-00 00:00:00'\n and ris = '2010-8-15'\n and ris = '2014-8-22', 32.046038147), (SELECT TIMESTAMPDIFF(...) AS 'duration',\n TIMESTAMPDIFF(...)\n - INTERVAL 1 HOUR, TIMESTAMP(...)\n + INTERVAL CAST(...) AS 'timediff',\n ris.ODATE as 'date',\n CONCAT(...) as 'service'\n FROM ... AS ris\n JOIN ... as sd on ris = sd\n WHERE ris != '-00-00 00:00:00'\n and ris != '-00-00 00:00:00'\n and ris = '2010-8-15'\n and ris = '2014-8-22', 0.6069998741149902)] The query that took 32 seconds was executed with the page request. The controller was falling to the debug console after db.executesql(), so the second query which took 0.6 second was executed by me on the same session. -- 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] Slow first time access on production with Ubuntu/NGINX/UWSGI
The install script in the book may not be correct for your version of Web2py. A good first step might be to check the script's config settings against the ones from the book. On Wednesday, August 20, 2014 4:49:28 PM UTC-4, Jim S wrote: I did this and after waiting 45 minutes and re-testing, it did not exhibit the slow behavior. Since this is a test without running nginx/uwsgi I'm assuming my problem is in one of those layers. Also, I access the production site with http instead of https, the slowness isn't there either. -Jim On Wednesday, August 20, 2014 2:26:35 PM UTC-5, Richard wrote: You can check that with profiler : python web2py.py -a 'asdf' -i 127.0.0.1 -p 8000 appname -F fileNameForProfilerDumpInfo' Your app will be very slow with profiler. Richard On Wed, Aug 20, 2014 at 3:24 PM, Richard Vézina ml.richa...@gmail.com wrote: Could your app take time to create global vars and after they are cached up? Richard On Wed, Aug 20, 2014 at 1:32 PM, Jim S j...@qlf.com wrote: Hi I've installed web2py on my ubuntu machine using the script at the bottom of this section in the book: http://web2py.com/books/default/chapter/29/13/deployment-recipes#Nginx It is all working well except for one annoyance. If I leave the let the page site for a while (haven't really determined the time period needed to display the behavior), when I come back later my first access to the application is really slow, like 10 seconds to display the page. But, after that, it clicks along with sub-second response time. Anyone have any idea what is going on or where to begin trouble-shooting? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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: one-to-many relations and form for crerate records
Here is what I would do. On the client have a var contact_count = 0 All of your starting contact fields will have a suffix __0 When the user clicks the add contact button, use Javascript to increment the contact_count and write another set of contact fields. This time set the suffix to __1 Increment the number in the suffix accordingly each time the user clicks the add contact button. Use form submission as usual. In the controller you can link the sets of contact fields together by the suffix number. On Saturday, August 16, 2014 9:44:09 AM UTC-4, Kirill Shatalaev wrote: Hello. This is just a simple example, my actual model is more complex, but I think I can explain the main idea. Model: db.define_table('users', Field('name', 'string')) db.define_table('contacts', Field('user', db.users), Field('phone', 'string')) Well, each user can have from 1 to infinite phone numbers. I want user entering all his numbers while registering. So, what are the ways to realize it? 1) Split registration process to steps, step one - enter name, step two - add phones one by one. Ugly. 2) Use smartgrid. Have parent-children out of the box. Being, may be, cool tool for admin purposes, it is absolutely unintuitive and unusable for end-users. 3) Make custom form with jquery: form have button add another phone number, user press the button and another text field adding dynamicaly for the infinite form. Excellent way. But. This is theoretically. And I cant find any practical examples. So, testing I can see that inputs with same name processing by web2py as a list, its fine! For example, there is a duplicated inputs in the form: input name=phone type=text input name=phone type=text after submitting, I have ['123456','345678'] on form.vars.phone. Cool. Cycle and do db.insert() voila, you say! No. Linked table contacts actually is more more complex. It have address string, state string, postal, validators and another linked tables such postals, cities, etc, etc... And I have no idea how build my form and how to process my form vars within controller with all contact table validators? Is there any elegant way doing this? Found this: http://www.web2pyslices.com/slice/show/1427/single-form-for-linked-tables not so helpful. -- 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: Strange ajax problem
Michael, one final thought. To get a better handle on what's going on, in Chrome or Firefox press F12 to bring up the developer tools. Click the Network tab and play around with submitting your forms. You can look at the entire conversation. On Friday, August 15, 2014 8:55:41 AM UTC-4, Michael Beller wrote: Perfect - I can't thank you enough! I saw the code in index right after I sent my other message, I was looking for display_page. Not sure what I did wrong last night (probably just a case of staring at code too long) but I see how you added the $.web2py.enableElement. I just went back and read the OP and I think this is the answer to all the problems mentioned. Your explanation along the way was also very helpful. Thanks again! On Friday, August 15, 2014 8:44:39 AM UTC-4, Leonel Câmara wrote: I used default/index.html, return_data doesn't need a view as it uses generic.json -- 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: CSS issue with embedded form
That's kind of an inappropriate use of the h2 tag for starters. Why not put it inside a div class=fake-h2/div tag set and style fake-h2 however you like. On Wednesday, August 13, 2014 11:30:27 PM UTC-4, Joe wrote: I am just learning web2py and I love it!!! I am experimenting with it so I can learn it. THE QUESTION: I use my own HTML and CSS. I embedded a form in the HTML like so h2{{=form}}/h2 The form is displayed fine and works perfectly, however, it just floath left no matter what I do in the page. I placed the {{=form}} in the HTML inside a class which is controlled by my CSS, but my CSS controls everything on that class except the position of the form. The form's text is fine, but the position is not. I kind of want this form in the middle. -- 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: float usage; 2 decimals
What database? Web2py has a decimal datatype which, in my use cases, mimics the Python decimal datatype. I use Postgresql and the adapter turns Python decimal into Postgres numeric. Both of these types act like real world decimal numbers. In other words, .2 + .1 comes out to .3. Of course a different db backend will work differently. Just google python decimal. On Friday, July 11, 2014 5:50:30 AM UTC-4, Stefan van den Eertwegh wrote: Hi, I have a float type in the define tables and when he inserts 3.50 into the database he makes 4.0 off it. How comes that it rounds off the float? And not uses the usage of 2 decimals? Thank you! -- 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: Strange ajax problem
Aha, I get what you're doing now. Maybe the simple answer is don't use a submit button. Try something like input type=button class=submit-button id= something_created_server_side You may have to mess around with the css a bit to get the vertical alignment and height right. This will work around the client side handlers. On Thursday, August 14, 2014 4:20:05 PM UTC-4, Michael Beller wrote: Thanks Cliff and Niphlod, I've used ajax several times and think I understand the process. My problem now involves using a form inside a bootstrap modal and using ajax to submit the form. What I meant by web2py intercepting the event was that web2py.js registers an event handler for the submit which interferes with the modal submit handler. web2py.js adds the 'disabled' class but does not detect the succesful ajax response and then remove the class. Per Niphlod's request, I've recreated the problem using a minimum of code that I've pasted below. This codes works if I remove web2py.js and fails if I leave it. To recreate, click the button to open the model and then click submit on the modal. You can see the button becomes disabled (even if you close and reopen it remains disabled). In other testing, I also had web2py add 'display='none' ' to the target but the code below doesn't do that. Thanks again for your help. Controller Actions: def display_page(): return dict(foo='bar') def return_data(): data= {'foo':'text processed: %s' % request.vars.formdata} return data View: {{extend 'layout.html'}} script $(document).ready(function() { $('#note-btn').click(function() { $('#note-modal').modal({ show: true }); }); $('#note-form').submit(function(e) { e.preventDefault(); $form= $(this); $.post('{{=URL('default', 'return_data.json')}}', {formdata: $form.serialize()}, function(data) {$('#form-feedback').html(data.foo);} ); }); }); /script a href=# id=note-btnOpen modal/a div id=note-modal class=modal fade tabindex=-1 role=dialog div class=modal-dialog div class=modal-content form class=form-horizontal id=note-form div class=modal-header button type=button class=close data-dismiss= modal span aria-hidden=truetimes;/spanspan class= sr-onlyClose/span /button h4 class=modal-titleEnter Notes/h4 div class='bg-success text-center' id='form-feedback'/div /div div class=modal-body div class=form-group div textarea class=form-control id=note-text name=note_text/textarea /div /div /div div class=modal-footer a class=btn btn-default data-dismiss=modalClose/ a button type=submit class=btn btn-primarySave Notes/button /div /form /div!-- /.modal-content -- /div!-- /.modal-dialog -- /div!-- /.modal -- On Wednesday, August 13, 2014 11:31:39 PM UTC-4, Cliff Kachinske wrote: Here's how I do it and I assume Web2py does something similar when it, for example, resets the Working caption on buttons. The Javascript/Jquery whatever in the client changes the state of the button. I do it before sending the ajax post. I don't know how Web2py does it. It doesn't matter whether it's JQuery's ajax or Web2py's ajax. The syntax is a little different between the two, but the overall process is the same. The client sends a request that gets routed to a function. The function returns a response. In that response you would include, assuming JQuery has been loaded on the page, something like $('#somentity_on_page').whatever_attribute_needs_changing('new state of the attribute'); Web2py isn't intercepting anything. You push a button, click a link, whatever, the browser sends a request. The request goes to your web server, be it Rocket, Apache, Nginx, any other. The web server sends the request to Web2py because the server is set up that way. Web2py then processes the request and returns a response. Excuse me if I'm interpreting incorrectly, but your questions suggest a certain misunderstanding about what's going on. Chapters 1, 3 and 4 of the Web2py manual provide a pretty good overview of how this all works. If I recall correctly, Wikipedia has some reasonably good articles about http, http requests and http responses. On Wednesday, August 13, 2014 6:51:59 PM UTC-4, Michael Beller wrote: Thanks ... Niphlod - I'll try to create a minimal app to reproduce. Cliff - are you suggesting to use the web2py ajax function rather the jQuery post? I'm also trying to understand why web2py is intercepting the event and why
[web2py] Re: add static files to header from a module
Put the appending code in the controller. On Wednesday, August 13, 2014 7:14:46 AM UTC-4, pa...@cancamusa.net wrote: Dear all: In the process of moving functionality from models to modules, I'm trying to add some filesto the header. When the file was in models, I did: response.files.append(URL('static', 'jqplot/jquery.jqplot.min.js')) response.files.append(URL('static', 'jqplot/jquery.jqplot.min.css')) now that it's in modules, I tried: current.response.files.append(URL('static', 'jqplot/jquery.jqplot.min.js')) current.response.files.append(URL('static', 'jqplot/jquery.jqplot.min.css')) but it doesn't work... I've found a workaround, the last line in JQPlot.xml was: return current.response.render('jqplot.html', d) so I can add script html tags to the template jqplot.html: script src=/karakolas/static/jqplot/jquery.jqplot.min.js/script script src=/karakolas/static/jqplot/jquery.jqplot.min.css/script but I'm sure it can be done better... Thanks -- 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: What is the right way to serve static files through a CDN ?
If, like me, you use the same static files on every page, just hard code them into layout.html. I realize this may make upgrading more, um, interesting, but it's much simpler than pattern-based routing. On Wednesday, August 13, 2014 11:23:52 AM UTC-4, Louis Amon wrote: I am using a CDN and am trying to configure web2py to use it instead of the classic static file service. So far I've been using pattern-based routes like this : cdn = 'https://xxx.cloudfront.net' routes_in = (... ('/static/$anything', cdn + '/static/$anything'), ... ) routes_out = (... ('/static/$anything', cdn + '/static/$anything'), ... ) This basically works, but this has to be implemented on a pattern-based routes.py which means I lose many cool features like map_hyphen, default_application, default_controller mappings... Is there a way to use a CDN with a parametric router ? I read somewhere that the host parameter in URL can also be used to setup a CDN, but it seems a bit tedious to find all URL and rewrite them. Isn't there a variable in gluon.rewrite that I can mess with to trick web2py into serving CDN-based content ? -- 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: Strange ajax problem
get rid of the target in your ajax call and use ':eval' instead. Then reset the button in your response. On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote: I've created a simple ajax form to update a post database. For some strange reason when I post a new message, the button greys out. Here is the model: db.define_table('t_post', Field('f_post', type='text', label=T('Post')), auth.signature, format='%(f_post)s') Here are my controller functions. def ajax_post(): posts = crud.select(db.t_post, fields=['f_post'], query = db.t_post.created_by == auth.user, headers={'t_post.f_post': 'Post'}, orderby = ~db.t_post.created_on) search = crud.search(db.t_post) return dict(posts=posts, search=search) def new_post(): postdata = request.vars.post db.t_post.insert(f_post = postdata) posts = crud.select(db.t_post, fields=['f_post'], query = db.t_post.created_by == auth.user, headers={'t_post.f_post': 'Post'}, orderby = ~db.t_post.created_on) return posts Here is the model: {{extend 'layout.html'}} h1This is the default/ajax_post.html template/h1 form onsubmit=return false divPost : input name=post//div divbutton onclick=ajax('new_post', ['post'],'results')Post Message/button/div /form div id=results {{=posts}} /div div {{=search[0]}} /div At first I used an input field with type submit for the submit button. When that happened, it would grey out and the value would set to Working. At least now button text doesn't change, but it it still grey's out. Inspecting the element in Firefox I get: button value=Working... class=btn disabled onclick=ajax('new_post', ['post'],'results')Post Message/button Why? I didn't ask it to change the button's class to disabled. And it stays greyed even though the results have returned and my results div has been properly updated. I can still click on the button, but it just appears disabled. -- 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: Hypermedia API and Collection+JSON in web2py
Massimo, The new recipe you propose is bottle+dal+validators+auth+collection Could it be bottle+whatever_you_like+validators+auth+collection? I have found myself needing to execute complex SQL queries. In this situation, in my opinion, psycopg2 would serve me just as well as dal. On Sunday, June 22, 2014 4:45:06 PM UTC-4, Massimo Di Pierro wrote: I added Hypermedia API support to web2py using Collection+JSON. Experimental. Collection+JSON is a standard for self documenting RESTful API. Read more: http://amundsen.com/media-types/collection/ Example = Let's say you have a model: db.define_table('thing',Field('name')) and in controller default.py you add def api(): from gluon.contrib.hypermedia import Collection rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} return Collection(db).process(request,response,rules) And now by magic your table thing is fully exposed using the Collection+JSON API. The API is self documenting and supports GET, POST, PUT, DELETE, etc. For example you can do things like: curl http://127.0.0.1:8000/app/default/api/thing curl http://127.0.0.1:8000/app/default/api/thing/1 curl http://127.0.0.1:8000/app/default/api/thing?id=1 curl http://127.0.0.1:8000/app/default/api/thing?name=Boxid.gt=10_offest=10_limit=30 curl -X POST -d name=Box http://127.0.0.1:8000/app/default/api/thing curl -X PUT -d name=Chair http://127.0.0.1:8000/app/default/api/thing ?name=Box curl -X DELETE http://127.0.0.1:8000/super/collections/conform/thing?name=Chair The API are completely self documenting as explained here http://amundsen.com/media-types/collection/ It is customizable == rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} Let you specify which tables are exposed, which methods are available and which fields are exposed for each method. The query property lets you specify optional filters for example { 'query':db.thing.name.startswith('A'),} will only exposed things starting with letter A. Fields can be conditional and different for different users or for the same user in different stages of a workflow (the communication is stateless, but the server is not). Supports complex queries = http:/./{table} http:/./{table}/{id} http:/./{table}?{field}=value http:/./{table}?{field}.gt=value # fieldvalue http:/./{table}?{field}.le=value # field=value ... http:/./{table}?_orderby={field} http:/./{table}?_limitby=value http:/./{table}?_offset=value ... and combinations there of. They are mapped directly into DAL queries. More examples are in the API response itself. The bigger picture === This API provide enough information to generate forms and tables and grid completely client side. Recently we stumbled against the problem of moving from Bootstrap 2 to Bootstrap 3 because so much of the form and grid logic is server side. My plan is to move most of the logic in the JS library and allow users to customize them for different CSS frameworks. Eventually (in dreams) I would like to have a very slim framework based on bottle+dal+validators+auth+collection and have client side only templates (based on jquery, sugar, and ractive.js) that can generate forms and grids based the collection API. This framework could ship with web2py and allow you to program using same web interface that we all love. There are many design decisions to make to get there. Your suggestions are welcome. How can you help? === 1) test it. 2) there are many existing client side tools for Collection+JSON. Try them with web2py. 3) blog about it and suggest improvements. I said, it is experimental === Collection+JSON has limits: - it is very verbose JSON. This is my my implementation has compact=True option that breaks the protocol but makes much smaller JSON messages. - it does not convey field type information and constraints. This is why I extended to do so but more work is needed because DAL types do not map into HTML5 input types (this of list:string or list:reference). More extensions of the protocol are required. Extensions are allowed. Yet they may change the API in the near future. Massimo -- 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
[web2py] Re: Strange ajax problem
Here's how I do it and I assume Web2py does something similar when it, for example, resets the Working caption on buttons. The Javascript/Jquery whatever in the client changes the state of the button. I do it before sending the ajax post. I don't know how Web2py does it. It doesn't matter whether it's JQuery's ajax or Web2py's ajax. The syntax is a little different between the two, but the overall process is the same. The client sends a request that gets routed to a function. The function returns a response. In that response you would include, assuming JQuery has been loaded on the page, something like $('#somentity_on_page').whatever_attribute_needs_changing('new state of the attribute'); Web2py isn't intercepting anything. You push a button, click a link, whatever, the browser sends a request. The request goes to your web server, be it Rocket, Apache, Nginx, any other. The web server sends the request to Web2py because the server is set up that way. Web2py then processes the request and returns a response. Excuse me if I'm interpreting incorrectly, but your questions suggest a certain misunderstanding about what's going on. Chapters 1, 3 and 4 of the Web2py manual provide a pretty good overview of how this all works. If I recall correctly, Wikipedia has some reasonably good articles about http, http requests and http responses. On Wednesday, August 13, 2014 6:51:59 PM UTC-4, Michael Beller wrote: Thanks ... Niphlod - I'll try to create a minimal app to reproduce. Cliff - are you suggesting to use the web2py ajax function rather the jQuery post? I'm also trying to understand why web2py is intercepting the event and why it doesn't think the response is succesful which I assume is why the button is not re-enabled. On Wednesday, August 13, 2014 5:18:42 PM UTC-4, Cliff Kachinske wrote: get rid of the target in your ajax call and use ':eval' instead. Then reset the button in your response. On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote: I've created a simple ajax form to update a post database. For some strange reason when I post a new message, the button greys out. Here is the model: db.define_table('t_post', Field('f_post', type='text', label=T('Post')), auth.signature, format='%(f_post)s') Here are my controller functions. def ajax_post(): posts = crud.select(db.t_post, fields=['f_post'], query = db.t_post.created_by == auth.user, headers={'t_post.f_post': 'Post'}, orderby = ~db.t_post.created_on) search = crud.search(db.t_post) return dict(posts=posts, search=search) def new_post(): postdata = request.vars.post db.t_post.insert(f_post = postdata) posts = crud.select(db.t_post, fields=['f_post'], query = db.t_post.created_by == auth.user, headers={'t_post.f_post': 'Post'}, orderby = ~db.t_post.created_on) return posts Here is the model: {{extend 'layout.html'}} h1This is the default/ajax_post.html template/h1 form onsubmit=return false divPost : input name=post//div divbutton onclick=ajax('new_post', ['post'],'results')Post Message/button/div /form div id=results {{=posts}} /div div {{=search[0]}} /div At first I used an input field with type submit for the submit button. When that happened, it would grey out and the value would set to Working. At least now button text doesn't change, but it it still grey's out. Inspecting the element in Firefox I get: button value=Working... class=btn disabled onclick=ajax('new_post', ['post'],'results')Post Message/button Why? I didn't ask it to change the button's class to disabled. And it stays greyed even though the results have returned and my results div has been properly updated. I can still click on the button, but it just appears disabled. -- 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: multiple SQLFORM.grid on tabs
I would just use ajax or LOAD. If you really want to use grid, something like this might work. In the view: div id=tab_0 {{=form_0}} /div div id=tab_1 {{=form_1}} /div div id=tab_... {{=form_...}} /div In the controller: def some_func(): form_0 = SQLFORM.grid(whatever) form_1 = SQLFORM.grid(whatever_else) form_... = SQLFORM.grod(yet_other) return dict(form_0=form_0, form_1=form_1, form_...=form_...) On Monday, August 11, 2014 10:03:56 AM UTC-4, Yebach wrote: Hello I am trying to create a view where I have tabs and each tab has its own view. All tabs are included into main view. lets call it settings. In settings there are tabs for user to insert workers into tables, posts, etc etc. all the (un)necessary stuff. For each I would like to use SQLFORM.grid. It already works for inserting workers, but how to add new ones?? I guess in controller I have to create function for each table (form.grid) and for each I have to create new view (html)?? And what function to create for main view? - Basically it should show data for workers but this way all I get is workers SQLform.grid Is this it even possible. Any guideliness would be nice Thank you some code main view ul class=nav nav-tabs li class=activea href=#zaposleni data-toggle=tab{{=T('Delavci')}}/a/li lia href=#turnusi data-toggle=tab{{=T('Turnusi')}}/a/li /ul div class=tab-content div class=tab-pane active id=visual {{include '../views/settings/workers.html'}} /div div class=tab-pane id=turnusi {{include '../views/settings/turnusi.html'}} /div /div div div class=col-md-2 div id=navVisual data-spy=affix data-offset-top=60 ul class=nav nav-pills nav-stacked style=margin-top: 10px; lia href=#SifrantDelavcev{{=T('Delavci')}}/a/li lia href=#unkn{{=T('Turnusi')}}/a/li /ul /div /div /div My view for workers div class=row div id=mainContainer class=col-md-10 h4b{{=T('Šifrant delavcev')}}/b/h4 div class=flash{{=response.flash}}/div div id=SifrantDelavcev class=well well-sm {{=grid}} /div /div /div my view for turnusi div class=row div id=mainContainer class=col-md-10 h4b{{=T('Šifrant turnusov')}}/b/h4 div class=flash{{=response.flash}}/div {{=grid}} /div /div and for both i have fucntions in controller -- 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: IDE for using web2py on windows
Another vote for Pycharm. My approach is a little different from Massimo's, though. I import each class that I use in a function. It can be a lot of boilerplate, but it gives me full use of Pycharm's error detection capability. With the Pycharm project set up in the Web2py folder, I do something like: from gluon.sqlhtml import SQLFORM, ... On Sunday, August 10, 2014 6:30:46 AM UTC-4, Suresh Mali wrote: Am new to web2py looking for better IDE support been using spyder for my other work on windows. Can I continue to use same or need to move to some other IDE? -- 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 vs ruby on rails for a startup?
My opinions: Size of community is not as important as willingness to provide good, timely help. The Web2py community is second to none in these respects. The Web2py learning curve is such that ... well, if you hire a good Python dev you will soon have a good Web2py dev. I have not found this to be true in, for example, Django. On Sunday, August 10, 2014 2:43:02 AM UTC-4, Suresh Mali wrote: I am trying to zero on web framework for our startup, requirements a. Security ( we are working on financial info hence this is important) b. Good way of accessing algos/data of python Machine learning programs c. Low cost of hosting and development (a strartup with not much funds :-) looking for cloud hosting options. d. Relatively low userbase maybe a 1 million in a year's time (looking to server niche ) After reading a bit have zeroed on Ruby on Rails and Web2Py. Looks like ROR is extremly quick, but might have higher hosting costs.. difficulty of mainitaining etc. other hand web2py seems to pull good things from ROR, but very small community and still early stages.. Please suggest, other suggestion liky Play, django etc. welcome if you feel strongly -- 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: Security advice for updating records
Each user has a unique group with only one member: him. So in your controller, something like def my_great_function(): # Not sure if Web2py session supports get, session.get(auth.user.id, 'nobody') would be more # concise than the next 4 lines of code. if 'auth' in session: # defensive code in case session has timed out user_id = auth.user.id else: return # Session has timed out, most likely. Maybe you want to redirect to login screen # user_id = 'nobody' Alternative if you don't want to redirect group_name = 'user_{}'.format(user_id) if not auth.has_membership(group_name): # whatever you decide to do with failed attempt pass # Your great code here pass On Friday, August 8, 2014 6:03:34 PM UTC-4, desta wrote: Let's assume a table: db.define_table('SecretData', Field('data','string'), Field('file_owner', 'reference auth_user', default=auth. user_id) The table is already populated. On the *View* side, the user is able to send an ajax request which contains the *id*, and some data in order to *update* a record he owns. In this scenario, isn't possible for a user to tamper the *id* variable (i.e. through javascript) and mess up with data from other users? How can I protect against this and enforce the update of the right record? Thank you. -- 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: Security advice for updating records
On the client side who cares? On Sunday, August 10, 2014 5:38:31 PM UTC-4, desta wrote: Thank you. But still the user is able to tamper data on client side right? On Sunday, August 10, 2014 11:00:47 PM UTC+3, Cliff Kachinske wrote: Each user has a unique group with only one member: him. So in your controller, something like def my_great_function(): # Not sure if Web2py session supports get, session.get(auth.user.id, 'nobody') would be more # concise than the next 4 lines of code. if 'auth' in session: # defensive code in case session has timed out user_id = auth.user.id else: return # Session has timed out, most likely. Maybe you want to redirect to login screen # user_id = 'nobody' Alternative if you don't want to redirect group_name = 'user_{}'.format(user_id) if not auth.has_membership(group_name): # whatever you decide to do with failed attempt pass # Your great code here pass On Friday, August 8, 2014 6:03:34 PM UTC-4, desta wrote: Let's assume a table: db.define_table('SecretData', Field('data','string'), Field('file_owner', 'reference auth_user', default=auth. user_id) The table is already populated. On the *View* side, the user is able to send an ajax request which contains the *id*, and some data in order to *update* a record he owns. In this scenario, isn't possible for a user to tamper the *id* variable (i.e. through javascript) and mess up with data from other users? How can I protect against this and enforce the update of the right record? Thank you. -- 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: Powered by Web2py: www.sklad05.si
Very nice. I like the way the pages adapt to changing viewport sizes. Good decision on shrinking the pictures across the top, I think. If you don't mind my asking, what CSS/javascript magic are you using? Or is it all htm5? On Saturday, August 9, 2014 11:16:24 AM UTC-4, Najtsirk wrote: Hi, just wanna share my site I've made with web2py www.sklad05.si Best, Kristjan -- 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 With Pycharm project on remote Server
I agree with Massimo. Unless your situation forbids it, the simplest thing would be to code on your local workstation and push code to the server with git or whatever version control system is in use. If there's no version control system on the server you can even use rsync. But you should use git on your workstation so you can roll back changes if necessary. On Monday, August 4, 2014 7:33:58 AM UTC-4, NOSSOLUTIONS wrote: Hi All, Sorry for disturb. I've a question regarding Web2py on Pycharm IDE. I wonder if is possible to create a new web2py project on Pycarm an work on remote server? thanks a lot. -- 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] Nginx and uwsgi Internal Server Error
Richard, I used the ubuntu install script on a VPS at Digital Ocean. No problem. On Friday, August 8, 2014 9:53:22 AM UTC-4, Richard wrote: Yes Jim, it great if you come up with a ubuntu 14.04 tested script and you share with us. Regards Richard On Thu, Aug 7, 2014 at 3:07 PM, Jim S j...@qlf.com javascript: wrote: Finally figured out my problem. It seems to me that everything works fine if I use pip to install additional python packages. But if I use easy_install then I get the python errors. I 'think', but am not sure that the problem lies in some egg cache files that exist in the logged-in users home directory, but am not skilled enough to know for sure. Anyway, the good news is that all works fine when I pip install my additional python packages. I've got a nice big script now that installs web2py (by calling the ubuntu/nginx/uwsgi script), installs my additional ubuntu packages, python packages, adds my network mounts, and is working quite well. Thanks to all who participated in creating the ubuntu/nginx/uwsgi script!! -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: menu creation error
What are the respective file names? Web2py runs the model files in alphabetical order. On Friday, August 8, 2014 3:10:09 PM UTC-4, ocascante wrote: Hello, I am trying to create a menu following a web2py video in youtube: http://www.youtube.com/watch?v=_4to_44DcJU This is my db: *# coding: utf8* *db.define_table('categorias',* *Field('nombre',requires=IS_UPPER(),unique=True))* This is my menu code: response.menu = [ (T('Home'), False, URL('default', 'index')), ] for row in db(db.categorias).select(): response.menu.append((T(row.nombre))) I got this error: type 'exceptions.AttributeError' 'DAL' object has no attribute 'categorias' Thanks for help -- 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 vs others. Status of 2014
Modernizr? Do you think that tall corn interferes with the purchase of new equipment? Whiskey Tango Foxtrot? On Tuesday, August 5, 2014 3:35:50 AM UTC-4, Joe Barnhart wrote: I look forward to Massimo's improvements. One of the continuing thorns in my side is that a significant number of my users are still on XP and IE8 -- about 15% -- and my users are in California. I can only imagine the ratio would be higher in middle America where the tall corn grows. I could choose to ignore these users, but they have money to spend and I want to get it. As we move to more client-heavy designs, it means more javascript and more chances that it won't run in antique computers. I can't leave 15% of my revenue on the table. On the other hand, more and more of my users are on mobile platforms, which fits perfectly with the heavy client approach. Agh! -- Joe On Monday, June 9, 2014 5:01:39 AM UTC-7, Ramos wrote: what is the status of the evolution of web2py compared with other, mainly rails /or django ? which of these including web2py has gain more improvements over the last year? Does anybody knows? Is still web2py over the others? From the beginning Massimo used the phrase Ideas we had , ideas we stole I would like to know if Massimo is stealing more ideas from others. Also what new Killer ideas are we expecting for near future? Regards António -- 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 posts text input twice when name and id are identical
This is not supposed to happen and I don't know why it did. The js looks like this: $('#products_on_order').on('click', '.edit_bound_container', function(e){ //alert(this.id); var container_id = this.id.split('__')[1] var count_field = 'bound_container_count_edit__' + container_id var pounds_field = 'bound_container_quantity_packed_edit__' + container_id ajax( edit_bound_container_url, [count_field, pounds_field, 'order_id'], ':eval' ) }); I thought somehow I had created duplicate input names, but there were none that I could find. Changing the input id so that it is not identical to the input name made the problem go away. -- 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 to add CSS class to SQLFORM.grid??
I would go the other way and override the attributes of the existing classes with my own css. Just make sure your css loads last. On Tuesday, August 5, 2014 5:17:42 PM UTC-4, greenpoise wrote: How can I make use of my own td classes for SQLFORM.grid?? Thanks -- 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 posts text input twice when name and id are identical
I can do that. But I discovered it was doing something much more interesting than my original diagnosis. The inputs in question were editable and generated by the controller. As such they had an assigned value. When I ajaxed them to the server, apparently two copies of the input were sent. One copy had the original value and the other had the edited value. If I would do something like alert($('#the_field').val()); it would alert the edited value. So the final work around was to park those values in hidden fields and send those across via ajax. Of course that doesn't answer why it was happening. And that fixed the problem. I don't know why I thought the other work around fixed it unless it was post-lunch fog. But yes, I will put up the html and the post stream later today. On Wednesday, August 6, 2014 1:55:21 PM UTC-4, Anthony wrote: Can you show the relevant HTML? What does the post data look like? On Wednesday, August 6, 2014 5:48:33 PM UTC+2, Cliff Kachinske wrote: This is not supposed to happen and I don't know why it did. The js looks like this: $('#products_on_order').on('click', '.edit_bound_container', function(e ){ //alert(this.id); var container_id = this.id.split('__')[1] var count_field = 'bound_container_count_edit__' + container_id var pounds_field = 'bound_container_quantity_packed_edit__' + container_id ajax( edit_bound_container_url, [count_field, pounds_field, 'order_id'], ':eval' ) }); I thought somehow I had created duplicate input names, but there were none that I could find. Changing the input id so that it is not identical to the input name made the problem go away. -- 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 do you display created_by and modified_by names and not id's when using lazy tables?
Put the represent in the controller. On Wednesday, August 6, 2014 1:36:51 PM UTC-4, Michael Beller wrote: When I set lazy_tables=True in the DAL, all my signatures fields show the user_id and not the user name. I also set db.auth_user._format = '%(last_name)s' which I thought would force the auth_user definition with lazy tables but my signatures still show id's. Any thoughts on what I'm missing? Also, if I use lazy_tables=False and still set db.auth_user._format = '%(last_name)s' the created_by and modified_by fields in view forms still shows the full name which I can override with auth.signature.created_by.represent = lambda id: db.auth_user._format % db.auth_user[id]. Is that the best way? -- 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: SQLFORM doesn't have SELECT element values
The Chrome developer tools should show the dragged-to select being populated as you drag things across. If things aren't moving look in the console tab for errors. Also you can insert alert statements into the javascript to see if the events are firing. On Tuesday, July 22, 2014 5:01:55 PM UTC-4, Frank Buibish wrote: I just checked what was being sent via POST, and it's not submitting an empty variable corresponding with the select name. Now could this be because the select tag isn't an input tag? I'm not an html pro yet, so small details like this are something i will learn with time. Any suggestions on workarounds? Should I have a hidden input field that stores what is in the select field? or should I use a different form inside of a form (not even sure that is possible). Thanks for any suggestions Frank On Monday, July 21, 2014 10:38:38 PM UTC-4, Anthony wrote: Yes, you're allowed to bump. Use the browser developer tools to see what gets sent to the server when you submit the form. Perhaps the problem is with the JavaScript on the client side. Anthony On Monday, July 21, 2014 8:18:30 PM UTC-4, Frank Buibish wrote: Am I allowed to bump in this forum? if not this shall be the last time...most likely On Thursday, July 17, 2014 10:43:56 PM UTC-4, Frank Buibish wrote: select id=selected-exercises multiple= name=exercises option value=2 class=btn btn-defaultBench/option /select They get added through javascript from the first select element. On Thursday, July 17, 2014 10:14:17 PM UTC-4, Anthony wrote: The first select has no name, and the second one has no options. -- 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] form.process(onvalidate=some_function) blocks custom validator?
I use a custom validator for list:string fields. If I use onvalidate with form.process, the validator is not called. It's easy to work around this situation, but it took some time to figure out what was going on. It might be beneficial to document this behavior. -- 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] Pinging Massimo: why Bottle as opposed to Flask?
Massimo, In the Reddit thread you mentioned experimenting with Bottle + Dal. Why Bottle? Thanks, Cliff Kachinske -- 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: form.process(onvalidate=some_function) blocks custom validator?
It appears not to. If I put a print statement in there it never executes. If I tell it to return the value and some arbitrary string it doesn't happen. On Thursday, July 17, 2014 6:56:41 AM UTC-4, Leonel Câmara wrote: Do you mean onvalidation? It's supposed to run your validators first. -- 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: form.process(onvalidate=some_function) blocks custom validator?
I've worked around it, so not a concern at this very moment. If I ever get out of crunch time Ill look into it. Cliff Kachinske On Thursday, July 17, 2014 11:59:57 AM UTC-4, Anthony wrote: Here's the framework code: status = self._traverse(status, hideerror) status = self.assert_status(status, request_vars) if onvalidation: ._traverse is where individual field validators are run, which happens before onvalidation. We'll probably have to see some code to figure out what's going on here. Anthony On Thursday, July 17, 2014 7:01:34 AM UTC-4, Cliff Kachinske wrote: It appears not to. If I put a print statement in there it never executes. If I tell it to return the value and some arbitrary string it doesn't happen. On Thursday, July 17, 2014 6:56:41 AM UTC-4, Leonel Câmara wrote: Do you mean onvalidation? It's supposed to run your validators first. -- 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: Updating database outside web2py
I would use the native Python adapter for what you want to do. There is less code to load and execute, thus less memory, less time and fewer opportunities for error. The only possible drawback is you will need to write some SQL. On Thursday, July 3, 2014 12:53:34 AM UTC-4, Mayank Kumar wrote: Hi, I am working on a project where I need to update the website database outside web2py, i mean outside an standard HTTP request. For example, I have another server where TCP request comes, and I need to update one table in the database. Also, I have views defined inside web2py which prints out entry from the same tables. I am planning to use DAL for the database access outside web2py ( http://www.web2py.com/AlterEgo/default/show/215). But, I am curious - What sort additional of care should I take while coding this as write (outside web2py) and read (in some views of the website) can happen simultaneously. Thanks -- 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: Silent dal failure with missing field def. Maybe a bug?
Thank you. On Tuesday, July 1, 2014 6:16:18 PM UTC-4, Anthony wrote: That particular method of updating calls: .update(**self._filter_fields(value)) So no exception is raised because the fields are filtered to include only those in the table definition. If you want to catch such errors, use the more explicit .update() method. Anthony On Tuesday, July 1, 2014 5:39:36 PM UTC-4, Cliff Kachinske wrote: I would have thought DAL would raise an exception here, but the failure was silent. The postgres table contains these fields: quantity_used | numeric(12,3) | container_count | integer | container_id | integer | restock | integer | An ajax request was attempting to update the quantity_used, container_count and restock fields. The updating code looks like this: All the variables were there. db.repacks_reruns_container[rrc_id] = dict( container_count=count, quantity_used=pounds, restock=restock, ) db._lastsql looked like this: UPDATE repacks_reruns_container SET quantity_used=1.000, container_count=2 WHERE ((repacks_reruns_container.id = 1) AND ( repacks_reruns_container.is_active = 'T')); Note restock not updated in the query. It happened because the model for repacks_reruns_container was missing the restock field. -- 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: {{=XML(row.contents, sanitize=True)}} and em/em
You can tune the tags and attributes that XML will allow. XML has a parameter called permitted_tags. It is a list of tags that XML will not escape. You could, at the top of your controller, create your own list of permitted tags. Then call XML like this: XML(row.contents, sanitize=True, permitted_tags=permitted_tags) This is what the permitted_tags parameter looks like with the added entry for em. You can find it in gluon/html.py around line 1536. permitted_tags=[ 'a', 'b', 'blockquote', 'br/', 'i', 'li', 'ol', 'ul', 'p', 'cite', 'code', 'pre', 'img/', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'table', 'tr', 'td', 'div', 'strong','span', # entry below added 'em' ], If you look at the XML class in html.py you will see another parameter called allowed_attributes. I suppose you could make your own dictionary to allow a style attribute for some html tags and pass it in when you call XML. On Wednesday, July 2, 2014 5:30:18 AM UTC-4, Annet wrote: In a view I have the following line: {{=XML(row.contents, sanitize=True)}} When 'contents' contains an em/em element add by tinymce, this element isn't being rendered: emMy text /em Other elements like p/p strong/strong are being rendered correctly. Furthermore, when tinymce adds a style to an element: p style=text-align: center;My text /p This is being rendered without the style: pMy text .../p Is there a way to solve these issues. Regards, 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. For more options, visit https://groups.google.com/d/optout.
[web2py] Silent dal failure with missing field def. Maybe a bug?
I would have thought DAL would raise an exception here, but the failure was silent. The postgres table contains these fields: quantity_used | numeric(12,3) | container_count | integer | container_id | integer | restock | integer | An ajax request was attempting to update the quantity_used, container_count and restock fields. The updating code looks like this: All the variables were there. db.repacks_reruns_container[rrc_id] = dict( container_count=count, quantity_used=pounds, restock=restock, ) db._lastsql looked like this: UPDATE repacks_reruns_container SET quantity_used=1.000,container_count= 2 WHERE ((repacks_reruns_container.id = 1) AND (repacks_reruns_container.is_active = 'T')); Note restock not updated in the query. It happened because the model for repacks_reruns_container was missing the restock field. -- 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] list:strings not working as described or am I missing something?
https://lh4.googleusercontent.com/-7k58hj9gv7M/U62UdX1NG4I/AHA/9l6vaRZIxy0/s1600/Screenshot+from+2014-06-27+11%3A56%3A46.png Web2py 2.8.2, if that matters. The manual at web2py.com says, On relational databases they [list:string fields] are mapped into text fields which contain the list of items separated by |. For example [1,2,3] is mapped into |1|2|3|. I am getting something different. The field shown at the top of this post Inserts the following into the Postgresql database. pandi3= select distinct lots_used from job_materials where lots_used is not null and is_active = 'T'; lots_used -- |foo, bar, fubar, fubub| (1 row) From the manual's description I expect something like foo|bar|fubar|fubub I am using a custom validator that returns a list from the field. Use it or not, I get the same results. How do I fix this? IS_IN_SET will not work here. -- 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: list:strings not working as described or am I missing something?
Anthony, Thanks for the shove in the right direction. An ajax callback processes that field and I had forgotten to run it through the validator. So the db was inserting the entire string instead of list members. On Friday, June 27, 2014 1:07:33 PM UTC-4, Anthony wrote: Hard to say without seeing any code, but clearly the database insert is not getting a list. On Friday, June 27, 2014 12:12:00 PM UTC-4, Cliff Kachinske wrote: https://lh4.googleusercontent.com/-7k58hj9gv7M/U62UdX1NG4I/AHA/9l6vaRZIxy0/s1600/Screenshot+from+2014-06-27+11%3A56%3A46.png Web2py 2.8.2, if that matters. The manual at web2py.com says, On relational databases they [list:string fields] are mapped into text fields which contain the list of items separated by |. For example [1,2,3] is mapped into |1|2|3|. I am getting something different. The field shown at the top of this post Inserts the following into the Postgresql database. pandi3= select distinct lots_used from job_materials where lots_used is not null and is_active = 'T'; lots_used -- |foo, bar, fubar, fubub| (1 row) From the manual's description I expect something like foo|bar|fubar|fubub I am using a custom validator that returns a list from the field. Use it or not, I get the same results. How do I fix this? IS_IN_SET will not work here. -- 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: Can't seem to verify password field...
Check the data types of element 0 in the tuples. On Thursday, June 26, 2014 3:37:22 AM UTC-4, Encompass solutions wrote: I can't seem to get my key to verify: This is how I verify it: success = db.melodigram.deletion_key.validate(request.args(1)) == (db(db.melodigram.unique_id == request.args(0)).select().first(), None) And this is how it is made: form = SQLFORM(db.melodigram) form.process(session = None, formname = None) Any ideas as to why this would be an issue? I just can't get success to be true. :( .. . . BR, Jason Brower -- 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: Hypermedia API and Collection+JSON in web2py
Massimo, I like the way your thoughts are headed. doesn't the many2many issue goes away if one uses, for example, MongoDB? On Sunday, June 22, 2014 4:45:06 PM UTC-4, Massimo Di Pierro wrote: I added Hypermedia API support to web2py using Collection+JSON. Experimental. Collection+JSON is a standard for self documenting RESTful API. Read more: http://amundsen.com/media-types/collection/ Example = Let's say you have a model: db.define_table('thing',Field('name')) and in controller default.py you add def api(): from gluon.contrib.hypermedia import Collection rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} return Collection(db).process(request,response,rules) And now by magic your table thing is fully exposed using the Collection+JSON API. The API is self documenting and supports GET, POST, PUT, DELETE, etc. For example you can do things like: curl http://127.0.0.1:8000/app/default/api/thing curl http://127.0.0.1:8000/app/default/api/thing/1 curl http://127.0.0.1:8000/app/default/api/thing?id=1 curl http://127.0.0.1:8000/app/default/api/thing?name=Boxid.gt=10_offest=10_limit=30 curl -X POST -d name=Box http://127.0.0.1:8000/app/default/api/thing curl -X PUT -d name=Chair http://127.0.0.1:8000/app/default/api/thing ?name=Box curl -X DELETE http://127.0.0.1:8000/super/collections/conform/thing?name=Chair The API are completely self documenting as explained here http://amundsen.com/media-types/collection/ It is customizable == rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} Let you specify which tables are exposed, which methods are available and which fields are exposed for each method. The query property lets you specify optional filters for example { 'query':db.thing.name.startswith('A'),} will only exposed things starting with letter A. Fields can be conditional and different for different users or for the same user in different stages of a workflow (the communication is stateless, but the server is not). Supports complex queries = http:/./{table} http:/./{table}/{id} http:/./{table}?{field}=value http:/./{table}?{field}.gt=value # fieldvalue http:/./{table}?{field}.le=value # field=value ... http:/./{table}?_orderby={field} http:/./{table}?_limitby=value http:/./{table}?_offset=value ... and combinations there of. They are mapped directly into DAL queries. More examples are in the API response itself. The bigger picture === This API provide enough information to generate forms and tables and grid completely client side. Recently we stumbled against the problem of moving from Bootstrap 2 to Bootstrap 3 because so much of the form and grid logic is server side. My plan is to move most of the logic in the JS library and allow users to customize them for different CSS frameworks. Eventually (in dreams) I would like to have a very slim framework based on bottle+dal+validators+auth+collection and have client side only templates (based on jquery, sugar, and ractive.js) that can generate forms and grids based the collection API. This framework could ship with web2py and allow you to program using same web interface that we all love. There are many design decisions to make to get there. Your suggestions are welcome. How can you help? === 1) test it. 2) there are many existing client side tools for Collection+JSON. Try them with web2py. 3) blog about it and suggest improvements. I said, it is experimental === Collection+JSON has limits: - it is very verbose JSON. This is my my implementation has compact=True option that breaks the protocol but makes much smaller JSON messages. - it does not convey field type information and constraints. This is why I extended to do so but more work is needed because DAL types do not map into HTML5 input types (this of list:string or list:reference). More extensions of the protocol are required. Extensions are allowed. Yet they may change the API in the near future. Massimo -- 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
[web2py] Re: Uniqueness in Multi-tenants
You could build a custom validator around something like this: new_value.strip() # Leading/trailing white space can fool humans if not db( (db[target_table][target_field==new_value) (db[target_table].tenant_id==tenant_id) ).isempty(): return new_value, error_message return new_value, None Read about custom validators here: http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-validators On Wednesday, June 25, 2014 2:17:06 PM UTC-4, Carlos Zenteno wrote: We cannot enforce uniqueness (unique=true) within a tenant in multi-tenancy because the database does not know about tenants. Has anybody found a way to enforce/design uniqueness using multi-tenancy? -- 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
Graham, I have done form submission both ways. I much prefer self-submission. Much less code to write, so fewer opportunities for error. On Thursday, June 19, 2014 9:30:15 AM UTC-4, Graham Ranson wrote: 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.
[web2py] Re: Need to have def 4() and def dir() to 301 redirect. Is it possible?
You probably need to use the URL rewrite facility. Read here for information about it: http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite Once your request gets to the web2py router, it will be parsed as follows: www.mydomain.com/web2py_application/controller/function/args(0)/..args(n)?vars So in the case of www.mydomain.com/4, the router will attempt to route your request to an app named 4. In the second case it will look for an app named dir. URL rewrite avoids this because it happens before the Web2py router gets called. On Tuesday, June 24, 2014 4:57:56 AM UTC-4, Kenneth wrote: I would like to redirect these two links: www.mydomain.com/4 and www.mydomain.com/dir for fixing backlinks I previously had for SEO purpose. I've tried to redirect from the controller but it didn't work. -- def 4(): redirect('/',301) def dir(): redirect('/',301) -- Obviously this is not possible since dir is a reserved keyword and 4 is integer. Anyway to redirect these two? Thank you. -- 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] Why does this happen: DAL returns a tuple is it supposed to?
Why is DAL returning a tuple here? from dal import DAL db = DAL('postgres://web2pyuser:password@localhost:5432/webtest', fake_migrate_all=True) q = '''select coalesce(sum(amount), 0) from product_journal''' db.executesql(q) [(Decimal('250.000'),)] # Why is the returned value a tuple? This does not seem to make sense. q = '''select coalesce(sum(amount), 0) from product_journal where product_id = 255''' db.executesql(q) [(Decimal('0'),)] Is this the way it's supposed to work and will it stay this way? -- 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: Why does this happen: DAL returns a tuple is it supposed to?
Leonel, Ah, so it is. Thank you. On Monday, June 16, 2014 10:31:53 AM UTC-4, Leonel Câmara wrote: That's just a consequence of python's DB-API (see http://legacy.python.org/dev/peps/pep-0249/ ) the result is indeed supposed to be a list of tuples. However, web2py's DAL executesql does have many parameters that allow you to change the results, you can even get Rows if you want. I recommend you check executesql parameters (for instance as_dict) in the docs. http://web2py.readthedocs.org/en/latest/dal.html#gluon.dal.DAL.executesql -- 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] Help with the eb2py calendar?
Here is what I want to do. I have several divs with date field inside them. It uses the Web2py calendar widget. I want to trap the onSelect event for the calendar widget and trigger an ajax call when that happens. I know I can put a fake submit button next to the calendar widget and trigger ajax on its click event, but I think it would be slicker to fire the ajax when the calendar changes. Any thoughts? Thank you, Cliff Kachinske -- 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] going crazy with pyfpdf
I've seen this. My leaky memory says pyfpdf doesn't like percentages. Try absolute units and I think it will work. On Wednesday, May 21, 2014 1:04:58 PM UTC-4, Carlos Cesar Caballero Díaz wrote: Thanks Mariano and Carlos, there is a simple code: controller default.py: def pdf_test: return dict(hello=hello) view default/pdf_test.html: body h1{{=hello}}/h1 pThis is a text/p table width=100% thead tr th width=40%name/th th width=60%lastame/th /tr /thead tbody tr td width=40%pepe/td td width=60%paco/td /tr /tbody /table /body http://localhost:8000/myapp/default/pdf_test.pdf;http://localhost:8000/myapp/default/pdf_test.pdfshows a Table column/cell width not specified, unable to continue error. and removing the table, return a blank pdf El 21/05/14 11:33, Mariano Reingart escribió: Yes, pyfpdf has a basic html parser (based on python stdlib) and needs some conventions to translate tables to PDF. Could you make a minimal example to test and debug it? That way it would be easy to reproduce and see how to adapt the html to be rendered. You can look at the documented examples, using thead and th tags will help, and you need to specify the total table and cell widths: https://code.google.com/p/pyfpdf/wiki/WriteHTML Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Wed, May 21, 2014 at 12:26 PM, Carlos Costa yamand...@gmail.comjavascript: wrote: It uses pyfpdf to convert it. But there are some restrictions as I remember. You check it here https://code.google.com/p/pyfpdf/ 2014-05-21 12:13 GMT-03:00 Carlos Cesar Caballero Díaz desar...@spicm.cfg.sld.cu javascript:: Hi, I need some help, when I call a view with .pdf this: html head titleReport/title /head body table tr td width=50%name/td td width=50%pepe/td /tr /table /body /html or this: body table tr td width=50%name/td td width=50%pepe/td /tr /table /body returns a blank one page pdf. Now if I put the content before the body tag, it is rendered, but the table allways throw a Table column/cell width not specified, unable to continue error. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Att. Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] routes.py invalid request
Using pattern-based routing, I get Invalid Request messages. Usually the routes work OK after restarting nginx. But after closing and restarting Chrome the problem recurs. The failing url is www.dotzle.com/apps This is the routes.py file. I used the nginx setup script. The only change I made was to increase the upload file size to 5 meg in /etc/nginx/nginx.conf. Later today I will try this with rocket and see if the problem goes away. Thanks for any help. BASE = '' # optonal prefix for incoming URLs 34 35 routes_in = ( 36 # do not reroute admin unless you want to disable it 37 (BASE + '/admin', '/admin/default/index'), 38 (BASE + '/admin/$anything', '/admin/$anything'), 39 # do not reroute appadmin unless you want to disable it 40 (BASE + '/$app/appadmin', '/$app/appadmin/index'), 41 (BASE + '/$app/appadmin/$anything', '/$app/appadmin/$anything'), 42 # do not reroute static files 43 (BASE + '/$app/static/$anything', '/$app/static/$anything'), 44 # reroute favicon and robots, use exable for lack of better choice 45 ('/favicon.ico', '/examples/static/favicon.ico'), 46 ('/robots.txt', '/examples/static/robots.txt'), 47 48 ## This raises the invalid request message 49 50 ('.*./apps', '/init/default/user/login'), 51 # remove the BASE prefix 52 (BASE + '/$anything', '/$anything'), 53 ) 54 55 # routes_out, like routes_in translates URL paths created with the web2py URL() 56 # function in the same manner that route_in translates inbound URL paths. 57 # 58 59 routes_out = ( 60 # do not reroute admin unless you want to disable it 61 ('/admin/$anything', BASE + '/admin/$anything'), 62 # do not reroute appadmin unless you want to disable it 63 ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'), 64 # do not reroute static files 65 ('/$app/static/$anything', BASE + '/$app/static/$anything'), 66 # do other stuff 67 ('/init/default/user/login', '.*./apps'), 68 # (r'.*http://otherdomain\.com.* /app/ctr(?Pany.*)', r'\gany'), 69 # (r'/app(?Pany.*)', r'\gany'), 70 71 ## Or maybe it is here 72 73 ('/init/default/user/login', '.*./apps'), 74 # restore the BASE prefix 75 ('/$anything', BASE + '/$anything'), 76 ) -- 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: SQLFORM.grid Export and represent
There must be something in the request that indicates you want csv or tsv. If it's in the request.args, for example, something like this would work: if 'csv' not in request.args and 'tsv' not in request.args: db.inventory.cpu_status.represent = lambda cpu_status, row: SPAN( ... On Wednesday, April 16, 2014 12:58:12 PM UTC-4, John Fraser wrote: Is there an easy way to strip HTML markup from SQLFORM.grid's CSV/TSV export? I realize I probably need to create a custom export function, but curious if there is an argument or a one liner that would do the trick. Or is there a better way to format the display? I have the following controller function: @auth.requires_login() def index(): response.title = 'Computer Inventory' db.inventory.id.readable = False db.inventory.cpu_status.represent = lambda cpu_status, row: \ SPAN(row.cpu_status, _style='text-transform: uppercase; font-weight: bold; padding:5px; color: %s; background-color: %s' % ('black' if row.cpu_status == 'Staged' else 'white','red' if row.cpu_status == 'Repair' else 'gold' if row.cpu_status == 'Staged' else 'green' if row.cpu_status == 'In Use' else 'black')) grid = SQLFORM.grid(db.inventory, csv=True) return locals() When I export as CSV/TSV (as displayed to the user) all values for db.inventory.cpu_status are wrapped in SPAN tags for example: span style='text-transform: uppercase; font-weight: bold; padding:5px; color: white; background-color: black'VALUE/span -- 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: great news: Sphinx Documentation
Thank you Niphlod. You have done Yet Another Good Thing. On Sunday, April 13, 2014 11:43:26 AM UTC-4, Massimo Di Pierro wrote: Great news! We are finally moving to Sphinx. http://web2py.readthedocs.org/en/latest/ Kudos to Simone (niphlod) who single handedly ported all the docstrings and made this possible. Thank you Simone! -- 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: Question about Web2py inner workings
Ach! My sample was a simplified version of the file that is actually failing. Here is the actual code. Explanatory comments on line 3 and line 43 delineated with ## #. This fails every time on my system, Python 2.7.3 on Debian Wheezy. I wrote this to demonstrate the exact point made by Anthony above. I'm sure I'm missing something, but I cannot see it. #! /var/bin python ## # Notice these two assignments foo = 'bar' i_am_global = 'Blue Parrot' print i_am_global class print_it(object): def __init__(self, some_string=None): self.some_string = some_string def print_the_global(self): Not to start a comp sci flame war about classes with side effects, or multiple exit points, or about how some Python guy showed a bunch of spagetti code. print 'I, print_it, am going to print the global var.' try: print i_am_global except: print 'Where is the global variable?' print 'I, print_it, am done. Thank you.' def change_the_global(self, new_value_for_global): i_am_global = new_value_for_global def change_and_print_the_global(self, newval): i_am_global = newval print i_am_global def main(): ## # Now comes the exception in line 45 print foo print i_am_global new_val = 'pwned' found_it = False print 'I think I found i_am_global in the global scope.' print 'I\'ll prove it by printing its contents.' print 'Watch.' print '\n' try: print 'It says, {}'.format(i_am_global) except Exception as e: print 'Oops, I got this Exception: %s' %e print Exception() print 'That didn\'t work so well.' else: found_it = True print 'There, see?' print '\n' # Here is the change if found_it: print 'Now I\'m going to change it to pwned.' i_am_global = new_val print 'This is the result of my change.' print 'It now says {}.'.format(i_am_global) print '\n' print 'Now for some object action.' printer_to_screen = print_it() #Created an instance. print 'This is my new object: {}'.format(printer_to_screen) print '\n' print 'My new object is going to print the global variable' printer_to_screen.print_the_global() print '\n' print 'how did that work out?' print '\n' print 'My new object is going to reassign the global variable' printer_to_screen.change_the_global('fubar') print 'Now to print it' printer_to_screen.print_the_global() print '\n' print 'How about if we change it and print it in the same method?' printer_to_screen.change_and_print_the_global('fubar') print '\n' print Let's see if the change stuck printer_to_screen.print_the_global() if __name__== '__main__': main() print '\nHere is the final value of the global: {}'.format(i_am_global) On Saturday, April 5, 2014 9:43:13 AM UTC-4, Anthony wrote: On Friday, April 4, 2014 5:51:11 PM UTC-4, Cliff Kachinske wrote: If I write a python module like this: # born_to_fail.py foo = 'bar' def main(): print foo if __name__=='__main__': main() The above shouldn't produce an error, but the following will: foo = 'bar' def main(): print foo foo = 'foo' In the above, the assignment to foo indicates foo is a local variable (since it hasn't been explicitly declared as global), so the previous print statement raises an exception because it refers to a local variable that has not yet been declared. In your original example, because there is no assignment to foo within the function, the foo in the print statement is assumed to be global, and there is no exception because foo is in fact a global variable. Anthony -- 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: Question about Web2py inner workings
Anthony, thank you. On Sunday, April 6, 2014 8:26:33 PM UTC-4, Anthony wrote: # Here is the change if found_it: print 'Now I\'m going to change it to pwned.' i_am_global = new_val Above you assign a value to i_am_global. Because you have not explicitly declared i_am_global as a global variable, it is automatically defined as being local to the main() function. Therefore, any earlier references to i_am_global (e.g., line 45) will generate an UnboundLocalError. In Python, you can always read a global variable without declaring it to be global, but if you want to create or overwrite a global variable within a function, you must first declare it to be global. Anthony -- 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 do I SELECT * FROM table WHERE field IN (1,2,3,4,7)
Kurt, I think the key is to realize that the WHERE clause comes first in DAL dialect, and the fields to be selected come after. On Saturday, April 5, 2014 11:49:28 PM UTC-4, Kurt Jensen wrote: How do I do : SELECT * FROM table WHERE field IN (1,2,3,4,7) AND field2='3' AND / OR DELETE FROM table WHERE field1 IN (1,2,3,4,7) AND field2='3' in web2py DAL? I come from PHP and I am really struggling with DAL in web2py. -- 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] Question about Web2py inner workings
If I write a python module like this: # born_to_fail.py foo = 'bar' def main(): print foo if __name__=='__main__': main() Python will raise an exception about an unbound local variable. But in Web2py, I do this all the time without getting an exception: #my_controller.py ISEDITOR = auth.has_membership('editors') def myfunc(): if ISEDITOR: #do stuff pass How does this happen? -- 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][Javascript] Massimo here searching for some javascript devs ready to port web2py in JS
Ha. On Tuesday, April 1, 2014 1:44:01 PM UTC-4, Richard wrote: Hello, I want to get rid of python entirely. As you probably know, I don't see great future in Python 3000 and since we can't fighting the Javascript dominance in webapp development world, I resign... I want to port web2py to javascript by rewriting all piece of it except the DAL because it too good and I like it! Is there any volonteers? Massimo -- 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: Database access without DAL but with connection pool
Derek, the conventional wisdom is connecting to a db is expensive. I'm willing to be convinced, but I need some data. Can you point me to some? Because if your statement is true, we could eliminate some pretty hairy code in the DAL to support pooling. On Wednesday, March 19, 2014 7:44:10 PM UTC-4, Derek wrote: I'd say the answer to 2 is 'not really'. Believe it or not, opening and dropping database connections is a fast operation. On Tuesday, March 18, 2014 11:33:04 PM UTC-7, tec...@gmail.com wrote: Dear Sirs, I understand it's possible to use databases without DAL. For example function in controller: def values(): client = pymongo.MongoClient('localhost', 27017) db = client.mybase mytable = db[mytable] res = mytable.find() . return dict() And of course it works. But is it fast to connect/disconnect every time in function? What's about connection pool? I consider connection pool could increase access to database. 1. Actually I would like to ask how to access to database without DAL but at maximum speed? 2. Do I need connection pool for fast database access? (I think, yes.) 3. How could I build custom connection pool for database access without DAL? Or any solution to re-use connections to database server? Any examples? Andrey A. -- 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: Python Performance Issue
Apparently the number of cores is adjustable. Try this link. http://download.parallels.com/desktop/v5/docs/en/Parallels_Desktop_Users_Guide/23076.htm On Monday, March 17, 2014 10:02:13 AM UTC-4, horridohobbyist wrote: Parallels VM running on a 2.5GHz dual-core Mac mini. I really don't know what Parallels uses. On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote: What kind of VM is this? What is the host platform? How many CPU cores? Is VM using all the cores? The only thing I can think of is the GIL and the fact that multithreaded code in python gets slower and slower the more cores I have. On my laptop, with two cores, I do not see any slow down. Rocket preallocate a thread pool. The rationale is that it decreases the latency time. Perhaps you can also try rocket in this way: web2py.py --minthreads=1 --maxthreads=1 This will reduce the number of worker threads to 1. Rocket also runs a background non-worker thread that monitors worker threads and kills them if they get stuck. On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote: Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code: Welcome: elapsed time: 0.0511929988861 Welcome: elapsed time: 0.0024790763855 Welcome: elapsed time: 0.00262713432312 Welcome: elapsed time: 0.00224614143372 Welcome: elapsed time: 0.00218415260315 Welcome: elapsed time: 0.00213503837585 Oddly enough, it's slightly faster! But still 37% slower than the command line execution. I'd really, really, **really** like to know why the shipping code is 10x slower... On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote: Okay, I did the calculations test in my Linux VM using command line (fred0), Flask (hello0), and web2py (Welcome). fred0: elapsed time: 0.00159001350403 fred0: elapsed time: 0.0015709400177 fred0: elapsed time: 0.00156021118164 fred0: elapsed time: 0.0015971660614 fred0: elapsed time: 0.0031584741 hello0: elapsed time: 0.00271105766296 hello0: elapsed time: 0.00213503837585 hello0: elapsed time: 0.00195693969727 hello0: elapsed time: 0.00224900245667 hello0: elapsed time: 0.00205492973328 Welcome: elapsed time: 0.0484869480133 Welcome: elapsed time: 0.00296783447266 Welcome: elapsed time: 0.00293898582458 Welcome: elapsed time: 0.00300216674805 Welcome: elapsed time: 0.00312614440918 The Welcome discrepancy is just under 2x, not nearly as bad as 10x in my shipping code. On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote: In order to isolate the problem one must take it in steps. This is a good test but you must first perform this test with the code you proposed before: def test(): t = time.time start = t() x = 0.0 for i in range(1,5000): x += (float(i+10)*(i+25)+175.0)/3.14 debug(elapsed time: +str(t()-start)) return I would like to know the results about this test code first. The other code you are using performs an import: from shippackage import Package Now that is something that is very different in web2py and flask for example. In web2py the import is executed at every request (although it should be cached by Python) while in flask it is executed only once. This should also not cause a performance difference but it is a different test than the one above. TLTR: we should test separately python code execution (which may be affected by threading) and import statements (which may be affected by web2py custom_import and/or module weird behavior). On Sunday, 16 March 2014 08:47:13 UTC-5, horridohobbyist wrote: I've conducted a test with Flask. fred.py is the command line program. hello.py is the Flask program. default.py is the Welcome controller. testdata.txt is the test data. shippackage.py is a required module. fred.py: 0.024 second 0.067 second hello.py: 0.029 second 0.073 second default.py: 0.27 second 0.78 second The Flask program is slightly slower than the command line. However, the Welcome app is about 10x slower! *Web2py is much, much slower than Flask.* I conducted the test in a Parallels VM running Ubuntu Server 12.04 (1GB memory allocated). I have a 2.5GHz dual-core Mac mini with 8GB. I can't quite figure out how to use gunicom. On Saturday, 15 March 2014 23:41:49 UTC-4, horridohobbyist wrote: I'll see what I can do. It will take time for me to learn how to use another framework. As for trying a different web server, my (production) Linux server is intimately reliant on Apache. I'd have to learn how to use another web server, and then try it in my Linux VM. On Saturday, 15 March 2014 22:45:27 UTC-4, Anthony wrote: Are you able to replicate the exact task in another web framework, such as Flask (with the same server setup)? On Saturday, March 15, 2014 10:34:56 PM UTC-4, horridohobbyist wrote: Well, putting back all my apps hasn't widened the discrepancy. So I don't
[web2py] Re: Help with SQL Query without using executesql preferably :)
The DAL chapter of the online Web2py manual explains how to fetch the max value, same as a SQL GROUP BY. On Monday, March 10, 2014 3:54:59 PM UTC-4, brahama von wrote: This is the result i get from a simple select like this: legacy_db(legacy_db.cursodado.gp_pro_id==course).select() cursodado.gp_id cursodado.gp_pro_id cursodado.gp_historicdate cursodado.gp_curso_id 10003600042014-01-27 16:02:10None 10003600042014-01-27 17:18:31None 10003600042014-01-27 17:21:02None 10005250042014-01-27 16:02:10None 10005250042014-01-27 17:18:31None 10005250042014-01-27 17:21:02None Here i get the id of the person and the id of the course but I want only to show the first I once, that correspond to the max(cursodado.gp_historicdate) To see it like this: cursodado.gp_id cursodado.gp_pro_id cursodado.gp_historicdate cursodado.gp_curso_id 10003600042014-01-27 17:21:02None 10005250042014-01-27 17:21:02None tried this in the select but it gives a timeout: select(groupby=gp_id,having=max(historicdate field)) Thanks! -- 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: Problem with upgrade to 2.9.4 with SQLTABLE
drayco, correct me if I'm wrong but it looks like you didn't make the change Niphlod suggested. The error trace shows you still use db.pagos.id.count() rather than the suggested syntax. On Monday, March 10, 2014 1:22:04 PM UTC-4, drayco wrote: With the change, this is the result File /home/drayco/web2py/applications/movil/controllers/cobros.py https://sys.luzo.mx/admin/default/edit/movil/controllers/cobros.py, line 335, in pagos select(db.pagos.id.count()), headers={db.pagos.id.count():'Total Pagos'}) File /home/drayco/web2py/gluon/sqlhtml.py, line 2929, in __init__ columns = ['.'.join(sqlrows.db._adapter.REGEX_TABLE_DOT_FIELD.match(c).groups()) for c in sqlrows.colnames] AttributeError: 'NoneType' object has no attribute 'groups' But the problem persist, do you have other idea? And repeat, that kind of code works in web2py 2.8.3 El viernes, 7 de marzo de 2014 14:00:40 UTC-6, drayco escribió: All code work with web2py 2.8.3 but when we upgrade to web2py 2.9.4, we use extensive SQLTABLE and in this moment we have a lot of errors similar to File /home/drayco/webapps/newconfig/web2py/gluon/sqlhtml.py, line 2929, in __init__ columns = ['.'.join(sqlrows.db._adapter.REGEX_TABLE_DOT_FIELD.match(c).groups()) for c in sqlrows.colnames] AttributeError: 'NoneType' object has no attribute 'groups' This is our code totalPagos = SQLTABLE(db((db.pagos.created_oninicio)(db.pagos.created_onfin)).\ select(db.pagos.id.count()), headers={'COUNT(pagos.id)':'Total Pagos'}) What can we do? Can you help me please? -- 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: multiple response.menu
To expand a little on Massimo's explanation. Find the reference to Cooperating Applications in the online manual. Once you have figured out which app will be the master app, you can put all the model files in the master apps models directory, then softlink the files you need in other directories. If you use lazy tables (see the DAL chapter in the on line manual), the price for having all the tables in one directory will not be too high. On Friday, March 7, 2014 10:22:02 AM UTC-5, ureal frank wrote: Hi, I'm very new to web2py. I've started watching Massimo's vimeo posts and I like what I am seeing, even thinking some concepts are little strange at the beginning :) Well, my 3 questions are: - Can I define/use multiple menus inside one app? - While using PostgreSQL or so, can I share the same database between different apps? I've made this question because I want somehow to split one site in two apps. The website where users can register for a demo and the backoffice, running in a different server where users do their stuff. I just want to share the registered users and information like this. I think CAS could solve this but I am not sure. - finally (sorry guys): Can I hide the appname from the URL? I hope to have many more questions :) Many thanks in advance :) Frank -- 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 conference
I could not come, but that is wonderful. Congratulations. On Sunday, March 9, 2014 9:14:02 PM UTC-4, Massimo Di Pierro wrote: I am happy to report that the 1st web2py conference is already full after only 5 days since publishing about it: http://www.experts4solutions.com/web2py_conference/default/index We will continue to register attendees but they will be put in a waiting list in case there are cancellations or we can get a biggest space (unlikely). We also have a list of about 10 talks so far (will be published shortly). Massimo -- 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] Force all requests to https - a pointer please
I know I have read it somewhere, but I can't find it. Where can I find out how to force all requests to https? Thank you,m Cliff Kachinske -- 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] Re: Force all requests to https - a pointer please
Thanks Anthony, Right there in the core documentation. Should have known. On Thursday, February 27, 2014 9:02:36 PM UTC-5, Anthony wrote: A little easier: request.requires_https() That will redirect to the currently requested URL, but with https instead of http. Anthony On Thursday, February 27, 2014 6:27:18 PM UTC-5, Limedrop wrote: Try this: session.secure() if not request.is_https: redirect('https://%s/%s' % (request.env.http_host, request.application)) On Friday, February 28, 2014 11:46:20 AM UTC+13, Cliff Kachinske wrote: I know I have read it somewhere, but I can't find it. Where can I find out how to force all requests to https? Thank you,m Cliff Kachinske -- 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.
Re: [web2py] web2py on BeagleBone Black: optimizing ajax
Michael, I'm curious about this. Do you turn migrate off globally, or on a table by table basis? On Thursday, February 13, 2014 2:38:46 PM UTC-5, Michael Ellis wrote: On Wednesday, February 12, 2014 5:17:02 PM UTC-5, Michele Comitini wrote: run the profiler on the board: Thanks Michelle, those are good tools. They show that my ajax function accounts for only 2.6% of the time spent. The rest is web2py overhead, especially dal.define_table(), despite the fact that I have migrate set to False. My ajax function does no db access, so I'm wondering if there's a way to tell web2py to skip the db stuff and just run the function and render the output. If not, I suppose I'm going to have to find a way to go around web2py and make client-side reads directly from ZeroMQ sockets that are already running outside web2py. That sounds fragile and messy, so hope there's another answer. -- 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] Re: SQLite, SmartGrid, 2.8.2: foreign key constraint failed
Can you post the entire field definition for the foreign key field? On Thursday, February 13, 2014 12:39:26 PM UTC-5, Mirek Zvolský wrote: I have similar troubles as here: https://groups.google.com/forum/?fromgroups#!searchin/web2py/smartgrid$20foreign$20key$20constraint$20failed%7Csort:relevance%7Cspell:false/web2py/klspqXpha4E/mCwQ6HC5IhAJ I just have smartgrid, 1 parent table (main table for smartgrid), 1 child table. At the child foreign key I have standard requires=IS_IN_DB(db, db.parent.id) In parent table I have just first record, child table is completly empty. Now I navigate through the link in smartgrid row (of the single parent record) and try add the first record into child table. This fails with foreign key constraint failed Solution adapter_args=dict(foreign_keys=False) in DAL() works for me. But, can I repair it better? -- 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] Re: impossible to convert decimal
It looks like you have an empty value in the table row where you experience the error. On Thursday, February 13, 2014 6:49:44 AM UTC-5, Robin Manoli wrote: Hey, I have a decimal in db, for which I tried numerous ways to round to two decimal points, and also to calculate with other numbers. Basically I want to convert it to a float, but could find no way to do so. The Field looks like this: Field('score', 'decimal(4,3)') It does work to convert to string such as: {{=str(t.score)}} but neither does this work: {{=float(str(t.score))}} # error: type 'exceptions.ValueError' could not convert string to float: None and nor this: {{=float(t.score)}} # error: type 'exceptions.TypeError' float() argument must be a string or a number I even tried to import decimal and calculate that with t.score, but even that didn't work! What's going on? -- 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] Re: How can I show response.flash messages with different styles?
response.flash = SPAN('flash message goes here', _class='whatever') On Wednesday, February 12, 2014 8:54:46 PM UTC-5, User wrote: I am using bootstrap 2.3.2 and I would like to use Bootstrap css alert classes to style response.flash. These include: alert alert-error alert-success alert-info Is there an easy way to specify the type of flash from the controller? I'm thinking I could do something like: response.flash_style = 'alert-success' and then: {{if response.flash:}} div class=alert{{=response.flash_style or ' alert-info'}} button type=button class=close data-dismiss=alerttimes;/ button {{=response.flash}} /div {{pass}} -- 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] Re: ImportError - no module named...
The __init__.py file tells Python that the directory is a package. You can also put code in __init__.py. The code will execute when you import the package. Leave it in there. You need it. On Tuesday, February 11, 2014 6:33:41 PM UTC-5, Chris Hepworth wrote: https://groups.google.com/forum/#!searchin/web2py/importerror/web2py/FEYjCpBPpWU/9OfvXCeyPMoJ I found this thread as I searched for a solution. I can confirm that in my app, there is an __init__.py in modules. It is blank (as it has been since I created the app), but it is there. Could this have something to do with the issue? On Tuesday, February 11, 2014 4:21:54 PM UTC-7, Chris Hepworth wrote: Just to test I set up a VM running Ubuntu. I installed all relevant packages and I am still receiving the same error. Any suggestions? On Tuesday, February 11, 2014 2:12:42 PM UTC-7, Chris Hepworth wrote: There is an import for pymaging, which must have already been installed on my Ubuntu machine. Installing it on Windows seems to be more trouble than its worth, so I'll just wait to get my Ubuntu environment set up on another machine. Thanks for the suggestion though! On Tuesday, February 11, 2014 1:15:35 PM UTC-7, Niphlod wrote: are all the dependencies of that module satisfied on the windows environment ? for imported modules, if some of the libraries it depends on are missing, the error that web2py can show is that it's unable to import the module (meaning, it can't load it because there is some error in it vs - what you're probably guessing - its a non-existant module ) On Tuesday, February 11, 2014 9:09:32 PM UTC+1, Chris Hepworth wrote: I recently had to set up a new environment (my desktop running Ubuntu is dead) on my Windows laptop. I have a module called *qrcode *that worked fine in my old environment and hasn't had an issue on pythonanywhere. After I cloned the application, however, I received this error. Is there something special about Windows? I am working on replacing my desktop, but in the meantime I would love to get this working. Any help would be much appreciated! type 'exceptions.ImportError' No module named mqr.modules Version web2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 2.7.5: C:\web2py\web2py.exe (prefix: C:\Python27) Traceback 1. 2. 3. 4. 5. 6. 7. Traceback (most recent call last): File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, in restricted File C:/web2py/applications/mqr/controllers/cms.py http://127.0.0.1:8000/admin/default/edit/mqr/controllers/cms.py, line 105, in module import qrcode File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 76, in custom_importer ImportError: No module named -- 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.
Re: [web2py] Re: IS_IN_DB validator dropdown formatting
Have you tried simplejson.dump()? On Tuesday, February 11, 2014 12:52:28 PM UTC-5, Jim S wrote: Thanks Anthony. Trying this but running into a problem generating the json to use for the data. Keep getting a javascript error: SyntaxError: invalid property id data: [{quot;textquot;: quot;Skygsslo Farmsquot;, quot;descriptio On the python side I'm building it like this: for customer in db(customerQuery).select(orderby=db.customer.customerId): customerList.append(dict(value=customer.customerId, text=customer.name, description='%s, %s' % (customer.city,customer.state))) customerList = response.json(customerList) then I'm passing {{=customerList}} to the data argument in the javascript. I'm not well-versed enough in javascript/json to know how to get rid of these quotes, and even if I do, will it help? Any insight would be appreciated. Or, tell me to work it out on my own -Jim On Tue, Feb 11, 2014 at 10:07 AM, Anthony abas...@gmail.com javascript: wrote: I don't think you can put any additional HTML tags in an option element, so you would probably have to use a Javascript plugin to render a custom dropdown (e.g., http://designwithpc.com/Plugins/ddSlick). Anthony On Tuesday, February 11, 2014 10:57:00 AM UTC-5, Jim S wrote: I'm looking for a way to format the dropdown list generated from a SQLFORM. I'm using the following code: db.equipOrder.customerId.requires = IS_IN_DB(query, db.customer, ('%(customerId)s - %(name)s'), zero='..') which give me a nice dropdown list showing my customer id and name. However, I'd really like to add a second line to each item in my list that displays the city and state where the customer reside. Is there a way for me to do this using the IS_IN_DB validator? -Jim -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/dx_PQybY4MI/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- 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] Re: Best practice for a development environment together with a live environment
I have used rsync to update models, controllers, views, modules and so on. For database updates I create a separate script and test, test, test it. I don't use the DAL. Sometimes I write SQL, sometimes python using the database driver. Going forward it will probably just be SQL. On a production box you have migration set to false for all models, yes? So the process for migrating the database is: 1. Shut down the app. 2. Run your migration script. 3. Set fake_migrate = True 4. Restart the app and force fake migration on all changed tables. You can do this by opening the tables in the appadmin application or though the user interface. All you need to do is ensure you can select records out of the tables. 5. Turn all migration off Don't know if this qualifies as a best practice, but it's what I do. Also on my development box I run the same DB backend as on production. This helps eliminate surprises. On Monday, February 10, 2014 6:54:10 AM UTC-5, Robin Manoli wrote: Hey, I'm working on developing projects that will have live releases. In other words, I want to be able to develop my app calmly on a dev version, and once I'm done with that I want to synchronize it with the live version which is open to the public. I'm using two separate mysql databases for this, because I don't want to fill the live one up with garbage. The easiest way I've found is to have two different applications (one live and one dev), and to synchronize them by using rsync on linux. It is quite scary though when it comes to alter the db tables. It has happened that the live app completely breaks because of a very simple change (a change of name of a table column). I wonder how you guys encounter this situation. Do you recommend using git? Is it even possible to use git, since web2py so easily gets confused with how the database looks? It would be nice with some tutorial on this, because I have not yet learnt git or similar things. -- 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] Re: Multiple SOLIDFORMs from table rows
Have you tried it without the showid arg? On Monday, February 10, 2014 3:12:36 AM UTC-5, Mike Constabel wrote: Hi, I try to generate multiple SOLIDFORMS from table rows. Simple example in pseudo code: x = db(y.z).select() for d in x: form=CAT(form, SOLIDFORM(d)) return dict(form=form) This works for me: Model: #simplified, the tables are much longer in real db.define_table(foo_analysis_type, Field(uuid, length=64, default=lambda:str(uuid.uuid4())), Field(analysis_code, integer, label=T(analysis_code), requires=IS_INT_IN_RANGE(0,))) db.define_table(foo_analysis, Field(uuid, length=64, default=lambda:str(uuid.uuid4())), Field(customer_uuid, length=64, label=T(customer_uuid), requires=IS_IN_DB(db, 'icp_customer.uuid', db.foo_customer._format, multiple=False)), Field(analysis_type_uuid, length=64, label=T(analysis_type_uuid), requires=IS_IN_DB(db, 'foo_analysis_type.uuid', db.foo_analysis_type._format, multiple=False)), Field(order_number, integer, label=T(order_number), requires=IS_INT_IN_RANGE(0,))) Controller: fields3 = [['order_number', None]] form3 = P() analysis = db(db.foo_analysis.customer_uuid == request.get_vars.uuid).select() for a in analysis: form3 = CAT(form3, SOLIDFORM(db.foo_analysis, a, fields=fields3, showid=False, readonly=True), P()) return dict(form3=form3) For every table row i got a nice form. But I need left outer joins. And there I stuck. Same Model as above, Controller: fields3 = [['order_number', 'analysis_code']] form3 = P() analysis = db(db.foo_analysis.customer_uuid == request.get_vars.uuid).select(db.foo_analysis.ALL, db.foo_analysis_type.ALL, left=db.foo_analysis_type.on(db.foo_analysis.analysis_type_uuid==db.foo_analysis_type.uuid) ) for a in analysis: #form3 = CAT(form3, a) this works, it prints rows with all data, so the select is ok? form3 = CAT(form3, SOLIDFORM(db.foo_analysis, a, fields=fields3, showid=True, readonly=True), P()) return dict(form3=form3) Here I got type 'exceptions.AttributeError'('Row' object has no attribute 'id') I tried many other combinations of fields, forms, selects, but got every time errors. It would be really great if I can get a hint howto correct code this. Regards, Mike -- 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] Re: Inject HTML in SQLFORM.factory field from client side(js or jQuery)
On Monday, February 10, 2014 11:42:34 AM UTC-5, Andrey K wrote: Dear web2py users, I would like to add dynamically fields to SQLFORM.factory defined in the model in client side by jQuery and then get the added fields values back to db (by if form.accepted) via the standard form submit ,embedded in SQLFORM.factory . It does not seems to work on the server side - I can't get my values via form.vars.X where UI shows me new fields . Any idea what is wrong? Is the any other/better way to do it? Any your advice would be very helpful. Here is my code: *default.py:* def test_view(): fields=[Field('your_script', 'upload')] form = SQLFORM.factory(db.tool,*fields,table_name='tool_upload_tab').process() if form.accepted: response.flash = form.vars #! it does not bring me any new variables apart from the ones i have got from defatul.py return dict(form=form) *default\test_view.html* {{extend 'layout.html'}} {{=form}} input type=button value=Add Filed to Table class=add id=addTable / script type=text/javascript $(document).ready(function() { $(#addTable).click(function(){ var fieldWrapper = $('tr id=tool_upload_tab_extrafield1__row/tr'); var fName0 = $(tdinput type=\text\ id=\tool_upload_tab_field1_value\ class=\fieldname\ //td); var fName1 = $(trtdinput type=\text\ id=\tool_upload_tab_field1_comment\ class=\fieldname\ //td/tr); var fName2 = $(tdinput type=\text\ id=\tool_upload_tab_field1_label\ class=\fieldname\ //td); fieldWrapper.append(fName0,fName1,fName2); $('tbody').append(fieldWrapper); }); }); /script -- 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] Re: adding table column/field pro grammatically to existing table under controler
Andrey, Not to be negative, but why do you want to do this? On Friday, February 7, 2014 8:07:10 AM UTC-5, Andrey K wrote: Thanks Anthony for your concise answer! I have tried it in the app code - it did not work, giving me no error. I have tried your code in the terminal and it looks the code does not create new table field. Any idea why it does not work? Maybe its my db settings? I use sqlite db. Your help would very helpful to me as all my app dependent on this function. Here is my trial in a terminal: from gluon import DAL, Field db = DAL('sqlite://se2.sqlite',check_reserved=['postgres', 'postgres_nonreserved'],pool_size=10,lazy_tables=True, migrate=True, fake_migrate=False) ta_args = dict(format='%(f1)s') db.define_table('ta',Field('f1', 'string'),**ta_args) db._tables ['ta'] db.ta._fields ['id', 'f1'] #if understand correctly here I am trying to add new field 'newfield' to the ta table. db.define_table('ta', db.ta,Field('newfield', 'string', default = 'abc'),redefine=True, **ta_args) db.ta._fields #it giving me no change in db.table field list ['id', 'f1'] On Thursday, February 6, 2014 4:41:29 PM UTC+3, Anthony wrote: The safest way is probably to redefine the whole table. *models/dp.py:* tA_args = dict(format='%(f1)s', ...) db.define_table('tA', Field('f1', 'string'), **tA_args) *controllers/default.py:* db.define_table('tA', db.tA, Field('newfield'), redefine=True, **tA_args) Anthony -- 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] Re: sqlite --- postgresql
Gour, Maybe I'm missing something, but why would you develop on one back end if your production target is another? If you switch back ends you will need to go through a complete regression test before you deploy. Postgres is not that hard to set up and use. MariaDB/MySQL is equally easy. On Wednesday, February 5, 2014 3:02:50 PM UTC-5, Gour wrote: Hello, Do you consider it's safe to work with web2py on localhost machine and use sqlite3 database as storage (which greatly simplifies setup) and then deploy application on the production server by using e.g. PostgreSQL database? Sincerely, Gour -- One must deliver himself with the help of his mind, and not degrade himself. The mind is the friend of the conditioned soul, and his enemy as well. http://www.atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 -- 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] Re: sqlite --- postgresql
And maybe there's no need to switch. SQLite is not a toy. http://www.sqlite.org/whentouse.html On Wednesday, February 5, 2014 3:02:50 PM UTC-5, Gour wrote: Hello, Do you consider it's safe to work with web2py on localhost machine and use sqlite3 database as storage (which greatly simplifies setup) and then deploy application on the production server by using e.g. PostgreSQL database? Sincerely, Gour -- One must deliver himself with the help of his mind, and not degrade himself. The mind is the friend of the conditioned soul, and his enemy as well. http://www.atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 -- 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.