RE: [web2py] Re: Fixes for uWSGI + ngnix install script in Ubuntu 20.04.01 LTS?

2021-01-07 Thread Tim Nyborg
Agreed that the web2py itself shouldn’t require python 3, but python 2 is no longer the default for Ubuntu, and a public configuration recipe should reflect that.A user who really needs 2.7 for their projects will be able to adapt it without much effort. From: web2py@googlegroups.com On Be

[web2py] Re: Fixes for uWSGI + ngnix install script in Ubuntu 20.04.01 LTS?

2021-01-07 Thread Tim Nyborg
Agree that the changes merit a pull request, and the script should now be py3-specific, since we're past py2 EOL. Re. problem 3, I think the script once handled ubuntu/debian versions with initd OR systemd, and that the init config is long obsolete and should be removed. It was useful having b

[web2py] Re: Likely causes of admin server error?

2020-05-13 Thread Tim Nyborg
I'd look at the apache logs. I ran into the same problem with an nginx/uwsgi config, and uwsgi's logs pointed me to the fact that I had the wrong group on the application's file permissions. On Friday, 1 May 2020 18:52:02 UTC+1, Ian W. Scott wrote: > > What are the "likely culprits" I should be

[web2py] Mirroring/multiple URIs broken in 2.19.1

2020-04-06 Thread Tim Nyborg
The new pyDAL version included in 2.19.1 causes problems where multiple URIs are provided to the DAL, but the first is non-functional (e.g. a mirror) See details at: https://github.com/web2py/pydal/issues/620 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://

[web2py] Re: web2py with python 2.7 and web2py running on python 3

2020-03-20 Thread Tim Nyborg
Should be, but it can depend on what other tools you're using in web stack. E.g., the steps it'll take to get Apache running two different environments are different from the steps to get NGINX/Uwsgi, or Gunicorn. On Saturday, 14 March 2020 19:06:20 UTC, Andrea Fae' wrote: > > Is it possible to

[web2py] Re: Displaying for loop results only once

2020-01-21 Thread Tim Nyborg
Simplest fix: use "any" instead: {{for bookings in bookings:}} {{if any(bookings.company in q.customer.company for q in quotes):}} Quoted {{pass}} {{pass}} To avoid all this looping, you could have a separate query join the two tables and count the matches. On Saturday, 18 January 20

[web2py] Re: running two web2py instances on the same server under apache wsgi mod

2020-01-21 Thread Tim Nyborg
Yes, that should work. I have three web2py instances on a server running nginx/uwsgi, and the principle's the same: slightly different configs for each instance, pointing to separate source files. On Tuesday, 21 January 2020 11:37:55 UTC, Manuele wrote: > > Hi! > > If I need to manage on the s

[web2py] Re: Splitting long controller file

2019-08-22 Thread Tim Nyborg
Admittedly, splitting a lot of the functions into a module would be the best solution. We recently had the same challenge, and moved a bunch of functions from our default controller into their own functions, without having to change frontend calls. This only worked because the functions were i

[web2py] Re: Could this problem in production be related to web2py?

2019-06-07 Thread Tim Nyborg
, I think > you will need to different instances of Redis. > > > El viernes, 7 de junio de 2019, 7:09:26 (UTC-3), Tim Nyborg escribió: >> >> Thanks for this. Let me know if you find a resolution to the 'saving to >> disk' latency issue. Redis sessions wou

[web2py] Re: Could this problem in production be related to web2py?

2019-06-07 Thread Tim Nyborg
from Redis configuration. The first one sets the max amount of > memory that Redis is allowed to use, and "maxmemory-policy" allows you to > choose how Redis should evict keys when it hits the maxmemory: > https://redis.io/topics/lru-cache. > > > El jueves, 6 de jun

[web2py] Re: Could this problem in production be related to web2py?

2019-06-06 Thread Tim Nyborg
This is really good to know. I've a similar architecture to you, and am planning to add redis to the stack soon. Knowing about issues to be on the lookout for is very helpful. On Friday, 24 May 2019 16:26:50 UTC+1, Lisandro wrote: > > I've found the root cause of the issue: the guilty was Redi

[web2py] Re: nginx, basic auth: internal error

2019-05-08 Thread Tim Nyborg
My guess is that something is wrong with the file permissions on the sessions folder/subfolders. If uwsgi is trying to write a session file and failing, you'll get an unrecoverable error. On Wednesday, 8 May 2019 07:49:34 UTC+1, tomasz bandura wrote: > > Hello, > > I use web2py (2.16.1) on 2 en

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-11 Thread tim . nyborg
The web2py book's example could use replacing, since it relies on using __init__ and returning (value, error) rather than using def validate and returning value or raising ValidationError On Sunday, 7 April 2019 05:36:13 UTC+1, Massimo Di Pierro wrote: > > we will fix the backward incompatibilit

[web2py] Re: How can I convert a SUM from a SQLite SELECT statement to web2py's DAL?

2019-04-03 Thread tim . nyborg
Apologies. Left a lot of cruft in there which should be edited out now. On Wednesday, 3 April 2019 17:10:49 UTC+1, tim@conted.ox.ac.uk wrote: > > That will be different. SQLFORM.grid doesn't support aggregation, so > you'll need to use virtual fields to do the work, which is what I do to >

[web2py] Re: How can I convert a SUM from a SQLite SELECT statement to web2py's DAL?

2019-04-03 Thread tim . nyborg
That will be different. SQLFORM.grid doesn't support aggregation, so you'll need to use virtual fields to do the work, which is what I do to show invoices along with their current calculated balance. It's not sortable, though. Something like: def is_operador(row): return not idb(

[web2py] Re: How can I convert a SUM from a SQLite SELECT statement to web2py's DAL?

2019-04-03 Thread tim . nyborg
I think that implicit conversion of "auth_group.role = 'Operador'" to a 1 is a Sqlite-specific thing. What you want to use here is case: query = db().select( db.auth_user.id, db.auth_user.username, db.auth_user.canceled_on, db.auth_user.canceled_by, (db.auth_group.role == 'Op

[web2py] Re: HOW TO SET A DEFAULT VALUE FOR A TABLE REFERENCED IN ANOTHER TABLE

2018-11-09 Thread tim . nyborg
You set the default in client: db.define_table( 'client', Field('city', db.city, default='Value here'), ) On Friday, 9 November 2018 04:59:23 UTC, mostwanted wrote: > > if i have 2 table client and city and have city referenced in client, how > do i set a default value for city that wil

[web2py] cache.ram with nginx/uwsgi

2018-09-13 Thread tim . nyborg
Is it possible for cache.ram to work if running on nginx/uwsgi, particularly with multiple processes? I don't really care if each of my processes (4) winds up with its own cache in memory, but they seem to expire very quickly. Moving to cache.disk or Redis may be the way to go, but if simple

[web2py] Re: Setting filename to a streamed file

2018-09-13 Thread tim . nyborg
Are you setting the PDF's title before streaming it? pdf.set_title('Whatever you want to appear in the tab') pdf_stream = pdf.output(dest='S') On Thursday, 6 September 2018 13:16:32 UTC+1, Simona Chovancová wrote: > > Hello. > I have a backend function that is supposed to stream a pdf file, but

Re: [web2py] SQLFORM IS_NOT_EMPTY validator dependent on the value of another request vara

2018-01-25 Thread tim . nyborg
You need to use the onvalidation option in SQLFORM to do validation spanning several columns: def _validate_other(form): if form.vars.select_field == 'Other' and not form.vars.other: form.errors.other = 'Please provide a value' form = SQLFORM(table, onvalidation=_validate_other) for

[web2py] Re: DB model reference field conditions eg. auth_user belonging to a certain group only

2018-01-12 Thread tim . nyborg
You can put conditions into the field validator: Field('writer_user', 'string', requires=IS_IN_DB( db( (db.auth_user.id == db.auth_membership.user_id) & (db.auth_membership.group_id == db.auth_group.id) & (db.auth_group.role

[web2py] Re: auto increment field that reset evry year

2018-01-12 Thread tim . nyborg
I've done this with a table with a year as its id: idb.define_table( 'next_id', Field('year', 'id'), Field('next', 'integer'), ) def get_next_id(year): record = idb.next_id(year) if not record: # Auto add new years idb.next_id.insert(year=year, next=1)

[web2py] Re: Is there a way to put icon or image picker in form?

2018-01-11 Thread tim . nyborg
If you want to avoid javascript magic, you'll want to create a custom widget, probably something extending a dropdown. However, there are nice lightweight js libraries for adding images to dropdown options. On Tuesday, 9 January 2018 12:33:07 UTC, Dragan Matic wrote: > > I would like to have an

[web2py] Re: web2py 2.16.1 is OUT

2018-01-04 Thread tim . nyborg
My interim solution for computed fields is to set writable=False. It's fixed problems with form submission. On Tuesday, 2 January 2018 19:02:30 UTC, José Leite wrote: > > It seems that compute fields are not working anymore with web2py 2.16.1. > Can not generate thumbnails anymore. > > Is there

[web2py] Re: Help with icons

2017-12-04 Thread tim . nyborg
Answered my own question: SQLFORM.grid(ui={...}) So either solution is fine. On Monday, 4 December 2017 16:45:38 UTC, tim.n...@conted.ox.ac.uk wrote: > > Since I use fa icons all over the place, and do a fair bit of styling on > top of the w2p css, I'd sooner see 'fa fa-{name}' rules. Not as cle

[web2py] Re: Help with icons

2017-12-04 Thread tim . nyborg
Since I use fa icons all over the place, and do a fair bit of styling on top of the w2p css, I'd sooner see 'fa fa-{name}' rules. Not as clean as .icon, I admit, but it makes it easier for global rules to affect the grid. Is it possible to pass a dict of custom icon class strings to the grid, so

[web2py] show_if and radio buttons

2017-12-01 Thread tim . nyborg
Has anyone gotten field.show_if to work with the built-in radio button widget? We've a typical show_if: idb.amendment.transfer_module.show_if = idb.amendment.transfer_type == 1 And it functions just find if transfer_type uses SQLFORM.widgets.integer.widget or ...options.widget, but not ...radio

[web2py] Re: How to position students based on their total averages

2017-11-30 Thread tim . nyborg
I'm not sure I understand the link between student and student_class. Does student.class_name reference class_name.id? Anyway, I think you need to be joining things up properly, and grouping by student: def generate_report(): marks=db( (db.student_class.class_name=='5A') &

[web2py] Re: How to position students based on their total averages

2017-11-30 Thread tim . nyborg
I'm not sure I understand the link between student and student_class. Does student.class_name reference class_name.id? Anyway, I'd do something like this: def generate_report(): marks=db( (db.student_class.class_name=='5A') & (db.student.class_name == db.student_class.id)

[web2py] Re: How to position students based on their total averages

2017-11-30 Thread tim . nyborg
I think you need to give a bit more context. What are your model definitions for db.student_class and db.marks? Does each student have multiple rows in the marks table? On Thursday, 30 November 2017 09:12:14 UTC, mostwanted wrote: > > I'm at the brink of pulling my hairs out!!! > Can please pl

[web2py] Re: form grid Order by a Field Value in the Parent Table

2017-09-12 Thread tim . nyborg
Your grid should be using a query that brings in both tables, rather than just the Voyages table: def Voyages(): Voyages = SQLFORM.grid(db.EQ_Voyages.Vessel == db.EQ_Vessels.id, fields =[db.EQ_Vessels.VesselName, db.EQ_Voyages.VesselNumber], csv=False, orderby =[db.EQ_Vessels.VesselName, db.EQ

[web2py] Re: web2py 2.15.2 is OUT

2017-07-21 Thread tim . nyborg
Actually, this should be simple enough that I can post a fix. On Friday, 21 July 2017 09:35:34 UTC+1, tim.n...@conted.ox.ac.uk wrote: > > Creating a SQLFORM.factory() from tables, or a combination of tables and > fields, now breaks, because the underlying logic assumes the tables are > fields: >

[web2py] Re: web2py 2.15.2 is OUT

2017-07-21 Thread tim . nyborg
Creating a SQLFORM.factory() from multiple tables, or a combination of tables and fields, now breaks, because the underlying logic assumes the tables are fields: form = SQLFORM.factory(idb.catering, idb.catering_diet) File "/home/www-data/internal-apps/gluon/sqlhtml.py", line 1922, in factory

[web2py] Re: Advice needed on complex SQL operation

2017-06-29 Thread tim . nyborg
Below is something similar I've been playing with. The interface is utter garbage, but it shows the general idea. A form that allows you to select fields and aggregation per field: Manage a list of queries fields, adding in the field or its .sum() or .count() method as necessary. Where you're

[web2py] Re: New site on web2py

2017-06-16 Thread tim . nyborg
Very impressive. Especially impressed by the 'Save for later' process, which I bet I'll end up copying. On Wednesday, 14 June 2017 14:36:18 UTC+1, Ian Ryder wrote: > > Hi all, not sure if it's OK to do this - slap me down if not! > > We're just about to launch a new tool / site based on web2py -

[web2py] Re: web2py 2.15.1

2017-06-06 Thread tim . nyborg
Re #3: I highly recommend swapping in Eonasdan's bootstrap-datetimepicker: https://github.com/Eonasdan/bootstrap-datetimepicker I just altered my web2py_ajax.html to swap dependencies and initialize datepickers: # response.files.insert(1,'/inc/css/calendar.css') # response.files.insert(2,'/inc/

[web2py] Re: Strange behaviour of SQL query on accented characters

2017-05-30 Thread tim . nyborg
Looks like the issue is: str(query) The query is a unicode object by default, and á can't be converted to a string, since it's outside the ascii character set. Try this instead: print u"DEBUG: query = " + query On Tuesday, 30 May 2017 11:07:30 UTC+1, Karoly Kantor wrote: > > Please help: > > I

[web2py] Re: Codec MS-SQL, unicode Latin1 UTF8

2017-05-25 Thread tim . nyborg
I use this same stack, and ran into encoding issues when updating the database, because of FreeTDS v.91. But upgrading to FreeTDS v1.00.40 fixed all unicode issues: https://github.com/mkleehammer/pyodbc/issues/244 Connect with mssql4n, TDS_Version 7.1+, no need to set db_codec On Friday, 19 May

[web2py] Re: Custom formstyle for auth

2016-10-31 Thread tim . nyborg
You'll also want to set auth.settings.formstyle I've built a form style, placed it in a model (style.py), and then set response.formstyle and auth.settings.formstyle On Tuesday, 25 October 2016 15:52:12 UTC+1, Marko Seppälä wrote: > > Hi, > > I'm trying to set custom form styles for auth, like r

[web2py] Re: How to code efficiently for multiple database engines with Exceptions

2016-09-13 Thread tim . nyborg
It may be a bad move, but I defined IntegrityError in a model, so it can be nice and terse everywhere else: IntegrityError = idb._adapter.driver.IntegrityError Where I have two different databases, I just added it to the database objects: db.IntegrityError = db._adapter.driver.IntegrityError idb

[web2py] Re: SELECT without duplicates for a specific field

2016-06-09 Thread tim . nyborg
Looks like you want a subquery. You'll need to decide which of the items to choose when you have a given category_code. Say you want the first item with a given category code: sub_query = db()._select(db.products.id.min(), groupby=db.products.category_code) results = db(db.products.id.belongs(s

[web2py] Re: alternative autocomplete widget

2016-02-12 Thread tim . nyborg
I've been thinking about doing this exact thing for a while, so I'll be eagerly watching your plugin On Thursday, 11 February 2016 16:18:28 UTC, Carlos Cesar Caballero wrote: > > Hi, right now I am working in a plugin with an autocomplete widget using > typeahead.js: > > https://github.com/daxs

Re: [web2py] Re: Virtual fields disapeared from select() results (v2.11.2)

2015-06-09 Thread tim . nyborg
Lovely! I was just about to post this problem. On Tuesday, 9 June 2015 07:56:35 UTC+1, Paolo Valleri wrote: > > I see the problem now, thanks for pointing it out. > I'll post a fix later today. > > Paolo > > 2015-06-08 22:11 GMT+02:00 Donatas Burba >: > >> This is failing example: >> >> db=DAL('

[web2py] MSSQL and Unicode problems

2015-04-07 Thread tim . nyborg
Here's a question for those of you experienced integrating MSSQL and web2py. My web2py apps connect to a legacy SQL Server 2005 database, but I'm running into a problem where any attempts to *insert *unicode data into my nvarchar fields breaks the encoding (Renée -> Renée) It seems the Unicode

[web2py] Bug: SQLFORM.accepts() breaks formstyle when widgets are defined

2015-02-19 Thread tim . nyborg
I'm using a custom formstyle to apply bootstrap3 to my forms (a modified copy of the built-in bootstrap3_inline). Importantly, it adds the form-control class to each input. This works fine, until you define a widget for a field, and have it fail validation. db.define_table('test', Field('

[web2py] Re: ckeditor : how to make read only, how to remove the toolbar in a dynamic way

2015-02-02 Thread Tim Nyborg
Depends on how you're implementing the widget. I've got a CKEditor widget as follows (pretty much a glorified copy of text.widget with the ckeditor class): class CKEditor(FormWidget): _class = 'ckeditor' @classmethod def widget(cls, field, value, **attributes): """

[web2py] Re: Override update defaults?

2015-01-28 Thread tim . nyborg
Your first suggestion's clever, and not too hard to extend. Have a list of admin functions, check if request.function is in it. At the moment, I've got a disabling routine, and pass all the table names: def suppress_timestamp(*tables): #Stop updating of modified_on and _by, given a l

[web2py] Re: Record format and SQLFORM.factory

2015-01-27 Thread tim . nyborg
form = SQLFORM.factory( Field('Presupuesto', requires=IS_IN_DB(db, db.presupuesto, *db.presupuesto._format*)), submit_button='Continuar', table_name='presupuesto', ) On Monday, 26 January 2015 16:09:31 UTC, César Bustíos Benites wrote: > > Hello! I have a table called

[web2py] Re: About validators

2015-01-27 Thread tim . nyborg
'but I get "abcDEF"' How did you get that? form=FORM(INPUT(_type="text", _name="n", requires=IS_LOWER())) if form.process().accepted: response.flash = form.vars.n The above spits out 'uppercase' when I entered 'UPPERCASE' On Tuesday, 27 January 2015 15:15:34 UTC, mweissen

[web2py] Override update defaults?

2015-01-27 Thread tim . nyborg
I'm really liking the ability to automatically timestamp when records are updated, but I'm wondering if there's a simple way of suppressing this behaviour when needed: I have these signature fields appended to a number of tables, automatically recording when users update records: signature_fiel

[web2py] Re: One AutoComplete overrides another

2014-12-22 Thread Tim Nyborg
I haven't found a solution to this, but have found more detail about the problem: The first defined autocomplete widget on a particular field overrides ALL others defined after. idb.define_table( 'fee', ... Field('module_code', 'string', writable=False, label='Module code',

[web2py] Re: One AutoComplete overrides another

2014-12-22 Thread tim . nyborg
Found my mistake; hopefully it will save someone time in the future. Multiple autocompletes referring to the same field need keyword arguments, otherwise they all end up as the default '_autocomplete_%(tablename)s_%(fieldname)s' (_autocomplete_module_code in my case). Once I gave them distinct

[web2py] Re: Hyphen in application name

2014-12-16 Thread tim . nyborg
After some further digging, I'm not sure map_hyphens can possibly work on application names as things sit. In map_app() in rewrite.py, the incoming app name is never translated. I added the following code near the top of the function, and everything started to work. if routers.BASE.ma

[web2py] Re: Hyphen in application name

2014-12-16 Thread tim . nyborg
I've put Routes.py in the root web2py directory. You may be right about a bug, though. I've loaded up a fresh local copy of web2py, created an app called a_b, and set up the routing: routers = dict( # base router BASE=dict( default_application='welcome', map_hyphen=Tru

[web2py] Hyphen in application name

2014-12-15 Thread tim . nyborg
Does anyone know how to get map_hyphen to work with an application name? I have a routes.py setup as follows: routers = dict( BASE = dict( default_application = "home", default_controller = "default", default_function = "index", map_hyphen=True, ),

[web2py] Re: SQLFORM - best method for hide fields and set default values

2014-12-10 Thread tim . nyborg
That's the method I use, more or less, as it seems the simplest and most reliable to set defaults. Would it be easier if those fields were writable = False and readable = False in the model, and the other form used ignore_rw=True? You might also put db.registrations.registered_user.default = au

[web2py] Re: Customizing generated columns from SQLFROM.grid

2014-11-07 Thread tim . nyborg
Or, on the slightly simpler side: before you call SQLFORM.grid(): from gluon import TAG db.house.location_type.represent = lambda value, row: TAG.abbr(value, _title=row.location_type_msg) db.house.capacity.represent = lambda value, row: TAG.abbr(value, _title=row.capacity_msg) -- Resources:

[web2py] Re: SQLFORM.grid want no initial values

2014-11-07 Thread tim . nyborg
It's easy enough if you have a separate search-form: searchform = SQLFORM.factory(...) form = None if searchform.process().accepted: form = SQLFORM.grid(...) If you're wanting to use the built-in grid search tool, you could set the query to return 0 results unless keywords is in get_vars: d

[web2py] Re: Allow form re-submission / suppress disableElement?

2014-11-07 Thread tim . nyborg
Clever. I took the route of replacing the Button with an anchor that submits the form via javascript: export_form = FORM(LABEL('Export batch #'), DIV( INPUT(_type='text', _name='number', _class="span2", _id="appendedInputButton"),

[web2py] Allow form re-submission / suppress disableElement?

2014-11-03 Thread tim . nyborg
I have a form which allows a user to download a CSV, given a batch number, without having to leave the page. However, I'd like to allow form re-submission, since the user might want to run the CSV export several times. Web2py.js disables buttons on form submission, but is there a simple way t

[web2py] One AutoComplete overrides another

2014-10-16 Thread Tim Nyborg
I've run into an odd problem with autocomplete: I have a factory form doing an autocomplete lookup on the field idb.module.code, with custom help_fields, etc., and it works well: browseform = SQLFORM.factory(Field('code', widget=SQLFORM.widgets. autocomplete(request, idb.module.code, id_field=id

[web2py] Maxlength for string and text inputs in SQLFORM

2014-08-08 Thread tim . nyborg
Is it possible to have a string or text field's length parameter automatically populate the SQLFORM-generated input's maxlength? Such that: Field('personname', 'string', length=32, label='First name', requires=[IS_LENGTH(32), IS_NOT_EMPTY()]), Will produce: I know I can add the parameter to t

[web2py] String-keyed tables, SQLFORM, and query shortcuts?

2014-02-19 Thread Tim Nyborg
I'm connecting to a legacy MSSQL database, and have an important table which has an alphanumeric primary key: db.define_table('module', Field('modid', 'string'), ... primarykey=['modid']) When I generate an update SQLFORM (form = SQLFORM(db.modu

[web2py] Re: Treat Datetime field as Date?

2014-02-19 Thread Tim Nyborg
gt; why the overcomplication ? as other backends that don't support date every > date field in DAL gets turned to a datetime (with 0 hours, minutes and > seconds) and it's automatically handled. > > On Wednesday, February 12, 2014 6:31:06 PM UTC+1, Tim Nyborg wrote: >> >> I

[web2py] Treat Datetime field as Date?

2014-02-14 Thread Tim Nyborg
I'm connecting to an MSSQL 2005 db, which only has the Datetime format (Date was added in 2008). Is there a standard way to treat a Datetime as a Date in web2py for forms and formatting? I've done the following, and it works thus far, but it seems a bit hackish. Field('BirthDte', 'datetime',