[web2py] Re: Asking support for MySQL create/alter column "AFTER" keyword

2021-07-22 Thread Alfonso Serra
objects.py, or overwrite with the attached objects.py file. Its naive and in progress as it only supports common mysql types. Please let me know how it looks, ill try to integrate this into pydal on my own but i still have to study how. Thanks Best Regards. On Wednesday, 24 January 2018 at 00:01:33 U

[web2py] Re: Encoding problem with a web2py application that implements an XMLRPC webservice

2019-07-06 Thread Alfonso Serra
sys.setdefaultencoding will work thorough the server execution process. So as long it is alive you wont need to call it several times. It will probably work if you set that up on routes.py or web2py.py so its not called per request. As long as it fixes your problem i wouldnt care whether it

[web2py] Routes on error and ajax bug

2019-07-06 Thread Alfonso Serra
I have been able to reproduce a bug with the welcome app when routes on error is in use on localhost: Steps to reproduce: 1.- create an app "myapp" 2.- create another app "errors" 3.- Edit routes.py default_application = 'myapp'# ordinarily set in base routes.py default_controller = 'index'

[web2py] Re: how to distinguish between an application error and HTTP(500, "Cant do")?

2019-07-05 Thread Alfonso Serra
I have tracked the problem to globals.py line 126 if 'X-Progress-ID' not in request.get_vars: copystream(source, dest, size, chunk_size) return dest if i disable this condition, any raise HTTP returns fast with code 500 regardless the code or response i would use. I guess this would

[web2py] how to distinguish between an application error and HTTP(500, "Cant do")?

2019-07-05 Thread Alfonso Serra
Hi. I have set up anerror handler on routes.py as: routes_onerror = [(r"*/*", r"/admin/errors/index")] Its quite slow but its fine for now. The problem is that im trying to emulate a failed response out of an ajax request and its taking 15 secs to respond, using on the controller: raise

[web2py] Re: Is there any way to preprocess a view before its rendered?

2019-02-08 Thread Alfonso Serra
This would be a solution: At gluon/templates.py line 790, poll for "*response.parseview*" which is a custom function that will get the template text and return a modified one: else: text = filename.read() response = context.get("response") if response and

[web2py] Re: Is there any way to preprocess a view before its rendered?

2019-02-08 Thread Alfonso Serra
Those are all good alternatives. ill investigate the js option but cant process a view with js delimiters as \{{ as they will be interepreted by python. response.render is not documented but found an example at

[web2py] Is there any way to preprocess a view before its rendered?

2019-02-08 Thread Alfonso Serra
Hi. The question would be if theres any way to run a function taking a composed unprocessed view as argument to return a modified one, before its executed and rendered. The problem im trying to solve is because handlebars, jquery or knockout js are using the same delimiters as web2py. Im

[web2py] Re: cant access error admin

2019-01-20 Thread Alfonso Serra
Hi the traceback is pretty clear, these are 2 different errors and the full traceback should point you to where these happened, unfortunately just with a fragment we cant see where the error was originated. The ascii error should go away by declaring "# coding: utf-8" at the begining of the py

[web2py] Display errors on the same page tutorial

2019-01-20 Thread Alfonso Serra
I believe i have found a proper way to display errors on the same page that causes them without having to modify web2py core files. [image: 2019-01-20_152028.png] This is useful on the development stage since we would see the problem directly without having to navigate to the admin area or

[web2py] Re: Modules Import Problem.

2019-01-06 Thread Alfonso Serra
Hi Massimo, thanks for your answer. sites-packages is an option indeed. Importing modules works without issues when i fully qualify the import path like: from applications.myapp.modules.utils import anyfunc I have been reading the custom_import, which tries to find or reload the module

[web2py] Re: Modules Import Problem.

2019-01-02 Thread Alfonso Serra
Hi, so far it looks like this works: at the model 01_config.py import sys sys.path.insert(0, r"E:\webdev\web2py-mod.02\applications\myapp\modules") then im able to import as: from utils import myfunc where utils.py is an application module at applications\myapp\modules -- Resources: -

[web2py] Re: Modules Import Problem.

2019-01-02 Thread Alfonso Serra
Hi, im having a similar issue: In modules, i have a utils.py module with a function called "first" that i cant import from another module. The problem is that theres a utils.py module installed in the python standard library that obviously doesn not has that function and its being imported

[web2py] Re: Validate a GET request using SQLFORM.factory and request vars

2018-04-27 Thread Alfonso Serra
The auto id field, may not be a problem, i removed it for convenience for a couple of reason: - iterate form.fields in the view to create the html. in this case was not needed but also the special treatment as it should lie on hidden inputs. - the type checking on this case was validating the id

[web2py] Re: Validate a GET request using SQLFORM.factory and request vars

2018-04-26 Thread Alfonso Serra
> I'm not sure about this. We already have default validators in place when > using SQLFORM with a DAL table. This breaks down when using SQLFORM.factory > because DAL(None) does not generate the default validators -- but it would > probably be a better approach to change that behavior so

[web2py] Re: Validate a GET request using SQLFORM.factory and request vars

2018-04-26 Thread Alfonso Serra
Hi Anthony. Didnt think of the mixed case but it makes sense. getvars on a post could be used to indicate an app state at a given time for example. Please allow me some considerations: - The only case request.vars could be a problem would be when there are variables with the same name on both

[web2py] Re: Validate a GET request using SQLFORM.factory and request vars

2018-04-25 Thread Alfonso Serra
Thanks Anthony. I think ill submit a patch, Im doing some debugging and i have noted a few things: Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 gluon/html.py line 2217 kwargs['request_vars'] = kwargs.get( 'request_vars', current.request.post_vars) the validate

[web2py] Re: Validate a GET request using SQLFORM.factory and request vars

2018-04-25 Thread Alfonso Serra
Thanks Anthony. It worked but now it always validates no matter what. I have passed # request.vars request.vars._formname = "get_rates" print "accepts:", form.accepts(request.vars, session=None, dbio=False, formname="get_rates") print "validate:", form.validate(request_vars=request.vars,

[web2py] Validate a GET request using SQLFORM.factory and request vars

2018-04-24 Thread Alfonso Serra
Hi everybody. Im trying to validate a simple GET request using SQLFORM.factory. but cant get it to pass. I would like just to validate those variables but i dont know what im missing. On the docs theres not much info about forms and the get method but form.accepts(request.vars, ...). The url

[web2py] Re: Why web2py server hangs/freeze?

2018-04-21 Thread Alfonso Serra
I have had the exact same problem the server hanged for a minute to get an undescriptive IOError. I have been able to solve it by commenting these lines on one of my models. from gluon.custom_import import track_changes track_changes(True) wasnt using modules anyway. Hope it helps. --

[web2py] Error in IS_DATE / IS_DATETIME validator?

2018-02-11 Thread Alfonso Serra
This one took me a while to figure it out: im declaring a model as: date_format = "%Y-%m-%d" db.define_table("bookings" , Field("start_date", "datetime") , Field("end_date", "date", requires = IS_DATE(format=date_format)) , Field("agency", "reference agencies", format="{agency}")

[web2py] Re: What does a SQLFORM needs to delete a record?

2018-01-28 Thread Alfonso Serra
Because i was trying to indicate the form to delete a record but it is retrieved instead which does not make much sense. If it is not a mistake i made and the SQLFORM always retrieves the record before deletion it may be something to improve, unless there is any case im probably missing. On

[web2py] Re: What does a SQLFORM needs to delete a record?

2018-01-28 Thread Alfonso Serra
Not ajax, a regular post, i have even tried removing that condition. No luck, maybe the custom widgets are messing it up. i have finally chosen to delete the record directly bypassing the form. That said, why would you retrieve and or validate the record if its going to be deleted? --

[web2py] Re: Widget executing more times than it should

2018-01-28 Thread Alfonso Serra
Sorry this would be the controller: def index(): tbl = request.args(0) table = "" id = request.post_vars.id delete = False if request.post_vars and id: if request.post_vars.delete: request.post_vars.pop("delete") delete = True

[web2py] What does a SQLFORM needs to delete a record?

2018-01-28 Thread Alfonso Serra
Im have created a form with 2 submits for update and delete the record but whatever i do the record is not deleted: This is the controller tbl = request.args(0) if request.post_vars and request.post_vars.submit=="Delete": request.post_vars['delete_this_record'] = "on"

[web2py] Widget executing more times than it should

2018-01-27 Thread Alfonso Serra
I have a table with 4 records and a datetime field At the database: start_date 2018-02-24 00:00 None 2018-01-27 14:17 2018-01-24 00:00 the model is: db.define_table("bookings" , Field("start_date", "datetime", widget=date_widget) , Field("end_date", "datetime", widget=text_widget) ,

[web2py] Re: routes on error question.

2018-01-27 Thread Alfonso Serra
Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 downloaded a few days ago. When i disable the routes on error all works well. Not related but i have also ran into errors on sqlhtml.py line 1504 elif field.widget: inp = field.widget(field, default) this trying to execute when default

[web2py] Re: routes on error question.

2018-01-27 Thread Alfonso Serra
I may have ran into a web2py bug: this is the requested controller: def index(): if request.ajax: raise HTTP(500, "cant do it") this is the error handler function errors.py: def index(): # dd(response.toolbar()) return "cant do it from error.py" and i get a 400 BAD REQUEST

[web2py] routes on error question.

2018-01-27 Thread Alfonso Serra
what do i need to return at an error handler controller to get the same as web2py does by default? Let me ellaborate: I have implemented "routes on error" at routes.py like: routes_onerror = [ (r"*/*", r"/error") ] so any error goes through "/myapp/controllers/error.py" (note i have

[web2py] Re: Asking support for MySQL create/alter column "AFTER" keyword

2018-01-23 Thread Alfonso Serra
This works only on newly created fields over MySQL. Moving fields around on your model wont reorder them. Version 2.15.3-stable+timestamp.2017.08.07.12.51.45 migrator.py line 364 field_position = sql_fields[key]['sortable'] after = "FIRST"

[web2py] Re: Asking support for MySQL create/alter column "AFTER" keyword

2017-12-18 Thread Alfonso Serra
I would love to, have some time in December to spend in personal projects. Any directions or shall i start researching the source code? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Asking support for MySQL create/alter column "AFTER" keyword

2017-12-07 Thread Alfonso Serra
Hi everybody. I would like to ask for support for the create column "AFTER" another column keyword so whenever we change something in our models the order of the columns in the database is respected. I know this is a cosmetic change but migrations wont mess up column order this way. In large

[web2py] Re: DAL write permission error

2017-12-07 Thread Alfonso Serra
Unable to open the database could mean: - The database does not exists. - The credentials to access the database are wrong. - Theres not read/write access to the file. - The database is corrupted. If you get the full trace stack there may be more information to know which one is the problem. I

Re: [web2py] Re: Support for BIT(1) as boolean?

2017-09-22 Thread Alfonso Serra
Yan's example worked. But still there are some quirks with the scheduler using connections for long processes. You are able to change T and F for good editing gluon.packages.dal.dialects.base.py line 36 then use Field(.., type = "boolean") as usual. No adapter change with problems or

Re: [web2py] Re: Support for BIT(1) as boolean?

2017-09-22 Thread Alfonso Serra
Thanks Yan, i will use your example if i cant fix this. I can confirm the problem on Version 2.15.3-stable+timestamp.2017.08.07.12.51.45. This is dal declaration working fine on previous versions db = DAL("mysql://myuser:mypassw@localhost/myapp", pool_size = 10, check_reserved=False, migrate

Re: [web2py] Re: Support for BIT(1) as boolean?

2017-09-11 Thread Alfonso Serra
Hi Massimo. This is the db declaration im using. It works well so far not using copy. Standard MySQL 5.5.24 connection. I have read that using BIT may cause problems on calculations with another fields, so TINYINT(1) (-127, 127) would do for a lack of a better option. db =

[web2py] Re: Two database join query

2017-08-28 Thread Alfonso Serra
I guess this is the solution: https://stackoverflow.com/questions/6824717/sqlite-how-do-you-join-tables-from-different-databases If you want to write simpler sqls, the tables should be within the same database. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Is it posible to fallback to static files when a controller is not found?

2017-08-27 Thread Alfonso Serra
Simpler and better approach: routes_in = ( # do not reroute admin unless you want to disable it (BASE + '/admin', '/admin/default/index') , (BASE + '/admin/$anything', '/admin/$anything') # do not reroute appadmin unless you want to disable it , (BASE + '/$app/appadmin',

[web2py] Re: Is it posible to fallback to static files when a controller is not found?

2017-08-27 Thread Alfonso Serra
Think i got it: routes.py: routes_onerror = [ # (r'init/400', r'/init/default/login') # ,(r'init/*', r'/init/static/fail.html') # ,(r'*/404', r'/init/static/cantfind.html') ('*/*', '/myapp/default/handle_error') ] In app/default.py def handle_error(): code =

[web2py] Re: change_password validator

2017-08-27 Thread Alfonso Serra
I was able to setup IS_STRONG like this: db.auth_user.password.requires.insert(0, IS_STRONG()) Be careful, after doing this users wont be able to log in if their password is not strong, validated. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Is it posible to fallback to static files when a controller is not found?

2017-08-27 Thread Alfonso Serra
im trying to fallback to the static folder when a controller is not found, for example: a route like: img is not a defined controller so i would like to redirect this route to "/static/img/mypicture.png", how do i do that? I have tried: BASE = '' # optonal prefix for incoming URLs

[web2py] Re: how to rewrite an URL to drop a function name showing in the address bar

2017-08-27 Thread Alfonso Serra
A solution would be to use routes.py in there you can place something like routes_in = [ ('/stock/showcase/$anything', '/stock/showcase/index/$anything') ] and use the index function to do whatever you like with the view. You redirect everything through the index function so you wont be able to

[web2py] Re: Posible bug in SQLFORM

2017-04-26 Thread Alfonso Serra
Before i drive you crazy, i have commented the function SQLFORM.createform so i could implement my own form styles just passing the SQLFORM instance to a function like: def renderform(self): style = self.formstyle return str(self.formstyles[style](self)) response.formstyle =

[web2py] Posible bug in SQLFORM

2017-04-26 Thread Alfonso Serra
I have declared a table as db.define_table("agencies", Field("hotel", "reference hotels", notnull=True), Field("subgroup", "reference subgroups", label="Subgroup"), Field("agency", "string", length=100, writable= False, label="Agency", notnull=True), Field("alias", "string"),

[web2py] Re: How can I union 2 different table datasets?

2017-04-26 Thread Alfonso Serra
You can try: sql = """ SELECT * FROM table1 UNION SELECT * FROM table2""" rows = db.executesql(sql, fields = [ Field("name", "string") , Field("age", "integer") , Field("apt_time", "datetime") ]) Always that both tables are the same size and types. Then style your view however you like.

[web2py] Re: The Almighty Form

2017-04-26 Thread Alfonso Serra
This is great i have found a way to have full control on how a form is displayed and behave other than writing mystyle(form) in a view. This is how it would look like: def stylefrm(self): #create any custom header or form.custom.begin frm = FORM(_class="myform") #iterate over

Re: [web2py] Re: btw: great job

2017-04-26 Thread Alfonso Serra
Great initiative, Lucas. My thanks to Massimo, Anthony, Niphlod and everybody helping and collaborating in the past, present and future of this wonderful framework. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

Re: [web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Alfonso Serra
As per the docs, they say they are stored in db but not computed on retrieval. i guess this applies to updates. Does this calculate_field function does not return a value in some case? for example total = unit * price may be None if the operation fails because either unit or price is None or

[web2py] Re: Using validate_and_insert with a computed field

2017-04-18 Thread Alfonso Serra
Hi Chris, why do you use requires IS_NOT_EMPTY in a computed field?, if you do, you have to supply a value before is computed, isnt it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: Removing item from list:Reference

2017-04-18 Thread Alfonso Serra
Will this work for you? company = db(db.companies.id==1).select().first() company.projects.remove(1) use db.commit() afterwards if this is ran in a console instead a controller. Ideally you could use foreign keys to delete related projects data or dependencies. Have in mind that list fields

[web2py] Re: Auth change password confirmation

2017-04-12 Thread Alfonso Serra
What i wanted is a profile page with all the auth forms, profile, change password and create users if the logged in user is an admin. As for the change password confirmation i have to use session.flash to got the success message but the problem was it is always empty even when the form was

[web2py] Is there any way to undo impersonation?

2017-04-09 Thread Alfonso Serra
I have implemented an admin impersonating users successfully, but was wondering if theres any way to go back to the admin while impersonating without having to manually logout - loging. Thanks -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Auth change password confirmation

2017-04-09 Thread Alfonso Serra
Thanks Anthony, but thats the matter, redirection is not optional. It will happen regardless. I would like not to redirect to make use of form.errors, form.accepted to style the view. Other issue is that change password and profile shares the same view, so there are multiple redirections going

[web2py] Re: auth.register is only posible when theres not a user logged in.

2017-04-09 Thread Alfonso Serra
auth.register_bare sounds like it is what im looking for. Il give it a try, Many thanks 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

[web2py] auth.register is only posible when theres not a user logged in.

2017-04-09 Thread Alfonso Serra
form = auth.register() doesnt have in mind private sites like business dashboards where an admin would be able to register new users. Its only posible to register users when theres not a user logged in. tools.py line 3267: def register(self, next=DEFAULT,

[web2py] Re: Auth change password confirmation

2017-04-09 Thread Alfonso Serra
Ok its sorted but i had to change tools.py to remove the redirection, line 3978 like: if form.accepts(request, session, formname='change_password', onvalidation=onvalidation, hideerror=self.settings.hideerror):

[web2py] Re: Auth change password confirmation

2017-04-09 Thread Alfonso Serra
It is always False. Reading the auth.change_password() code. Theres always a redirection. The only method to know about the password change is session.flash. Now i cant get session.flash because i have multiple auth forms in the same view and there may be multiple redirections that sets

[web2py] Auth change password confirmation

2017-04-09 Thread Alfonso Serra
I cant check if the auth form to change a password is accepted. I have been debugging a post and post_vars and form.vars are empty. I dont know whats going, the password is changed succesfully but i cant display a message since i dont know how to check the form's state. I have the profile and

[web2py] Re: conditional use of None

2016-11-16 Thread Alfonso Serra
Have you tried?: if request.get_vars.specificAddressID == "None": Whatever you put in the url is not python, so specificAddressID=None is translated as a string. To translate it into python's None i think the url should be something like:

[web2py] Re: Difference between migrate = False or migrate_enabled = False

2016-10-15 Thread Alfonso Serra
Yes Stifan, but isnt the same thing? migrate = False disables migration for all tables migrate_enabled = False disables all migrations? Are there migrations not meant for tables? Thats the question. If they are the same thing why the need of 2 parameters? Is a legacy feature? Thanks --

[web2py] Difference between migrate = False or migrate_enabled = False

2016-10-15 Thread Alfonso Serra
Yes what's the difference between migrate = False and migrate_enabled = False on a DAL declaration? Since all my mysql tables are defined and they need some extra UNIQUE indexes (that are removed automatically if migrate = True). What would be the way to disable migrations in general and only

[web2py] Re: web2py resources

2016-09-12 Thread Alfonso Serra
Another tool for Firefox that may help to develop your applications. This AutoHotKey script reloads your browser and removes the repost Confirmation dialog whenever you press Ctrl + S. So if you save your code in any editor Firefox will show the changes. Havent tested for Chrome but it may work

[web2py] Re: how to handle boolean's tri states?

2016-07-09 Thread Alfonso Serra
> > Actually, the API for creating a custom field type is > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Custom-Field-types--experimental-. > > Note, it isn't documented, but SQLCustomType also takes "validator", > "represent", "widget", and "_class" arguments,

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Sorry, to finish up some considerations... Ive been investigating how web2py assigns default validators to field types. If im not wrong this is done by SQLFORM which imports a function from gluon.dal called _default_validators. In this function the relationship between web2py field types and

[web2py] Re: Do not show None

2016-07-08 Thread Alfonso Serra
Declare your field as: Field("price", "double", represent = lambda f, r: r.price if r.price != None else "") Here represent is a function that will format the field's value and takes the field itself and the row as arguments. To display the table. def index(): table =

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
This should do it: Field("with_kids", "integer", length = 1, notnull = False, default=None, required = False, requires=IS_NULL_OR(IS_INT_IN_RANGE(0,2)) ) Ive tested it and it converts correctly, and accepts the tri state. Thanks again. -- Resources: - http://web2py.com -

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Absolutetly right, i just realised that. @Richard Rather than a string field, i tried your approach using an integer and IS_IN_SET() but the problem is that bool conversion happens after that is executed. Hmm, actually this might work since as integer the bool conversion wont take place,

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
You are right. The real scenario is: Im using a table to store filters that are used to retrieve data from another table. This other table are bookings, and i need a filter to retrieve either all of them, or with kids, or without them. The form of such filters has 3 kind of submits "Execute

[web2py] Re: how to handle boolean's tri states?

2016-07-08 Thread Alfonso Serra
Just to post the right solution. filter_in didnt work out since im not saving the form when its posted, just using the form to generate a query. So the right solution would be something like: form = SQLFORM(db.myfilters).process(dbio=False, keepvalues=True, onvalidation=enable_bool_tri_state)

[web2py] Re: how to handle boolean's tri states?

2016-07-07 Thread Alfonso Serra
> > Thanks Richard, Anthony, very good answers. > The use case is simple: For example, query articles with a field of uncatalogued, you can either select catalogued, uncatalogued or all (doesnt matter if its uncatalogued). To store such filter i can make use of a boolean tri state, True,

[web2py] Re: how to handle boolean's tri states?

2016-07-07 Thread Alfonso Serra
MySQL with TINYINT as booleans: db = DAL("mysql://", pool_size = 10, check_reserved=None, migrate=True) db._adapter.types['boolean']='TINYINT(1)' db._adapter.TRUE = 1 db._adapter.FALSE = 0 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] how to handle boolean's tri states?

2016-07-07 Thread Alfonso Serra
If i define a boolean field as: Field("mybool", "boolean", required = False, notnull = False, default = None ) Its stored as False if its not present in request.post_vars. The proper behaviour would be to store a null value in this case, which allows to handle boolean's tri-states. To achieve

[web2py] Re: Is there any way to inherit from Row?

2016-05-17 Thread Alfonso Serra
Thanks Anthony it works. I get the result but the sql is not quite right. Inspecting db._lastsql i see this: SELECT subgroupfields... FROM groups, subgroups WHERE ((groups.hotel = 1) AND (groups.id = groups.id));' Performancewise im not sure if thats the same as declaring Joins. Its good to

[web2py] Re: Redirect after profile update

2016-05-17 Thread Alfonso Serra
Instead on relying on callbacks you could implement the user() controller in default.py login, logout, register, profile, and so on are passed as request.args in default.py, something like: def user(): if auth.user: if request.args == "profile": if user.type == "seller":

[web2py] Re: Is there any way to inherit from Row?

2016-05-17 Thread Alfonso Serra
Yep it isnt working well inheriting from Row. The instance looks like a row, but all the db methods doesnt work. update_record, and such. Following your advise and going back to web2py recursive selects i have this problem: Given this schema: - A company has groups and groups has subgroups I

[web2py] Re: Thread with own db connection

2016-05-16 Thread Alfonso Serra
Well, the sceduler starts with an error because im mapping booleans to tinyint in 01_db.py. But it doesnt fail inserting booleans. db = DAL("mysql://cnnstring", pool_size = 10, check_reserved=None, migrate= True) db._adapter.types['boolean']='TINYINT(1)' db._adapter.TRUE = 1 db._adapter.FALSE =

[web2py] Re: Thread with own db connection

2016-05-16 Thread Alfonso Serra
The difference is, from my modest knowledge about the scheduler, the following. The scenario is: - Users have to be able to import a csv to one of the tables. csv's may be big 8mb, 40k rows. (worst case) - Users may do this whenever they want, so concurrency would occur. Implementation

[web2py] Re: unknown ticket on server for all sites

2016-05-15 Thread Alfonso Serra
Bit locker is a windows feature that encrypts your harddrive so no one can read your files. It might be this, you can read your files but the uploaded ones are encrypted, readable only by your windows machine. You can try this

[web2py] Re: Is there any way to inherit from Row?

2016-05-15 Thread Alfonso Serra
> > Why not? That's how ORMs do it -- everything related to a given model > lives in a single class. After all, the logic in question does pertain to > the associated model. > You don't need classes to organize code. > All the tables/models are connected somehow by reference fields. I dont

[web2py] Re: unknown ticket on server for all sites

2016-05-14 Thread Alfonso Serra
Still, what operating system are you running? Does it have bitlocker or similar enabled? I dont know how bitlocker works but you could be uploading an encrypted file to your server. Easy to check If you try any other text file and it works. -- Resources: - http://web2py.com -

[web2py] Re: Is there any way to inherit from Row?

2016-05-14 Thread Alfonso Serra
Thanks for the advise. Yes you are right i didnt need the join, was just following the same pattern as other queries which does need them, not this case. Also right with virtual fields, they are easy to use but i dont think i should write tens lines of code within a lambda. My webapp is getting

[web2py] Re: Is there any way to inherit from Row?

2016-05-14 Thread Alfonso Serra
Sry i got it. super(Hotel, self).__init__(db.hotels[id]) -- 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

[web2py] Is there any way to inherit from Row?

2016-05-14 Thread Alfonso Serra
I would like to subclass a Row object but cant get it right. What would be the way? from pydal.objects import Row class Hotel(Row): _room_types = None _regimen_types = None _agencies = None _countries = None def __init__(self, db, id): super(Hotel, self).__init__()

[web2py] Re: Problem with routes

2016-05-14 Thread Alfonso Serra
Finally i got it right. Its so cool, ive corrected something that happens when you are logged in, if you visit /myapp/default/user it takes you to the login page, i was able to redirect to the profile page. If the url ends with numbers it converts them into args regardless the url you are in.

[web2py] Re: I tried learning scheduler but got messed up. Can someone help me with this?

2016-05-14 Thread Alfonso Serra
Making the scheduler work wasnt easy for me either. You said earlier the db was being flooded which is a good sign, the scheduler is working. As for the parameters take a look here: http://web2py.com/books/default/chapter/29/04#Complete-Scheduler-signature And here:

[web2py] Re: I tried learning scheduler but got messed up. Can someone help me with this?

2016-05-14 Thread Alfonso Serra
Its just doing what you told it. Inserting a record each time it runs. So ye, its working. Just make sure to tell it how long it should pass between executions. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: unknown ticket on server for all sites

2016-05-14 Thread Alfonso Serra
Hmm looks bad, ransomware on your server? Do you have a copy of your database? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list

[web2py] Re: Problem with routes

2016-05-14 Thread Alfonso Serra
Thanks Anthony ill give it a try but i dont quite understand how it works. Anyway the pattern routes are working but Auth doesnt realise the routes are mapped resulting in wrong _next and logout redirections. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: db.import_from_csv_file

2016-05-14 Thread Alfonso Serra
I dont think its the constraints but it looks you are trying to import that csv to the user's table, and the user's table doesnt have a field called created_by. if thats what you want remove the columns its asking like created_by from the file If its not the user's table you are trying to

[web2py] Re: Problem with routes

2016-05-14 Thread Alfonso Serra
Another problem. Since i want to get rid of the app name and index actions in the url i have added these to routes_in routes_in ... , ('/myapp/default/user/$anything', '/user/$anything') routes_out ... , ('/myapp/default/user/$anything', '/user/$anything') It works but redirecting to the login

[web2py] Re: IDX (internet data exchange) plugin in web2py

2016-05-14 Thread Alfonso Serra
What is IDX? a php wordpress plugin? -- 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

[web2py] Re: Thread with own db connection

2016-05-14 Thread Alfonso Serra
Thanks for your answer massimo. The problem is that the thread im creating "use to" last longer than the request dispatch, and it needs its own connection opened until is done (importing bulk data into the database). Thats why i cannot .join the thread, i let the request finish, and the

[web2py] Re: Problem with routes

2016-05-14 Thread Alfonso Serra
No problem i got it. I dont need to type the app name or the index action at the url and numeric params works. routes.py default_application = "myapp" default_controller = "default" #no need to declare the default action routes_in = ( #... include the same routes as the example file ,

[web2py] Re: What is the difference between these two in relation with working of script?

2016-05-14 Thread Alfonso Serra
This is not web2py related but geolocation is disabled on all browsers by default. You have to enable 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) ---

[web2py] Re: I tried learning scheduler but got messed up. Can someone help me with this?

2016-05-14 Thread Alfonso Serra
On Saturday, 14 May 2016 08:38:57 UTC-1, Steve Joe wrote: > > how to write a scheduler function that will send me an email with subject > "hello" every night at 12 am? > Yep, 1-Launch the scheduler on a command prompt run cmd.exe or any terminal on your computer and type python web2py.py -K

[web2py] Problem with routes

2016-05-14 Thread Alfonso Serra
Hi. Im trying to map some routes using patterns but i cant get it right. I want to get rid of the app name and index actions so: http://mydom.com/anycontr/123 maps to http://mydom.com/myapp/anycontr/index/123 and be able to use numeric parameters on the default controller as

[web2py] Re: Thread with own db connection

2016-05-12 Thread Alfonso Serra
I kinda have it but its very bad. i have to declare the connection as: class customthread(Thread): def __init__ self.db = DAL(cnnstring, migrate=False) self.db['dontclose'] = True At gluon/packages/pydal/connection.py wich handles the ConnectionPool modify the line 56

Re: [web2py] Highcharts in web2py

2016-05-12 Thread Alfonso Serra
Actually is quite easy. Prepare some data on your controller: import json def index(): ... #get some rows from any source countries = XML(json.dumps([[r.country_name, r.population] for r in rows ])) At your view: //declare the libraries here, jquery hc, etc

[web2py] Re: Scheduler - limit on how large the result can be?

2016-05-12 Thread Alfonso Serra
A Task's run_output and run_result fields types are mapped to LONGTEXT if you are using mysql, this is 4gb storage capacity. Python strings should be around 3Gb depending on your system's ram amount. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Thread with own db connection

2016-05-11 Thread Alfonso Serra
Thanks for your interest Dave. Yes the files are big, the last one was 8mb with about 44k records About the scheduler. i start it manually at the control panel launching the script below ("python scheduler.py" from a pythonanywhere console). After a few days it becomes unresponsive and i have

  1   2   >