[web2py] Re: Bug in Dal: import for csv

2016-12-22 Thread mfarees . knysys
I am currently using *Version 2.14.6-stable* and this issue still exists. *Steps to reproduce the issue* If "|1|2|" is passed in a list:reference field , a dictionary key error shows up in *web2py/gluon/packages/dal/pydal/objects.py* *Cause* A line in import_from_csv_file method is causing this

[web2py] Web2py multiple table joins

2016-12-08 Thread mfarees . knysys
Hi I want to write a query in web2py. The purpose of this query is to return all users that belong to a user group specified in the query. The additional data I want with each user is his organization (if any), managing_countries (if any), and shops (if any). Note that a user might *either*

[web2py] Re: What a good web2py application architecture looks like?

2016-11-21 Thread mfarees . knysys
I'll definitely keep these tips in mind. Thank you ppl. -- 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] Re: What a good web2py application architecture looks like?

2016-11-18 Thread mfarees . knysys
I understand your point now. But if controllers are accessing the DAL then what goes in the models and modules? The modules will have the BO (later), what else? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: What a good web2py application architecture looks like?

2016-11-18 Thread mfarees . knysys
This is partial code. After fetching the data I convert the rows to a list of objects and return it to the controller. What is a better way to access DAL then? I am going through the link you shared earlier. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: What a good web2py application architecture looks like?

2016-11-18 Thread mfarees . knysys
You are right, that code was wrong. It was just to give an idea of fetching a user based on id or first name, if either is provided. Here is a better version to explain how I write queries without using SP. def get_user(id=None, first_name=None): data = None if id and not first_name: data =

[web2py] Re: What a good web2py application architecture looks like?

2016-11-17 Thread mfarees . knysys
*@*Val K Thanks but I'm not using stored procedures. I have DAL queries in which the where clause is manipulated via method parameters. So the code would look something like this, def get_user(id=None, first_name=None): return db((db.auth_user.id == id) & (db.auth_user.first_name ==

[web2py] Re: What a good web2py application architecture looks like?

2016-11-17 Thread mfarees . knysys
@Leonel Câmara Thanks for your input on this. Perhaps I didn't explain the structure very well. I do have controllers and they have the same as some of the BOs. But not every BO has its own controller. There are some BOs that only communicate with BOs and not with controllers. Also, the

[web2py] Re: What a good web2py application architecture looks like?

2016-11-17 Thread mfarees . knysys
Thanks for your input on this. Perhaps I didn't explain the structure very well. I do have controllers and they have the same as some of the BOs. But not every BO has its own controller. There are some BOs that only communicate with BOs and not with controllers. Also, the controllers have the

[web2py] Re: What a good web2py application architecture looks like?

2016-11-17 Thread mfarees . knysys
Thanks for your input on this. Perhaps I didn't explain the structure very well. I do have controllers and they have the same as some of the BOs. But not every BO has its own controller. There are some BOs that only communicate with BOs and not with controllers. Also, the controllers have the

[web2py] Re: Processing taking a long time in web2py?

2016-11-17 Thread mfarees . knysys
It would be easier to understand and solve your problem if you share the code. -- 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

[web2py] What a good web2py application architecture looks like?

2016-11-17 Thread mfarees . knysys
Hi, I need some help from experienced web2py developers and creators. I am creating a new application and would like to know what a good architecture for a web2py application looks like. Here is the architecture diagram of the past web2py projects I have worked on.

[web2py] Re: How to compare between two datetime in web2py?

2016-04-19 Thread mfarees . knysys
from datetime import datetime datetime1 = "2016-04-19 01:25:09.9090" datetime1 = datetime.strptime(datetime1, "%Y-%m-%d %H:%M:%S.%f") # Converts string to datetime object datetime2 = "2016-04-19 01:25:09.8765" datetime2 = datetime.strptime(datetime2, "%Y-%m-%d %H:%M:%S.%f") # Converts

[web2py] Re: How to ensure each row in the db table having distinct value of a partcular field?

2016-04-19 Thread mfarees . knysys
Field('username', unique=True) -- 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] Re: How to use functions defined in models, in modules?

2016-04-18 Thread mfarees . knysys
I tried that but it did not work. I added the function to modules/common.py. Then I used import common and called the function using common.int_or_None(x). After doing this I ran my pytests but they failed on the import statement. This is the error I got: 'thread._local' object has no attribute

[web2py] Re: How to use functions defined in models, in modules?

2016-04-18 Thread mfarees . knysys
I want to use this function in multiple module files. Copying it over to each one of those files does not seem like a good idea. Is there some other approach to tackle this cleanly? On Monday, April 18, 2016 at 3:13:37 PM UTC+5, Leonel Câmara wrote: > > This could be done, but it's a bad idea,

[web2py] How to use functions defined in models, in modules?

2016-04-18 Thread mfarees . knysys
There is a function in models/utils.py called int_or_None. I'd like to be able to use this functions in modules. Is there a way to do this? If not, where would be the best place to keep this int_or_None function in order to make it accessible to the entire application? Thanks. -- Resources: -

[web2py] Re: Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
Here is some more info on this. The datetime module does not return the correct time if the timezone is changed, unless the Python instance is restarted. http://bugs.python.org/issue17627 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
Yes, that's exactly what happened. I did not restart web2py after changing the timezone and I don't want to do that too. I want the correct time dynamically, without having to restart the server. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
No, it doesn't. 6:00 PM + 7 hrs = 1:00 AM (of next day). -- 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] Re: Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
Pacific Time (US & Canada (UTC -08:00) is the selected timezone. When it's 6:00 PM in LA, its 1:00 AM (of the next day) UTC. There's a 7 hour difference between LA and UTC (since DayLight Saving is active right now). Hence, the results quoted are correct. -- Resources: - http://web2py.com -

[web2py] Re: Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
I start the web2py server using this command python web2py.py The I go to localhost:8000/app_name I haven't set any timezone value in the environment variable, so I guess it should be default. However, I have set the system time and timezone from the bottom right clock. -- Resources: -

[web2py] Why datetime.now() is not returning correct value

2016-03-25 Thread mfarees . knysys
Hi. I am in Asia/Karachi timezone and am testing my application for US/Pacific timezone. Here is the scenario: The *system time* that I've set is, 2016-03-24 18:02:58 and the timezone is US/Pacific When I use the *Python interpreter* to print the datetime, I get >>> print

[web2py] Re: Get list of user groups

2016-03-24 Thread mfarees . knysys
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.

Re: [web2py] How to preserve order for query results

2016-03-19 Thread mfarees . knysys
Thanks, it worked! Had to change idx to ids though. -- 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

[web2py] How to preserve order for query results

2016-03-16 Thread mfarees . knysys
I have a list, ids = [2, 3, 1, 4] When I use this list in a query, like this: db(db.test.id.belongs(ids)).select() I get results sorted by id, like (1, 2, 3, 4), but what I want is the exact order that I sent i-e (2, 3, 1, 4) Is there any way to achieve this easily in web2py? --

[web2py] Re: Get list of user groups

2016-01-19 Thread mfarees . knysys
Please elaborate on how I can do this manually. Thanks. On Thursday, January 7, 2016 at 7:26:15 PM UTC+5, Anthony wrote: > > auth.user_groups is stored in the user's session. If you (as an admin) > make a change in the database, that will not affect the session of another > user (which is

[web2py] Re: How to add an hour to datetime field

2015-11-23 Thread mfarees . knysys
I've already tried this, but it didn't work. I get this error. type object 'datetime.datetime' has no attribute 'timedelta' On Friday, November 20, 2015 at 1:00:07 PM UTC+5, Annet wrote: > > It should be: > > datetime.timedelta(hours=1) > > So: > > db(db.myTable.id == 1).update(start =

[web2py] How to use update query with joins?

2015-11-19 Thread mfarees . knysys
I need some help with a DAL query. I'm trying to update records, but my query contains joins. *tournament Table* | id | start | end | *match Table* | id | tournamentID | home_team | away_team | start | end | db( ((db.tournament.start >= '2015-01-01 00:00:00') & (db.tournament.end <=

[web2py] How to add an hour to datetime field

2015-11-19 Thread mfarees . knysys
I have a table that I have created (in models) using db.define_table('myTable', Field('start', type='datetime', requires=NE) ) I have some records in this table, in this format: '2015-12-31 00:00:00' (this is on id = 1) I want to run a query that will add one

[web2py] How to cope with schema changes on Prod

2015-11-16 Thread mfarees . knysys
I have a web2py application that uses PostgreSQL and is running on 3 servers. We'll call them QA, Stage and Prod. Whenever I make some schema changes in my application, my deployment pipeline stops working. The deployment pipeline works this way; updated code is pushed to the QA server, this