[web2py] Re: what triggers a db migration
Migrations are pretty powerful but problems can arise. As I've suggested elsewhere, best to develop against SQLite and then deploy as desired. In development, I change models frequently. If I run into a problem that I can't fix with migrations, I might delete the whole database folder and start over. That's simple with SQLite. The sql.log is just a log. I think web2py compares the .table files to the database to figure out what needs to be migrated. I think fake_migrate rebuilds the .table files according to the model files without touching the DB. There's probably room for improvement in the documentation, especially around fixing broken migrations, what the files are in the database folder and what migrate/fake_migrate actually do.
[web2py] Re: migration not working
...which I did... Ummm... that sort of suggests I might as well ALWAYS set migrate=False in my DAL connector for MySQL? I don't mind--it's not too hard to make the changes and it helps focus on db design. Sounds like Postgres is a better longterm choice. On Jan 14, 10:39 pm, Massimo Di Pierro wrote: > Mysql does not support multiple alter table in one transaction that is > why it is possible for mysql to get into this state. notice this > cannot happen with postgresql which perform the entire migration in > one transaction. > > You need to manually ALTER TABLE and DELETE joke_id__tmp > > On Jan 14, 10:02 pm, Likit wrote: > > > > > > > > > I am trying to use the many-2-many DAL syntax suggested by the manual > > and the examples. In this approach, a field name is associated with a > > TABLE name. > > > I have not been able to get this to work with MySQL. So, I have used > > the more conventional approach of using an integer field to hold the > > key value from the relationship table. Instead of dogs and persons I > > have jokes and categories, but it's the same thing. The goal is to be > > able to express relations for jokes with no category, jokes with one > > or more categories, categories with one or more jokes, and categories > > with no jokes. The ideal query returns all of these, if they exist. > > > Here is the model for my "conventional" approach: > > > jodb.define_table('joke', > > Field('joketext', 'text',length=2048), > > Field('created_on', 'datetime', default=request.now), > > Field('created_by', jodb.auth_user, default=auth.user_id)) > > > jodb.define_table('category', > > Field('name', 'text')) > > > jodb.define_table('joke_category', > > Field('joke_id', 'integer'), > > Field('category_id', 'integer')) > > > jodb.category.name.requires = IS_NOT_EMPTY() > > jodb.joke.joketext.requires = IS_NOT_EMPTY() > > > All was good except I couldn't get the query to work using the persons/ > > dogs many-to-many approach. I was not getting jokes with no > > categories and categories with no jokes. So, I decided to follow the > > manual more closely to see if I could try the queries from the > > example. > > > Thus, I tried to change the field definitions in the relations table > > to associate the id field with a TABLE as in: > > > jodb.define_table('joke_category', > > Field('joke_id', jodb.joke), > > Field('category_id', 'integer')) > > > Yes, I would need to do the same for category, but I wanted to do one > > at a time because I had read somewhere that MySQL migrations did not > > work with multiple pending changes (don't know if that is really > > true...). Anyway, seemed easier to do one at a time. So, I made the > > immediately preceding change in the model. In attempting to do the > > migration, MySQL got an error 150. When this happens, either web2py or > > MySQL will hang. So, I stopped everything. > > > Upon resuming everything, I tried to go back to the original way I had > > it (above). This appears to cause a second migration with the > > following result: > > > 127.0.0.1.2012-01-14.19-48-00.189cb495-7851-429d-a0cb-bd23156431f1 > > > (1060, u"Duplicate > > column name 'joke_id__tmp'") > > VERSION > > > web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), > > 'stable') > > Python > > TRACEBACK > > > Traceback (most recent call last): > > File "c:\web2py\gluon\restricted.py", line 204, in restricted > > exec ccode in environment > > File "c:/web2py/applications/pyjokes/models/db.py", line 55, in > > > > Field('category_id', 'integer')) > > File "c:\web2py\gluon\dal.py", line 5097, in define_table > > polymodel=polymodel) > > File "c:\web2py\gluon\dal.py", line 728, in create_table > > fake_migrate=fake_migrate) > > File "c:\web2py\gluon\dal.py", line 816, in migrate_table > > self.execute(sub_query) > > File "c:\web2py\gluon\dal.py", line 1359, in execute > > return self.log_execute(*a, **b) > > File "c:\web2py\gluon\dal.py", line 1353, in log_execute > > ret = self.cursor.execute(*a, **b) > > File "c:\web2py\gluon\contrib\pymysql\cursors.py", line 108, in > > execute > > self.errorhandler(self, exc, value) > > File "c:\web2py\gluon\contrib\pymysql\connections.py", line 184, in > > defaulterrorhandler > > raise errorclass, errorvalue > > InternalError: (1060, u"Duplicate column name 'joke_id__tmp'") > > > Note the duplicate column name. It seems that the first migration > > created a tmp field to move the column values over to the newly > > created column. This hung, but the tmp column must have been > > created. The second migration--to get back (which I erroneously > > thought wouldn't happen at all, assuming the first migration had > > failed completely--clearly needed to create the second tmp column, > > which was a dupe. > > > I can get myself back to the "conventional" approach working. > > > So, my real question is: how can I formulate the query that returns >
[web2py] Re: examples app doesn't run on apache
The caching could be an issue. Are you able to comment out the cache decorators on examples/index to see? I frequently hear people running into trouble running Apache and/or Python on Windows. I'd strongly suggest developing against the Windows download and then deploying on *nix.
Re: [web2py] Re: PCBSD 9 release (freebsd 9) cannot start web2py
Judging from your error message and our exchange in the comments, I think the big problem is you might just be missing sqlite3 support for python. >From your error messages I take it you're running FreeBSD, so you should install the databases/py-sqlite3 package from ports. I don't know much about FreeBSD's ports system, but after you install the py-sqlite3 package, your problem should hopefully be cleared up. I'm going to assume, from brief reading, you do something like this, assuming you have the ports tree on your system: > cd /usr/ports/databases/py-sqlite3 > make && make install > -- http://stackoverflow.com/questions/7973660/python-sqlite3-error-in-freebsd-9 On Sun, Jan 15, 2012 at 4:40 AM, Bruce Wade wrote: > ** Now I am running python 2.7 ** > > > On Sat, Jan 14, 2012 at 10:40 PM, Bruce Wade wrote: > >> Hi, >> >> Fresh install of pcbsd 9, just downloaded web2py source version, when >> running python web2py: >> >> please visit: >> http://127.0.0.1:8000 >> use "kill -SIGTERM 21799" to shutdown the web2py server >> DEBUG: connect attempt 0, connection error: >> Traceback (most recent call last): >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 4736, in __init__ >> self._adapter = ADAPTERS[self._dbname](*args) >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 1634, in __init__ >> raise RuntimeError, "Unable to import driver" >> RuntimeError: Unable to import driver >> DEBUG: connect attempt 1, connection error: >> Traceback (most recent call last): >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 4736, in __init__ >> self._adapter = ADAPTERS[self._dbname](*args) >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 1634, in __init__ >> raise RuntimeError, "Unable to import driver" >> RuntimeError: Unable to import driver >> DEBUG: connect attempt 2, connection error: >> Traceback (most recent call last): >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 4736, in __init__ >> self._adapter = ADAPTERS[self._dbname](*args) >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 1634, in __init__ >> raise RuntimeError, "Unable to import driver" >> RuntimeError: Unable to import driver >> DEBUG: connect attempt 3, connection error: >> Traceback (most recent call last): >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 4736, in __init__ >> self._adapter = ADAPTERS[self._dbname](*args) >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 1634, in __init__ >> raise RuntimeError, "Unable to import driver" >> RuntimeError: Unable to import driver >> >> >> DEBUG: connect attempt 4, connection error: >> >> >> Traceback (most recent call last): >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 4736, in __init__ >> self._adapter = ADAPTERS[self._dbname](*args) >> File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line >> 1634, in __init__ >> raise RuntimeError, "Unable to import driver" >> RuntimeError: Unable to import driver >> >> Not I am running python 2.7 and the default database is sqlite. >> -- >> -- >> Regards, >> Bruce Wade >> http://ca.linkedin.com/in/brucelwade >> http://www.wadecybertech.com >> http://www.warplydesigned.com >> http://www.fitnessfriendsfinder.com >> > > > > -- > -- > Regards, > Bruce Wade > http://ca.linkedin.com/in/brucelwade > http://www.wadecybertech.com > http://www.warplydesigned.com > http://www.fitnessfriendsfinder.com > -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: PCBSD 9 release (freebsd 9) cannot start web2py
** Now I am running python 2.7 ** On Sat, Jan 14, 2012 at 10:40 PM, Bruce Wade wrote: > Hi, > > Fresh install of pcbsd 9, just downloaded web2py source version, when > running python web2py: > > please visit: > http://127.0.0.1:8000 > use "kill -SIGTERM 21799" to shutdown the web2py server > DEBUG: connect attempt 0, connection error: > Traceback (most recent call last): > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 4736, in __init__ > self._adapter = ADAPTERS[self._dbname](*args) > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 1634, in __init__ > raise RuntimeError, "Unable to import driver" > RuntimeError: Unable to import driver > DEBUG: connect attempt 1, connection error: > Traceback (most recent call last): > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 4736, in __init__ > self._adapter = ADAPTERS[self._dbname](*args) > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 1634, in __init__ > raise RuntimeError, "Unable to import driver" > RuntimeError: Unable to import driver > DEBUG: connect attempt 2, connection error: > Traceback (most recent call last): > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 4736, in __init__ > self._adapter = ADAPTERS[self._dbname](*args) > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 1634, in __init__ > raise RuntimeError, "Unable to import driver" > RuntimeError: Unable to import driver > DEBUG: connect attempt 3, connection error: > Traceback (most recent call last): > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 4736, in __init__ > self._adapter = ADAPTERS[self._dbname](*args) > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 1634, in __init__ > raise RuntimeError, "Unable to import driver" > RuntimeError: Unable to import driver > > > DEBUG: connect attempt 4, connection error: > > > Traceback (most recent call last): > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 4736, in __init__ > self._adapter = ADAPTERS[self._dbname](*args) > File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line > 1634, in __init__ > raise RuntimeError, "Unable to import driver" > RuntimeError: Unable to import driver > > Not I am running python 2.7 and the default database is sqlite. > -- > -- > Regards, > Bruce Wade > http://ca.linkedin.com/in/brucelwade > http://www.wadecybertech.com > http://www.warplydesigned.com > http://www.fitnessfriendsfinder.com > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] PCBSD 9 release (freebsd 9) cannot start web2py
Hi, Fresh install of pcbsd 9, just downloaded web2py source version, when running python web2py: please visit: http://127.0.0.1:8000 use "kill -SIGTERM 21799" to shutdown the web2py server DEBUG: connect attempt 0, connection error: Traceback (most recent call last): File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 1634, in __init__ raise RuntimeError, "Unable to import driver" RuntimeError: Unable to import driver DEBUG: connect attempt 1, connection error: Traceback (most recent call last): File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 1634, in __init__ raise RuntimeError, "Unable to import driver" RuntimeError: Unable to import driver DEBUG: connect attempt 2, connection error: Traceback (most recent call last): File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 1634, in __init__ raise RuntimeError, "Unable to import driver" RuntimeError: Unable to import driver DEBUG: connect attempt 3, connection error: Traceback (most recent call last): File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 1634, in __init__ raise RuntimeError, "Unable to import driver" RuntimeError: Unable to import driver DEBUG: connect attempt 4, connection error: Traceback (most recent call last): File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 4736, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File "/usr/home/detectedstealth/Downloads/web2py/gluon/dal.py", line 1634, in __init__ raise RuntimeError, "Unable to import driver" RuntimeError: Unable to import driver Not I am running python 2.7 and the default database is sqlite. -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: migration not working
Mysql does not support multiple alter table in one transaction that is why it is possible for mysql to get into this state. notice this cannot happen with postgresql which perform the entire migration in one transaction. You need to manually ALTER TABLE and DELETE joke_id__tmp On Jan 14, 10:02 pm, Likit wrote: > I am trying to use the many-2-many DAL syntax suggested by the manual > and the examples. In this approach, a field name is associated with a > TABLE name. > > I have not been able to get this to work with MySQL. So, I have used > the more conventional approach of using an integer field to hold the > key value from the relationship table. Instead of dogs and persons I > have jokes and categories, but it's the same thing. The goal is to be > able to express relations for jokes with no category, jokes with one > or more categories, categories with one or more jokes, and categories > with no jokes. The ideal query returns all of these, if they exist. > > Here is the model for my "conventional" approach: > > jodb.define_table('joke', > Field('joketext', 'text',length=2048), > Field('created_on', 'datetime', default=request.now), > Field('created_by', jodb.auth_user, default=auth.user_id)) > > jodb.define_table('category', > Field('name', 'text')) > > jodb.define_table('joke_category', > Field('joke_id', 'integer'), > Field('category_id', 'integer')) > > jodb.category.name.requires = IS_NOT_EMPTY() > jodb.joke.joketext.requires = IS_NOT_EMPTY() > > All was good except I couldn't get the query to work using the persons/ > dogs many-to-many approach. I was not getting jokes with no > categories and categories with no jokes. So, I decided to follow the > manual more closely to see if I could try the queries from the > example. > > Thus, I tried to change the field definitions in the relations table > to associate the id field with a TABLE as in: > > jodb.define_table('joke_category', > Field('joke_id', jodb.joke), > Field('category_id', 'integer')) > > Yes, I would need to do the same for category, but I wanted to do one > at a time because I had read somewhere that MySQL migrations did not > work with multiple pending changes (don't know if that is really > true...). Anyway, seemed easier to do one at a time. So, I made the > immediately preceding change in the model. In attempting to do the > migration, MySQL got an error 150. When this happens, either web2py or > MySQL will hang. So, I stopped everything. > > Upon resuming everything, I tried to go back to the original way I had > it (above). This appears to cause a second migration with the > following result: > > 127.0.0.1.2012-01-14.19-48-00.189cb495-7851-429d-a0cb-bd23156431f1 > > (1060, u"Duplicate > column name 'joke_id__tmp'") > VERSION > > web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), > 'stable') > Python > TRACEBACK > > Traceback (most recent call last): > File "c:\web2py\gluon\restricted.py", line 204, in restricted > exec ccode in environment > File "c:/web2py/applications/pyjokes/models/db.py", line 55, in > > Field('category_id', 'integer')) > File "c:\web2py\gluon\dal.py", line 5097, in define_table > polymodel=polymodel) > File "c:\web2py\gluon\dal.py", line 728, in create_table > fake_migrate=fake_migrate) > File "c:\web2py\gluon\dal.py", line 816, in migrate_table > self.execute(sub_query) > File "c:\web2py\gluon\dal.py", line 1359, in execute > return self.log_execute(*a, **b) > File "c:\web2py\gluon\dal.py", line 1353, in log_execute > ret = self.cursor.execute(*a, **b) > File "c:\web2py\gluon\contrib\pymysql\cursors.py", line 108, in > execute > self.errorhandler(self, exc, value) > File "c:\web2py\gluon\contrib\pymysql\connections.py", line 184, in > defaulterrorhandler > raise errorclass, errorvalue > InternalError: (1060, u"Duplicate column name 'joke_id__tmp'") > > Note the duplicate column name. It seems that the first migration > created a tmp field to move the column values over to the newly > created column. This hung, but the tmp column must have been > created. The second migration--to get back (which I erroneously > thought wouldn't happen at all, assuming the first migration had > failed completely--clearly needed to create the second tmp column, > which was a dupe. > > I can get myself back to the "conventional" approach working. > > So, my real question is: how can I formulate the query that returns > all jokes and categories with their relations including no > corresponding joke or category? Should I do this using the > "conventional' way or should I use the suggested web2py model > syntax. > > I know--a long question for what is probably a shorter answer. > > Many thanks.
[web2py] Re: DAL IMAPAdapter
This will probably be accepted. Will check it asap. On Jan 14, 6:40 pm, Alan Etkin wrote: > I sent an IMAP interface proposal to the issues list. As of now, there > is a dal module modification available that allows connecting to an > IMAP (i.e. Gmail) server, auto create tables and query for mailbox > messages with the web2py query syntax. > > It is possible to construct queries using ==, !=, >, <=, belongs, > contains, ... > > This web2py command returns rows that contain a string within the > subject text > > rows = imapdb(imapdb.INBOX.subject.contains("mytext")).select() > > I will appreciate your comments.
[web2py] Re: examples app doesn't run on apache
Did you try this: http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-ubuntu.sh On Jan 14, 4:43 pm, Likit wrote: > Still no solution to this. I would really like not having to switch > between Rocket and Apache each time I want to look at the help or > examples. > > Error 503 is Apache saying that the server can't respond to the > client. > > In the Apache error log, I have the following when I attempt to access > help or run the examples app: > > [Sat Jan 14 14:02:26 2012] [error] [client 127.0.0.1] client denied by > server configuration: C:/web2py/wsgihandler.py, > referer:http://127.0.0.1/welcome > > So, Apache/mod_wsgi is properly dispatching to python and > wsgihandler.py is obviously the first stop. But, then web2py fails to > respond back to Apache. Note that all the other apps including the > two I've started all work properly. > > My theory on memory seems to be wrong: with the whole stack > running(xampp, apache, python, web2py), Windows reports 2G. That's > certainly enough for some small caches and any transient memory use. > > So, I wonder if there is something wrong with routes, even though I > didn't touch it. > > What is different about the help and examples app? I can't figure it > out other than some links go back towww.web2py.comand many of the > functions are cached via function decorator in the controller. > > Any help would be appreciated as I am stuck and this seems to be an > uncommon problem.
[web2py] Re: what triggers a db migration
The manual is pretty explicit about this although it simplifies a bit. The manual says it looks at the existing tables (actually looks at the physical file or looks at the most recent definition in sql.log?). I think that the time stamps also matter. Not clear what timestamp is being compared to what... I followed the manual and did the "fake_migrate=True" thing. As the db tables already really did match, that as a sure thing and the app works again without migrate = False. I am curious why the initial migration did not work. It would seem that the sequence that needed to happen is: i. create new tmp column ii. assign values of column being changed to tmp column iii. create new column iv. assign values of tmp column to new column--if appropriate v. drop tmp column I think my migration failed on step iii, create new column, because I did not specify the Field arguments properly. Let me know if you have any suggestions. I am still curious about this. Here is my sql.log file BEFORE doing the fake_migrate. Immediately following that is the sql.log after the successful fake_migrate. The Alter table sql statements are still present. that sort of concerns me. Can I simply purge the log and let web2py update it with the application's next execution? Perhaps it is the _name.table files that really determine what happens in migrations. timestamp: 2012-01-11T21:33:41.50 CREATE TABLE auth_user( id INT AUTO_INCREMENT NOT NULL, first_name VARCHAR(128), last_name VARCHAR(128), email VARCHAR(255), password VARCHAR(255), registration_key VARCHAR(255), reset_password_key VARCHAR(255), registration_id VARCHAR(255), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; timestamp: 2012-01-11T21:46:05.797000 CREATE TABLE auth_user( id INT AUTO_INCREMENT NOT NULL, first_name VARCHAR(128), last_name VARCHAR(128), email VARCHAR(255), password VARCHAR(255), registration_key VARCHAR(255), reset_password_key VARCHAR(255), registration_id VARCHAR(255), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; timestamp: 2012-01-11T22:04:00.147000 CREATE TABLE auth_user( id INT AUTO_INCREMENT NOT NULL, first_name VARCHAR(128), last_name VARCHAR(128), email VARCHAR(255), password VARCHAR(255), registration_key VARCHAR(255), reset_password_key VARCHAR(255), registration_id VARCHAR(255), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.162000 CREATE TABLE auth_group( id INT AUTO_INCREMENT NOT NULL, role VARCHAR(255), description LONGTEXT, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.172000 CREATE TABLE auth_membership( id INT AUTO_INCREMENT NOT NULL, user_id INT, INDEX user_id__idx (user_id), FOREIGN KEY (user_id) REFERENCES auth_user(id) ON DELETE CASCADE, group_id INT, INDEX group_id__idx (group_id), FOREIGN KEY (group_id) REFERENCES auth_group(id) ON DELETE CASCADE, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.186000 CREATE TABLE auth_permission( id INT AUTO_INCREMENT NOT NULL, group_id INT, INDEX group_id__idx (group_id), FOREIGN KEY (group_id) REFERENCES auth_group(id) ON DELETE CASCADE, name VARCHAR(255), table_name VARCHAR(255), record_id INT, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.198000 CREATE TABLE auth_event( id INT AUTO_INCREMENT NOT NULL, time_stamp DATETIME, client_ip VARCHAR(255), user_id INT, INDEX user_id__idx (user_id), FOREIGN KEY (user_id) REFERENCES auth_user(id) ON DELETE CASCADE, origin VARCHAR(255), description LONGTEXT, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.21 CREATE TABLE auth_cas( id INT AUTO_INCREMENT NOT NULL, user_id INT, INDEX user_id__idx (user_id), FOREIGN KEY (user_id) REFERENCES auth_user(id) ON DELETE CASCADE, created_on DATETIME, service VARCHAR(255), ticket VARCHAR(255), renew CHAR(1), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.222000 CREATE TABLE joke( id INT AUTO_INCREMENT NOT NULL, joketext LONGTEXT, created_on DATETIME, created_by INT, INDEX created_by__idx (created_by), FOREIGN KEY (created_by) REFERENCES auth_user(id) ON DELETE CASCADE, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.233000 CREATE TABLE category( id INT AUTO_INCREMENT NOT NULL, name LONGTEXT, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-11T22:04:00.243000 CREATE TABLE joke_category( id INT AUTO_INCREMENT NOT NULL, joke_id INT, category_id INT, PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2012-01-14T19:48:00.511000 ALTER TABLE joke_category ADD joke_id__tmp
[web2py] what triggers a db migration
I had a db for which I changed the model. This correctly caused a migration. Either web2py or MySQL hung. This has sort of diminished my confidence in migrations. I realize it is a great thing, but only if/when it works. Believe me I am experimenting with a really trivial example with 3 tables (plus auth) and about 3-4 fields each with about as many rows of test data. So, if it hangs for this... Anyway, I manually purged the tmp column and make sure the data was ok. Set the table in question to migrate = False. All worked ok. Terrific. With things working I decided I would put the model back the way it was originally and removed migrate = False from the offending table. Then, when I ran the app--web2py attempted a migration. There must be something like the data-time stamp of the model compared to some inner value that triggers the migration. Is there someway I can get the inner state in sync so the migration doesn't happen? I sent another post about what went wrong with the migration itself. Now I am just trying to get everything cleaned up manually. Many thanks.
[web2py] migration not working
I am trying to use the many-2-many DAL syntax suggested by the manual and the examples. In this approach, a field name is associated with a TABLE name. I have not been able to get this to work with MySQL. So, I have used the more conventional approach of using an integer field to hold the key value from the relationship table. Instead of dogs and persons I have jokes and categories, but it's the same thing. The goal is to be able to express relations for jokes with no category, jokes with one or more categories, categories with one or more jokes, and categories with no jokes. The ideal query returns all of these, if they exist. Here is the model for my "conventional" approach: jodb.define_table('joke', Field('joketext', 'text',length=2048), Field('created_on', 'datetime', default=request.now), Field('created_by', jodb.auth_user, default=auth.user_id)) jodb.define_table('category', Field('name', 'text')) jodb.define_table('joke_category', Field('joke_id', 'integer'), Field('category_id', 'integer')) jodb.category.name.requires = IS_NOT_EMPTY() jodb.joke.joketext.requires = IS_NOT_EMPTY() All was good except I couldn't get the query to work using the persons/ dogs many-to-many approach. I was not getting jokes with no categories and categories with no jokes. So, I decided to follow the manual more closely to see if I could try the queries from the example. Thus, I tried to change the field definitions in the relations table to associate the id field with a TABLE as in: jodb.define_table('joke_category', Field('joke_id', jodb.joke), Field('category_id', 'integer')) Yes, I would need to do the same for category, but I wanted to do one at a time because I had read somewhere that MySQL migrations did not work with multiple pending changes (don't know if that is really true...). Anyway, seemed easier to do one at a time. So, I made the immediately preceding change in the model. In attempting to do the migration, MySQL got an error 150. When this happens, either web2py or MySQL will hang. So, I stopped everything. Upon resuming everything, I tried to go back to the original way I had it (above). This appears to cause a second migration with the following result: 127.0.0.1.2012-01-14.19-48-00.189cb495-7851-429d-a0cb-bd23156431f1 (1060, u"Duplicate column name 'joke_id__tmp'") VERSION web2py™ (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable') Python TRACEBACK Traceback (most recent call last): File "c:\web2py\gluon\restricted.py", line 204, in restricted exec ccode in environment File "c:/web2py/applications/pyjokes/models/db.py", line 55, in Field('category_id', 'integer')) File "c:\web2py\gluon\dal.py", line 5097, in define_table polymodel=polymodel) File "c:\web2py\gluon\dal.py", line 728, in create_table fake_migrate=fake_migrate) File "c:\web2py\gluon\dal.py", line 816, in migrate_table self.execute(sub_query) File "c:\web2py\gluon\dal.py", line 1359, in execute return self.log_execute(*a, **b) File "c:\web2py\gluon\dal.py", line 1353, in log_execute ret = self.cursor.execute(*a, **b) File "c:\web2py\gluon\contrib\pymysql\cursors.py", line 108, in execute self.errorhandler(self, exc, value) File "c:\web2py\gluon\contrib\pymysql\connections.py", line 184, in defaulterrorhandler raise errorclass, errorvalue InternalError: (1060, u"Duplicate column name 'joke_id__tmp'") Note the duplicate column name. It seems that the first migration created a tmp field to move the column values over to the newly created column. This hung, but the tmp column must have been created. The second migration--to get back (which I erroneously thought wouldn't happen at all, assuming the first migration had failed completely--clearly needed to create the second tmp column, which was a dupe. I can get myself back to the "conventional" approach working. So, my real question is: how can I formulate the query that returns all jokes and categories with their relations including no corresponding joke or category? Should I do this using the "conventional' way or should I use the suggested web2py model syntax. I know--a long question for what is probably a shorter answer. Many thanks.
[web2py] Re: Links to referencing records - 'str' object has no attribute 'ignore_common_filters'
The example in the book doesn't work as is. You could us eval() as mentioned below, but that would present a security risk since anything can be submitted in request.vars.query. appadmin does this, but it does some parsing of the query first, and it is not publicly accessible, so not a security risk. To work properly, list_records should probably parse the query, confirm that the db, table, and fields referenced in the query actually exist, and then create the query object from those components. Anthony On Saturday, January 14, 2012 6:16:49 PM UTC-5, Alan Etkin wrote: > > > def list_records(): > > table = request.args(0) > > query = request.vars.query > > records = db(query).select(db[table]) > > return dict(records=records,table=table,query=query) > > the fourth line passes a string to the db instance call that expects a > query object as those created with this statement: > > q = db.mytable.myfield.id == > > Maybe you can do new_query = eval(q) to create the normal db call > input. The admin interface does something similar (i don't know if it > uses eval) as it processes queries sent by browser user input.
Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors
I forgot to mention that you can have comments in different ways, Facebook comments, DIsqus, Intense Debate or Movuca comments. All configuration is in databases/config_movuca.sqlite (I am developing an admin page for that)
Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors
I made several changes to database model, the problem is that SQLITE does not support ALTER TABLE so you need to delete your tables and let them to be created again. You can just delete config* from databases folder, but I has problems with birthdate column in auth_user, so it is a good idea to start again from the scratch. The easiest way is: *- git clone git://github.com/mdipierro/web2py.git web2py - cd web2py/applications - git clone git://github.com/rochacbruno/Movuca.git demo - cd .. - python web2py.py -a "yourdesiredpassword" - Go to brower and: - http://localhost:8000/demo/setup/install - then - http://localhost:8000/demo * I implemented Facebook login, Google Connect login, Now users e-mail is using MailHide API from Recaptcha, User avatar can be taken from facebook, twitter, gravatar. I am working on posts via e-mail, privacy options, groups, pages and notifications, after that I think I will release the beta version.
Re: [web2py] Re: [FYI] DAL IMAPAdapter
> > Actually, I did not add any sending mail feature, since it can be > accomplished with tools.Mail. Yes, what I need is a simple API to read emails from google, the workflow should be. User obtain a key from settings page in movu.ca CMS e.g *x4f567899083* Now the user can publish posts to CMS by sending an e-mail to movucacms+* x4f567899083*@gmail.com I will use DAL with your API to rows = imapdb(imapdb.INBOX.to.contains("*x4f567899083*")).select() So I can take the email, parse and process to publish as a post in CMS. I am going to try it! -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Web2py_session table
Hi, I am trying to disconnect users when they connect from another computer by deleting entries in web2py_session table. But as this table doesnt log usernames . which makes some sens because a session is established before the login process. I had to edit file globals.py line 485 to add a field username to that table, and in my db.py file i updated the table with auth.user.username value (at the auth.setting.login_onaccept)
[web2py] Re: [FYI] DAL IMAPAdapter
>I am planning having the >possibility for users to publish posts via e-mail messages. Actually, I did not add any sending mail feature, since it can be accomplished with tools.Mail.
[web2py] Re: [FYI] DAL IMAPAdapter
No, it is in the issues list, i think it has not been revised On 14 ene, 21:49, Bruno Rocha wrote: > Nice! > > It it in trunk? > > I would like to test it forhttp://movu.caI am planning having the > possibility for users to publish posts via e-mail messages. > > > > On Sat, Jan 14, 2012 at 10:40 PM, Alan Etkin wrote: > > I sent an IMAP interface proposal to the issues list. As of now, there > > is a dal module modification available that allows connecting to an > > IMAP (i.e. Gmail) server, auto create tables and query for mailbox > > messages with the web2py query syntax. > > > It is possible to construct queries using ==, !=, >, <=, belongs, > > contains, ... > > > This web2py command returns rows that contain a string within the > > subject text > > > rows = imapdb(imapdb.INBOX.subject.contains("mytext")).select() > > > I will appreciate your comments. > > -- > > Bruno Rocha > [http://rochacbruno.com.br]
Re: [web2py] [FYI] DAL IMAPAdapter
Nice! It it in trunk? I would like to test it for http://movu.ca I am planning having the possibility for users to publish posts via e-mail messages. On Sat, Jan 14, 2012 at 10:40 PM, Alan Etkin wrote: > I sent an IMAP interface proposal to the issues list. As of now, there > is a dal module modification available that allows connecting to an > IMAP (i.e. Gmail) server, auto create tables and query for mailbox > messages with the web2py query syntax. > > It is possible to construct queries using ==, !=, >, <=, belongs, > contains, ... > > This web2py command returns rows that contain a string within the > subject text > > rows = imapdb(imapdb.INBOX.subject.contains("mytext")).select() > > I will appreciate your comments. > -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] [FYI] DAL IMAPAdapter
I sent an IMAP interface proposal to the issues list. As of now, there is a dal module modification available that allows connecting to an IMAP (i.e. Gmail) server, auto create tables and query for mailbox messages with the web2py query syntax. It is possible to construct queries using ==, !=, >, <=, belongs, contains, ... This web2py command returns rows that contain a string within the subject text rows = imapdb(imapdb.INBOX.subject.contains("mytext")).select() I will appreciate your comments.
[web2py] Re: Row difference bug
I have tried to reproduce this with web2py 1.99.4 and the line numbers are consistent trough the error page. It always shows the same line number. On 13 ene, 10:26, Kenneth Lundström wrote: > Hello list, > > I got an Internal error and the problem is in a views file. > > And as we know row numbers in the source files is not the same as in the > Error page. So I started looking at the error on the Error page and I > think I found a bug in showing the code. > > File"/views/troop/campaign.html",line436,in > TypeError:unsupported operand type(s)for-:'NoneType'and'long' > > So I scrolled down to line number 436 > 436 if tracker_rows[person_id].has_key(product.id): > > and I can't understand whats wrong. > > So I scrolled back up to check the row number and then by mistake I > looked at the short version that only shows 20 rows. In that listing row > numer 436 is: > to_be_returned[product.id] = > tracker_rows[person_id][product.id].count_received - > tracker_rows[person_id][product.id].count_paid - > tracker_rows[person_id][product.id].count_returned > > makes much more sense. > > Kenneth
[web2py] Re: Responsivekit for web2py!
Would it be possible to test it with a desktop pc? I visited the demo and found difficult to appreciate the features. Is image and table resizing being performed by the plugin? On 13 ene, 10:51, Angelo Compagnucci wrote: > Hello list, > > I want to share with you my new plugin (aiming to web2py inclusion!), > responsivekit, you can find it on > githubhttps://github.com/angeloc/web2py-responsivekit. > > Responsivekit implements responsive tables and responsive images using the > best known techniques at the moment (I'm basing on Marcotte, > SmashingMagazine and filamentgroups reccomendations). More will come! > > Comments are welcome. > > Cheers, > > Angelo > > -- > Profile:http://it.linkedin.com/in/compagnucciangelo
[web2py] Re: examples app doesn't run on apache
One other bit of information: everything works as expected with Rocket server (using port 8000).
[web2py] Re: Links to referencing records - 'str' object has no attribute 'ignore_common_filters'
> def list_records(): > table = request.args(0) > query = request.vars.query > records = db(query).select(db[table]) > return dict(records=records,table=table,query=query) the fourth line passes a string to the db instance call that expects a query object as those created with this statement: q = db.mytable.myfield.id == Maybe you can do new_query = eval(q) to create the normal db call input. The admin interface does something similar (i don't know if it uses eval) as it processes queries sent by browser user input.
[web2py] Re: examples app doesn't run on apache
Still no solution to this. I would really like not having to switch between Rocket and Apache each time I want to look at the help or examples. Error 503 is Apache saying that the server can't respond to the client. In the Apache error log, I have the following when I attempt to access help or run the examples app: [Sat Jan 14 14:02:26 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/web2py/wsgihandler.py, referer: http://127.0.0.1/welcome So, Apache/mod_wsgi is properly dispatching to python and wsgihandler.py is obviously the first stop. But, then web2py fails to respond back to Apache. Note that all the other apps including the two I've started all work properly. My theory on memory seems to be wrong: with the whole stack running(xampp, apache, python, web2py), Windows reports 2G. That's certainly enough for some small caches and any transient memory use. So, I wonder if there is something wrong with routes, even though I didn't touch it. What is different about the help and examples app? I can't figure it out other than some links go back to www.web2py.com and many of the functions are cached via function decorator in the controller. Any help would be appreciated as I am stuck and this seems to be an uncommon problem.
[web2py] Re: Proposal for SQLFORM.grid
Your proposed change is in trunk, with a minor adjustement. No : in the label any more, that should be the separator. On Jan 14, 3:27 pm, Martin Weissenboeck wrote: > Hi, > > I have a SQLFORM.grid. On pressing the Edit-button there will be a message > "Check to delete:" and a button "Submit". > It is not possible to translate these texts, because these texts are > hardcoded without the T-operator. > > The following changes in the source would do the job: > > In gluon.sqlhtml.py, def grid(...): > > line 1580 old: _class='web2py_form') > > line 1580 new: _class='web2py_form', submit_button = > T('Submit'), delete_label = T('Check to delete:')) > > Regards, Martin
[web2py] Re: Proposal for SQLFORM.grid
On Jan 14, 3:27 pm, Martin Weissenboeck wrote: > Hi, > > I have a SQLFORM.grid. On pressing the Edit-button there will be a message > "Check to delete:" and a button "Submit". > It is not possible to translate these texts, because these texts are > hardcoded without the T-operator. > > The following changes in the source would do the job: > > In gluon.sqlhtml.py, def grid(...): > > line 1580 old: _class='web2py_form') > > line 1580 new: _class='web2py_form', submit_button = > T('Submit'), delete_label = T('Check to delete:')) > > Regards, Martin
[web2py] Re: AUTOCOMLETE widget doesn'n work with non latin chars
I guess the auto complete widget makes some sort of ajax request on user actions and this is not exposed to the developer. Have you looked for server side errors in the admin error list? If ajax requests fail there should be tickets generated by web2py unless they are omited in the ajax action somehow. On 14 ene, 16:24, cyber wrote: > Hi there! > > My table consists of some cyrrilic chars and when I try to select by > typing into the form nothing happened. > But if I fill the table with latin chars, it works perfetly. > > For example, in models: > > db.define_table('clients', > Field('client', type='string', label=T('îÁÉÍÅÎÏ×ÁÎÉÅ > ÏÒÇÁÎÉÚÁÃÉÉ'), unique=True, notnull=True, length=25), > ... > ) > db.clients.client.requires=IS_NOT_EMPTY(error_message='cannot be > empty') > db.clients.client.requires=IS_NOT_IN_DB(db, 'clients.client') > db.clients.client.widget = SQLFORM.widgets.autocomplete(request, > db.clients.client, limitby=(0,10), min_length=1) > > ... in controller: > form=SQLFORM.factory(db.clients, fields=['client']) > > ... in view: > {{=form}} > > How can I deal with it? > Thanks in advance for any help!
[web2py] Proposal for SQLFORM.grid
Hi, I have a SQLFORM.grid. On pressing the Edit-button there will be a message "Check to delete:" and a button "Submit". It is not possible to translate these texts, because these texts are hardcoded without the T-operator. The following changes in the source would do the job: In gluon.sqlhtml.py, def grid(...): line 1580 old: _class='web2py_form') line 1580 new: _class='web2py_form', submit_button = T('Submit'), delete_label = T('Check to delete:')) Regards, Martin
[web2py] Re: computed fields and crud
I see, so then it appears that there is nothing wrong with the ouput and in this case would be better to use the SQLFORM helper so one can pass field names to the constructor. In new versions would be good to provide extra arguments, for example crud.read(, , fields=) On 14 ene, 18:00, Anthony wrote: > On Saturday, January 14, 2012 3:00:06 PM UTC-5, Alan Etkin wrote: > > > I found with this code that the form created does not show in the > > browser: > > > # controller > > ... > > # there is only one table defined with one (plus the id) field called > > myfield > > db.mytable.myfield.compute = lambda r: str(r.myfield) + "more text" > > I believe a value will only be computed when no value is explicitly > inserted/updated, so upon record insertion, the above computation won't > happen if a 'myfield' value is passed in. > > > > > # there is a record in db.mytable with id value 1 and myfield value > > None > > form = crud.read(db.mytable, 1) > > ... > > > # view code > > {{ =form }} > > I believe computed fields are automatically excluded from SQLFORMs unless > they are explicitly listed in the 'fields' argument. Unfortunately, I don't > think there is a way to specify the 'fields' argument with crud.read(). > Maybe we should display computed fields in readonly forms by default, and > make it easier to included computed fields in create/update forms as well. > > Anthony
[web2py] Re: Application-wide exception handler?
On Saturday, January 14, 2012 2:27:42 PM UTC-5, Massimo Di Pierro wrote: > > It is not documented. It was designed exactly for what spiffy asked. I > was not sure it should stay but probably yes. > Cool. In his case, it will only catch errors that arise specifically within the called controller function, not in the models or elsewhere in the controller, right?
[web2py] Re: computed fields and crud
On Saturday, January 14, 2012 3:00:06 PM UTC-5, Alan Etkin wrote: > > I found with this code that the form created does not show in the > browser: > > # controller > ... > # there is only one table defined with one (plus the id) field called > myfield > db.mytable.myfield.compute = lambda r: str(r.myfield) + "more text" > I believe a value will only be computed when no value is explicitly inserted/updated, so upon record insertion, the above computation won't happen if a 'myfield' value is passed in. > > # there is a record in db.mytable with id value 1 and myfield value > None > form = crud.read(db.mytable, 1) > ... > > # view code > {{ =form }} > I believe computed fields are automatically excluded from SQLFORMs unless they are explicitly listed in the 'fields' argument. Unfortunately, I don't think there is a way to specify the 'fields' argument with crud.read(). Maybe we should display computed fields in readonly forms by default, and make it easier to included computed fields in create/update forms as well. Anthony
[web2py] computed fields and crud
I found with this code that the form created does not show in the browser: # controller ... # there is only one table defined with one (plus the id) field called myfield db.mytable.myfield.compute = lambda r: str(r.myfield) + "more text" # there is a record in db.mytable with id value 1 and myfield value None form = crud.read(db.mytable, 1) ... # view code {{ =form }} I have read this thread http://groups.google.com/group/web2py/browse_thread/thread/cd6191f9827a48d5/a367c0e5055bb676 and there had been a bugfix in trunk for a similar problem but I am not sure if it applies for the code I am posting. Is this the correct output?. Shouldn't be possible by default to view myfield in the page? Also tried to set myfield.readable and myfield.writable but no luck, the field doesn't show anyway. Web2py source 1.99.4 Firefox 3.6.24
[web2py] Re: Links to referencing records - 'str' object has no attribute 'ignore_common_filters'
Anthony: I'm reading web2py book about Links to referencing records and I pasted the examples, so in my application has the following components: Models db.define_table('person', Field('name','string'), Field('surname','string'), Field('image_filename'), Field('image', 'upload')) db.define_table('dog', Field('owner', db.person), Field('name', requires=IS_NOT_EMPTY())) Controllers def display_form(): record = db.person(request.args(0)) url = URL('download') link = URL('list_records') form = SQLFORM(db.person, record, deletable=True, upload=url, linkto=link) if form.process().accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form) def list_records(): table = request.args(0) query = request.vars.query records = db(query).select(db[table]) return dict(records=records,table=table,query=query) def download(): return response.download(request, db) Views display_form.html {{extend 'layout.html'}} Display Form {{=form}} list_records.html {{extend 'layout.html'}} {{=records}} Sorry for my English. Thanks you very much for answers. On 13 ene, 17:39, Anthony wrote: > On Friday, January 13, 2012 12:52:26 PM UTC-5, isi_jca wrote: > > > Thanks for your answers. I made a correction, but the error persist. I > > was reading about this error in > > >https://groups.google.com/group/web2py/browse_thread/thread/11835a3c9 > > What is the relevance of that issue? Where do you set that query?
[web2py] Re: Application-wide exception handler?
Really interesting. Why this should not be added as a stable feature? On 14 ene, 14:28, Massimo Di Pierro wrote: > you can do, in controller > > def mycaller(f): > try: > return f() > except IOError: > redirect(URL('my_IOError_page')) > > response._caller = mycaller > > response._caller wraps all action calls. Give it a try and let us know > if this works. > > On Jan 13, 8:23 pm, spiffytech wrote: > > > My web2py application is littered with calls to a library that loves > > throwing exceptions when the website it connects to isn't available. > > I'd like my web2py app to catch the exceptions thrown by the library > > and redirect the user to a friendly error page. However, there are too > > many library calls to load up the app with try/except statements all > > over the place. > > > Is there something I can put in my models file that will catch all > > exceptions of a certain type and handle them? > >
[web2py] Re: Application-wide exception handler?
It is not documented. It was designed exactly for what spiffy asked. I was not sure it should stay but probably yes. On Jan 14, 12:31 pm, Anthony wrote: > > response._caller wraps all action calls. Give it a try and let us know > > if this works. > > Is that documented anywhere? Should it be? Does the framework use > response._caller for any purpose? > > Anthony
[web2py] AUTOCOMLETE widget doesn'n work with non latin chars
Hi there! My table consists of some cyrrilic chars and when I try to select by typing into the form nothing happened. But if I fill the table with latin chars, it works perfetly. For example, in models: db.define_table('clients', Field('client', type='string', label=T('Наименование организации'), unique=True, notnull=True, length=25), ... ) db.clients.client.requires=IS_NOT_EMPTY(error_message='cannot be empty') db.clients.client.requires=IS_NOT_IN_DB(db, 'clients.client') db.clients.client.widget = SQLFORM.widgets.autocomplete(request, db.clients.client, limitby=(0,10), min_length=1) ... in controller: form=SQLFORM.factory(db.clients, fields=['client']) ... in view: {{=form}} How can I deal with it? Thanks in advance for any help!
[web2py] Re: contains return no rows of field list:string
Also, in the shell, you have to do db.commit() to commit db transactions (this is not necessary in a normal web request because the framework handles that automatically). See http://web2py.com/books/default/chapter/29/6#commit-and-rollback. Anthony On Saturday, January 14, 2012 11:52:01 AM UTC-5, DenesL wrote: > > > tags has to be a list of strings, try: > > db.entries.insert(title='hello',tags='one,two,three'.split(',')) > > or the equivalent: > > db.entries.insert(title='hello',tags=['one','two','three']) > > > On Jan 14, 10:14 am, Joseph Jude wrote: > > I went into shell in a new web2py directory and tried the below. > > Surprisingly, I get empty output. Any explanations? > > > > python web2py.py -S init -M > > > > db.define_table('entries', > > Field('title', type='string'), > > Field('tags', 'list:string')) > > > > >>> db.entries.insert(title='hello',tags='one,two,three') > > > > 1 > > > > >>> t=db(db.entries.tags.contains('one')).select() > > >>> t.as_list() > > > > []
Re: [web2py] Re: New Site for web2py poweredby
ty very much thanks for all the feedback :-) *cheers Andrew On Sat, Jan 14, 2012 at 10:34 AM, Chris Hawkes wrote: > It looks a ton better, good job! > > > On Sat, Jan 14, 2012 at 12:21 PM, Andrew Evans > wrote: > >> Hello I think I finished the styling :-) >> >> its not perfect I am sure :-P I think the green at the top of the thread >> could be replaced (if only I could find where in the style sheet it is) >> >> anyway here is the link again >> >> www.fireflywra.com >> >> and >> >> www.fireflywra.com/forum >> >> Thank you for all the insight so far :-) >> >> >> >> >> >> >> >> >> On Fri, Jan 13, 2012 at 11:41 PM, Annet wrote: >> >>> Hi Andrew, >>> >>> > Annet I did the changes you suggested but will have to work on >>> > the forum styling later today. Great ideas though *cheers >>> >>> You're welcome, let us know when you're done with the styling ... >>> >>> >>> Kind regards, >>> >>> Annet >> >> >> >
Re: [web2py] Re: controller question
I broke the controllers into much smaller sizes. My site does not seem to be too much of a memory hog at this time. I will probably try to find ways of making it more efficient in the near future, but have tons of other stuff to do in the meantime. On Fri, Jan 13, 2012 at 4:45 PM, howesc wrote: > yeah, i don't have any controllers that are 7mb > > if that 7mb happens to be some static data that you are loading into > memory you might consider loading the data into a blobstore, and having a > method that reads it in and stores it in memcache for use by your > application. > > just a thought. > > cfh >
Re: [web2py] Re: New Site for web2py poweredby
It looks a ton better, good job! On Sat, Jan 14, 2012 at 12:21 PM, Andrew Evans wrote: > Hello I think I finished the styling :-) > > its not perfect I am sure :-P I think the green at the top of the thread > could be replaced (if only I could find where in the style sheet it is) > > anyway here is the link again > > www.fireflywra.com > > and > > www.fireflywra.com/forum > > Thank you for all the insight so far :-) > > > > > > > > > On Fri, Jan 13, 2012 at 11:41 PM, Annet wrote: > >> Hi Andrew, >> >> > Annet I did the changes you suggested but will have to work on >> > the forum styling later today. Great ideas though *cheers >> >> You're welcome, let us know when you're done with the styling ... >> >> >> Kind regards, >> >> Annet > > >
[web2py] Re: Application-wide exception handler?
> > response._caller wraps all action calls. Give it a try and let us know > if this works. > Is that documented anywhere? Should it be? Does the framework use response._caller for any purpose? Anthony
[web2py] Re: Application-wide exception handler?
you can do, in controller def mycaller(f): try: return f() except IOError: redirect(URL('my_IOError_page')) response._caller = mycaller response._caller wraps all action calls. Give it a try and let us know if this works. On Jan 13, 8:23 pm, spiffytech wrote: > My web2py application is littered with calls to a library that loves > throwing exceptions when the website it connects to isn't available. > I'd like my web2py app to catch the exceptions thrown by the library > and redirect the user to a friendly error page. However, there are too > many library calls to load up the app with try/except statements all > over the place. > > Is there something I can put in my models file that will catch all > exceptions of a certain type and handle them?
Re: [web2py] Re: New Site for web2py poweredby
Hello I think I finished the styling :-) its not perfect I am sure :-P I think the green at the top of the thread could be replaced (if only I could find where in the style sheet it is) anyway here is the link again www.fireflywra.com and www.fireflywra.com/forum Thank you for all the insight so far :-) On Fri, Jan 13, 2012 at 11:41 PM, Annet wrote: > Hi Andrew, > > > Annet I did the changes you suggested but will have to work on > > the forum styling later today. Great ideas though *cheers > > You're welcome, let us know when you're done with the styling ... > > > Kind regards, > > Annet
[web2py] Re: Set table name
eventually we shoud have a way to remap table and field names that was one of the main reason for rewriting the dal. On Jan 10, 10:51 am, Marcello Parra wrote: > Hello Massimo and all, > > I'm trying to use web2py for several projects of mine. > I always find a problem that should be solved if I could set the table name. > > Let me show an example... > > Suppose that I have this: > > db.define_table('person12345', Field('name')) > db.define_table('dog12345', Field('name'), Field('owner', db.person)) > > person12345 and dog12345 are names of the tables. > As they are already running projects, I can't change them... > > If I don't want to call a dog, dog12345 all the time, I could do this: > > person=db.define_table('person12345', Field('name')) > dog=db.define_table('dog12345', Field('name'), Field('owner', db.person)) > > This should work fine. > > But I can't do this: > person[1].dog.select() > > This should just work with: > person[1].dog12345.select() > > Is there a way to do this ? > > Thanks...
[web2py] Re: Output from some controller
I think apt sends the output to stdout. There are two ways to capture that: 1) redirect stdout to a file, then read and display the file. This is not thread safe which requires you lock when you do it 2) use multiprocessing or popen and run the function in a separate process which then captures the output. I this case I would go with 1. On Jan 12, 8:24 pm, blackshirt wrote: > i have some a littel coding with web2py framework.. > here is my controller and file : > > def update(): > cache = apt.Cache() > progress = apt.progress.TextFetchProgress() > res = cache.update(progress) > return dict(res = res) > > in this related view.. > > {{extend 'layout.html'}} > {{=res}} > {{pass}} > > the controller works normally, ie. update the APT database.. i see it > progress on console output. > but on view just return value > > True > > after process update finish... > > i hope, the output progress, like this normally : > > Hithttp://ftp.hk.debian.orgstable Release.gpg > Hithttp://security.debian.orgstable/updates Release.gpg > Ignoredhttp://security.debian.org/stable/updates/contrib Translation- > en > Failedhttp://security.debian.org/stable/updates/contrib Translation- > en > Ignoredhttp://security.debian.org/stable/updates/main Translation-en > Failedhttp://security.debian.org/stable/updates/main Translation-en > Ignoredhttp://security.debian.org/stable/updates/non-free > Translation-en > Failedhttp://security.debian.org/stable/updates/non-free Translation- > en > Hithttp://security.debian.orgstable/updates Release > Donehttp://security.debian.orgstable/updates Release > Ignoredhttp://ftp.hk.debian.org/debian/stable/contrib Translation-en > Failedhttp://ftp.hk.debian.org/debian/stable/contrib Translation-en > Hithttp://security.debian.orgstable/updates/main amd64 Packages > Ignoredhttp://ftp.hk.debian.org/debian/stable/main Translation-en > Failedhttp://ftp.hk.debian.org/debian/stable/main Translation-en > Hithttp://security.debian.orgstable/updates/contrib amd64 Packages > Hithttp://security.debian.orgstable/updates/non-free amd64 Packages > Ignoredhttp://ftp.hk.debian.org/debian/stable/non-free Translation- > en > Failedhttp://ftp.hk.debian.org/debian/stable/non-free Translation-en > Hithttp://ftp.hk.debian.orgstable Release > Donehttp://ftp.hk.debian.orgstable Release > Hithttp://ftp.hk.debian.orgstable/main Sources > Hithttp://ftp.hk.debian.orgstable/contrib Sources > Hithttp://ftp.hk.debian.orgstable/non-free Sources > Hithttp://ftp.hk.debian.orgstable/main amd64 Packages > Hithttp://ftp.hk.debian.orgstable/contrib amd64 Packages > Hithttp://ftp.hk.debian.orgstable/non-free amd64 Packages > Done downloading > > showing on the view output.. > How we can do this on web2py ? > i'm still pretty newbie on python and web2py > > thanks
[web2py] Re: Documentation of web2py
it is on my todo list enable editing of the online book. On Jan 13, 5:35 pm, davidjensen wrote: > I would like to help with the documentation of web2py. Is there a way > to do that, perhaps collaboratively?
[web2py] Re: Cherrypy can run on android ! without any patching needed , Can Rocket do that?
I did not try but I think yes because it does not use any additional libraries. On Jan 14, 6:50 am, Phyo Arkar wrote: > I cant wait to run Web2py on my android 8 inches and 10 inches tablets and > develop inside there. > But i see this tutorial : Cherrypy on Android! > > Can we hack rocket to run on android and then we should be able to run > web2py on > there!http://www.defuze.org/archives/228-running-cherrypy-on-android-with-s... > > Anyone up for that? > > Thanks > > Phyo.
[web2py] Re: Custom Operator
Thanks I will look into it. On Jan 14, 2:41 am, howesc wrote: > take a look at dal.py for the postgresql adaptor. see how it defines the > other operators. hopefully that will give you some clues as to how you > would extend the DAL to have your operator. > > i haven't done it myself, but it's just software so i'm sure there is a > solution. :) > > cfh
[web2py] Re: Rows without Headers
Well, discovered the answer myself! To retrieve the label of a field .. db['tablename']['fieldname'].label On Jan 13, 5:42 pm, Vikas Singhal wrote: > Hi , > > How can produce a list of rows without the header information. I need > to use this to json encode and send it datatable which will then > display it. Currently I have written a loop which does the job but I > was wondering if we have something already? > > Regards, > Vikas
[web2py] Re: contains return no rows of field list:string
tags has to be a list of strings, try: db.entries.insert(title='hello',tags='one,two,three'.split(',')) or the equivalent: db.entries.insert(title='hello',tags=['one','two','three']) On Jan 14, 10:14 am, Joseph Jude wrote: > I went into shell in a new web2py directory and tried the below. > Surprisingly, I get empty output. Any explanations? > > python web2py.py -S init -M > > db.define_table('entries', > Field('title', type='string'), > Field('tags', 'list:string')) > > >>> db.entries.insert(title='hello',tags='one,two,three') > > 1 > > >>> t=db(db.entries.tags.contains('one')).select() > >>> t.as_list() > > []
Re: [web2py] contains return no rows of field list:string
I went into shell in a new web2py directory and tried the below. Surprisingly, I get empty output. Any explanations? python web2py.py -S init -M db.define_table('entries', Field('title', type='string'), Field('tags', 'list:string')) >>> db.entries.insert(title='hello',tags='one,two,three') 1 >>> t=db(db.entries.tags.contains('one')).select() >>> t.as_list() []
[web2py] Re: latest web2py trunk: AttributeError: 'module' object has no attribute 'ftruncate'
ok, thanks Massimo!
Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors
I am with the same difficulty as David. Alex On Tue, Jan 10, 2012 at 7:21 PM, villas wrote: > Hi Bruno > > I just downloaded the zip file, but it seems broken. Did you re.factor > config.db.uri to be config.db_options.uri etc? I think you still a few > edits to do. I tried to debug but in the end I did not have enough time but > I am really looking forward to trying it again soon. > > Thanks, David > > >
[web2py] Re: T and internationalization
It would be a little bit "hard" or counterintuitive... The next step in development would be support more languages going on: by now I'd like a way to tell web2py: if Accept-Language is in ['it', 'it-it'] apply translations from it.py, else apply translations from ['en']. In this way a would have a "functional" default of a 'en' application, and when I'd like to add support for, let's say, 'fr', I can add them with the same logic I used for 'it'. Is there a way to accomplish that ?
Re: [web2py] Forwarding domain to a port
nginx will do the trick! On Thu, Jan 12, 2012 at 10:13 PM, Jonathan Lundell wrote: > On Jan 12, 2012, at 4:48 AM, Najtsirk wrote: > > I successfully instaled web2py on my VPS. However, I have problem to > forward my domain to port 8000. I can access web2py at > www.mydomain.com:8000/welcome. How can I forward domain so that > www.mydomain.com will actually show www.mydomain.com:8000/welcome? > > > mod_proxy (as others have pointed out) will do what you ask, but why not > just have web2py listen on port 80? >
[web2py] Cherrypy can run on android ! without any patching needed , Can Rocket do that?
I cant wait to run Web2py on my android 8 inches and 10 inches tablets and develop inside there. But i see this tutorial : Cherrypy on Android! Can we hack rocket to run on android and then we should be able to run web2py on there! http://www.defuze.org/archives/228-running-cherrypy-on-android-with-sl4a.html Anyone up for that? Thanks Phyo.
Re: [web2py] contains return no rows of field list:string
Thanks Bruno. I deleted the db and recreated (its only in db). The error still persists. print type(entry.tags) returns list and the field values are |learning|other|other| I can see that in the field too. Would you mind sharing your rest code? I think I'm missing something 'small' Regards, Joseph
Re: [web2py] contains return no rows of field list:string
Have you redefined tje field type to list:string or originally created as list:string? Can you open your SQLITE using SQLITEMANAGER or other client and see if values are |learning|other|another| if you retrieve the Row the column returns a list type? I tested here and for me its working, looks like you have problems in your db. On Sat, Jan 14, 2012 at 8:07 AM, Joseph Jude wrote: > I have the below table definition > > db.define_table('entries', > Field('tags', 'list:string',required=True)) > > and then inserted values. Now I am trying to select using the below > > entries = db(db.entries.tags.contains('learning')).select() > > It returns no values (though there are rows in db). > > db: sqlite; web2py: 1.99.4 > > Thank you, > Joseph > -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] contains return no rows of field list:string
I have the below table definition db.define_table('entries', Field('tags', 'list:string',required=True)) and then inserted values. Now I am trying to select using the below entries = db(db.entries.tags.contains('learning')).select() It returns no values (though there are rows in db). db: sqlite; web2py: 1.99.4 Thank you, Joseph
[web2py] Re: Routes error
Thank you Guys its working now very well ..
[web2py] Re: Get the URL
Thank you all guys its working great now , i used this {{MyUrl = "http://www.mydomain.com/%s/%s"; %request.url,request.env.query_string}} {{=MyUrl}} Best Regards, Hassan Al-Natuor