[web2py] does anybody know what happened to www.web2pyslices.com?
It's not reachable since a couple of days, and it's a very valuable tool for web2py users... José L.
[web2py] I have to make a new site, example appliance needed
Hi all, I have to made a new website/webapplication. It is structured as following: Home page (header, a little login form, several text and images, footer) Page 1 (not too different from home page...) Page 2 (idem) Page 3 (idem) Control panel to manage contents of all other pages (insert text, image...) accessible by login Question is: what is the simplest appliance with this features available to use as a base to modify? I search for a simple one because I dont want to dig inside "big" amount of code...
[web2py] Typo error in the official web2py book
I dont know if this is the correct place to post this, but I have found a typo in http://web2py.com/book/default/section/3/9 In the wiki code presented (first block, the db model) at lines 39 and 48 a function parameter (an empty string) is not correctly enclosed causing a syntax error. Or maybe I dont get it... Better safe than sorry :D
[web2py] Re: does anybody know what happened to www.web2pyslices.com?
My VPS provider is having some major problems. I'm going to move it tomorrow if they can't resolve. It should be back up within a day. On Jun 9, 2:24 am, José L. wrote: > It's not reachable since a couple of days, and it's a very valuable > tool for web2py users... > > José L.
[web2py] Re: upload file -- lot of file in one directory
I mean the uuid_key's first two letters... On jún. 9, 08:45, szimszon wrote: > I wasn't able to continue the thread in > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > So... > > I imagine that I would have lots of files say some 10 000 or more. :) > I think with ext3/ext2... filesystems so many files in one directory > is a mess. > > Is there absoute out of question to have upload/download to handle > this issue in trunk? > > I think of some kind of directory structure like one directory (say > upload/0) has X number of files then the new one (upload/1) is created > and the new files are stored in it... > ...and download could handle it out of the box. > > Or the generated filenames first or first two character is the > directory name under upload/ and the file is stored under that > directory... it could be a Field switch which defaults to the old > behavior...
[web2py] Re: PluginManager?
Hi, a Task Scheduler Plugin would be very nice. Kindly keep me posted about your progress! What exactly is the Problem, do you have a traceback? On 8 Jun., 05:42, Doug Warren wrote: > So I'm writing a plugin to handle scheduling of tasks with a dynamic > granularity of a second or less, and I went to use PluginManger per > it's definition in tools.py: > class PluginManager(dict): > """ > This object stored parameters to configure plugins (if they need > configuration) > In models/db.py instantiate the PluginManager > > plugins=PluginManager() > > then set the parameters required plugins, for example > > plugins.comments.db=db > > (each plugin should have a documented set of required parameters) > """ > > My code: > plugins = PluginManager() > db = plugins.plugin_scheduler.db or None > > if db is not None: > db.define_table(plugins.plugin_scheduler.table_name or > 'plugin_scheduler_table', > db.Field('execution_time', 'datetime', default=request.now), > db.Field('controller', 'string'), > db.Field('function', 'string') > ) > > Only problem... > def __init__(self,env): > self['globals'] = env > > What's that env? Has anyone written a plugin that uses PluginManager? > I checked on the official site and none seem to be using it... If > it's request.env shouldn't it have a default arg of None? Am I using > it as it was expected to be used?
[web2py] Re: PluginManager?
env(a, import_models=False, c=1, f=1, dir='', extra_request={}) Return web2py execution environment for application (a), controller (c), function (f). If import_models is True the exec all application models into the environment. extra_request allows you to pass along any extra variables to the request object before your models get executed. This was mainly done to support web2py_utils.test_runner, however you can use it with any wrapper scripts that need access to the web2py environment. On 8 Jun., 05:42, Doug Warren wrote: > So I'm writing a plugin to handle scheduling of tasks with a dynamic > granularity of a second or less, and I went to use PluginManger per > it's definition in tools.py: > class PluginManager(dict): > """ > This object stored parameters to configure plugins (if they need > configuration) > In models/db.py instantiate the PluginManager > > plugins=PluginManager() > > then set the parameters required plugins, for example > > plugins.comments.db=db > > (each plugin should have a documented set of required parameters) > """ > > My code: > plugins = PluginManager() > db = plugins.plugin_scheduler.db or None > > if db is not None: > db.define_table(plugins.plugin_scheduler.table_name or > 'plugin_scheduler_table', > db.Field('execution_time', 'datetime', default=request.now), > db.Field('controller', 'string'), > db.Field('function', 'string') > ) > > Only problem... > def __init__(self,env): > self['globals'] = env > > What's that env? Has anyone written a plugin that uses PluginManager? > I checked on the official site and none seem to be using it... If > it's request.env shouldn't it have a default arg of None? Am I using > it as it was expected to be used?
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro wrote: > If it were possible to do a SQL insert without the dummy filed this > almost the same as creating a sequence. web2py can create a table > without any field but the "id", but I do not do not how to do an > insert without any field value. > > On Jun 8, 8:12 pm, Thadeus Burgess wrote: >> This *might* work. You are right, it is still horrible... It might be >> *effectively* accomplishing the same thing that sequences do on >> PostgreSQL, however I still wouldn't use it in production as it feels >> "hacky". I already have to re-design this table, so I might as well do >> it 100% right. >> >> I never expected the scale of inserts that happened yesterday and >> today, nor had any proper benchmarking been done previously if it >> could handle this kind of sudden rush of traffic. >> >> -- >> Thadeus >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro wrote: >> > I know this horrible but it does solve some of the problems... >> >> > db.define_table('whopper_seq',Field('dummy')) >> >> > db.define_table('yourtable',... >> > Field("whopper_id", "integer",compute=lambda r: >> > db.whopper_seq.insert(dummy=None)) >> > ...) >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: >> >> I have a problem. >> >> >> I have this in the database >> >> >> Field("whopper_id", "string", default=None, unique=True), >> >> >> The thing with whopper_id is it always stores numbers. Said numbers >> >> are anywhere from 2 to 6. >> >> >> Also upon entering a new entry, I do the following >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) >> >> >> So I do all this juju just to get the number to autoincrement. >> >> >> The problem is, this structure is bad... first I'm storing integers in >> >> a string field, and then manually incrementing them >> >> >> I get errors like... IntegrityError: duplicate key value violates >> >> unique constraint "table_whopper_id_key"... when two requests come in >> >> to create a record within miliseconds of each other. >> >> >> Here is where I need some help please. >> >> >> I need to convert this entire field, into an autoincrementing integer >> >> performed by the database, however ALL current whopper_ids must stay >> >> EXACTLY the same. >> >> >> I don't know how to accomplish this with web2py. I know what I want... >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) >> >> >> But how do I convert all existing whopper_ids over and keep them the >> >> exact same? >> >> >> Is this even possible with web2py and the DAL? >> >> >> -- >> >> Thadeus >
Re: [web2py] Re: PluginManager?
We have not fully agreed on the spec of PluginManager, it has been added as a proof of concept, however no plugins to date have been implemented with it. There are hundreds of posts debated what it should do. Currently the spec for plugins is you can do anything you want as long as it has the word plugin_ in front of it. PluginManager is an attempt to clean up the global namespace, so you don't have tons of plugins littering with their own variables and such. Not sure if you have seen this... http://static.thadeusb.com/Web2py%20Plugin%20Specification.pdf -- Thadeus On Wed, Jun 9, 2010 at 5:08 AM, AsmanCom wrote: > env(a, import_models=False, c=1, f=1, dir='', extra_request={}) > > Return web2py execution environment for application (a), controller > (c), function (f). If import_models is True the exec all application > models into the environment. > extra_request allows you to pass along any extra variables to the > request object before your models get executed. This was mainly done > to support web2py_utils.test_runner, however you can use it with any > wrapper scripts that need access to the web2py environment. > > On 8 Jun., 05:42, Doug Warren wrote: >> So I'm writing a plugin to handle scheduling of tasks with a dynamic >> granularity of a second or less, and I went to use PluginManger per >> it's definition in tools.py: >> class PluginManager(dict): >> """ >> This object stored parameters to configure plugins (if they need >> configuration) >> In models/db.py instantiate the PluginManager >> >> plugins=PluginManager() >> >> then set the parameters required plugins, for example >> >> plugins.comments.db=db >> >> (each plugin should have a documented set of required parameters) >> """ >> >> My code: >> plugins = PluginManager() >> db = plugins.plugin_scheduler.db or None >> >> if db is not None: >> db.define_table(plugins.plugin_scheduler.table_name or >> 'plugin_scheduler_table', >> db.Field('execution_time', 'datetime', default=request.now), >> db.Field('controller', 'string'), >> db.Field('function', 'string') >> ) >> >> Only problem... >> def __init__(self,env): >> self['globals'] = env >> >> What's that env? Has anyone written a plugin that uses PluginManager? >> I checked on the official site and none seem to be using it... If >> it's request.env shouldn't it have a default arg of None? Am I using >> it as it was expected to be used? >
Re: [web2py] I have to make a new site, example appliance needed
Just use the welcome application. That should do it. But your approach is pretty, well, novice. Lots of questions need to be answered both by yourself and others. What will change on the site, and when. Can you program in python, html, css, js, or other languages? (This helps you determine what kind of setup you would like. You could try making a simple wiki. But that's that end all, not so good looking solution. BR, Jason On Wed, 2010-06-09 at 10:08 +0200, Giuseppe Luca Scrofani wrote: > Hi all, I have to made a new website/webapplication. It is structured > as following: > > Home page (header, a little login form, several text and images, footer) > Page 1 (not too different from home page...) > Page 2 (idem) > Page 3 (idem) > Control panel to manage contents of all other pages (insert text, > image...) accessible by login > > Question is: what is the simplest appliance with this features > available to use as a base to modify? > I search for a simple one because I dont want to dig inside "big" > amount of code...
[web2py] Funny ordering situation...
I have a field in my database that I would like to order in a particular way. It is string. Could I order the item by stating what should be first second third, and then the rest can be alphabetical. In particular. db.orders, orderby=db.orders.status That way I can get all the "Completed" and the second could be "At the door" and so on? BR, Jason Brower
Re: [web2py] upload file -- lot of file in one directory
I wonder if it would be better to sort by type. /uploads/table_name/field_name/ Working with those images/files should be done from a database don't you think? When I deal with large amounts of files I use the console. BR, Jason Brower On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > I wasn't able to continue the thread in > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dcef81/ > > So... > > I imagine that I would have lots of files say some 10 000 or more. :) > I think with ext3/ext2... filesystems so many files in one directory > is a mess. > > Is there absoute out of question to have upload/download to handle > this issue in trunk? > > I think of some kind of directory structure like one directory (say > upload/0) has X number of files then the new one (upload/1) is created > and the new files are stored in it... > ...and download could handle it out of the box. > > Or the generated filenames first or first two character is the > directory name under upload/ and the file is stored under that > directory... it could be a Field switch which defaults to the old > behavior...
[web2py] Re: Best CSS framework for web2py
Hello, ez-css is great for layout, I'm using it. for typography, you could use the "typography.css" of blueprint. On Jun 8, 4:03 pm, Salvor Hardin wrote: > I'm looking for a great CSS framework to use with web2py. > > Someone in this group mentioned using Blueprint for typography and ez- > css for layout. > > I'd like to hear recommendations from web2py users. Which is your > favorite? > > If you are unfamiliar with CSS frameworks, check out: > *http://www.w3avenue.com/2009/04/29/definitive-list-of-css-frameworks-... > *http://en.wikipedia.org/wiki/CSS_framework > > Some of them, like Blueprint, have a lot of > features:http://www.blueprintcss.org/ > * A CSS reset that eliminates the discrepancies across browsers. > * A solid grid that can support the most complex of layouts. > * Typography based on expert principles that predate the web. > * Form styles for great looking user interfaces. > * Print styles for making any webpage ready for paper. > * Plugins for buttons, tabs and sprites. > * Tools, editors, and templates for every step in your workflow. > > While others, like ez-css, are very lightweight by comparison. Again, > I'd love to hear from web2py users about their favorite css > framework(s).
[web2py] Re: upload file -- lot of file in one directory
Hmm... there are a lot of possibility to separate files into folders... I typically would have lots of files with the same type... In the mean time I have a path to separate the uploaded files into subdirectories based on uuid_key's first X character: cut --- sql.py.orig 2010-06-08 23:45:04.0 +0200 +++ sql.py 2010-06-09 12:50:46.0 +0200 @@ -49,7 +49,7 @@ table_field = re.compile('[\w_]+\.[\w_]+') oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] +|'')*'\))") -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? P\w+)\.\w+$') regex_cleanup_fn = re.compile('[\'"\s;]+') # list of drivers will be built on the fly @@ -2600,7 +2600,9 @@ # 'a_field_name' means store in this field in db # False means file content will be discarded. writable=True, readable=True, update=None, authorize=None, -autodelete=False, represent=None, uploadfolder=None) +autodelete=False, represent=None, uploadfolder=None, +uploadseparate=None # upload to separate directories by uuid_keys + # first X character) to be used as argument of SQLDB.define_table @@ -2636,6 +2638,7 @@ autodelete=False, represent=None, uploadfolder=None, +uploadseparate=None, compute=None, ): @@ -2655,6 +2658,7 @@ self.unique = unique self.uploadfield = uploadfield self.uploadfolder = uploadfolder +self.uploadseparate = uploadseparate self.widget = widget self.label = label self.comment = comment @@ -2695,6 +2699,10 @@ path = self.uploadfolder else: path = os.path.join(self._db._folder, '..', 'uploads') +if self.uploadseparate: +path = os.path.join(path,uuid_key[:self.uploadseparate]) +if not os.path.exists(path): +os.mkdir(path) pathfilename = os.path.join(path, newfilename) dest_file = open(pathfilename, 'wb') shutil.copyfileobj(file, dest_file) @@ -2728,6 +2736,9 @@ path = self.uploadfolder else: path = os.path.join(self._db._folder, '..', 'uploads') +if self.uploadseparate: +u = m.group('uuidkey') +path = os.path.join(path,u[:self.uploadseparate]) return (filename, open(os.path.join(path, name), 'rb')) def formatter(self, value): --- cut --- I introduced the "uploadseparate" parameter which is either None -- default (backward compatible) or the number of characters of uuid_key... The directory is created automatically and this works with uploadfolder too (uploadfolder/uploadseparate)... I don't know the name "uploadseparate" is acceptable... or the patch :) There could be a better way... On jún. 9, 12:40, Jason Brower wrote: > I wonder if it would be better to sort by type. > /uploads/table_name/field_name/ > Working with those images/files should be done from a database don't you > think? When I deal with large amounts of files I use the console. > BR, > Jason Brower > > On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > > I wasn't able to continue the thread in > > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > > So... > > > I imagine that I would have lots of files say some 10 000 or more. :) > > I think with ext3/ext2... filesystems so many files in one directory > > is a mess. > > > Is there absoute out of question to have upload/download to handle > > this issue in trunk? > > > I think of some kind of directory structure like one directory (say > > upload/0) has X number of files then the new one (upload/1) is created > > and the new files are stored in it... > > ...and download could handle it out of the box. > > > Or the generated filenames first or first two character is the > > directory name under upload/ and the file is stored under that > > directory... it could be a Field switch which defaults to the old > > behavior... > >
Re: [web2py] I have to make a new site, example appliance needed
Hi Jason, thanks for answer. In a hurry I just exposed my problem in too basic terms. I have started extending the wiki example in the web2py book, it seem to be what I need. My request was for a sort of "template"... I founded it, so thanks. gls
[web2py] Re: upload file -- lot of file in one directory
I have no problem to dealing with large amounts of files its just the underlaying filesystem is just not for storing large number of files in one directory. I speak about ext2/ext3 which I use... Some threads about it: http://serverfault.com/questions/129953/maximum-number-of-files-in-one-ext3-directory-while-still-getting-acceptable-perf "My personal rule of thumb is to aim for a directory size of <= 20k files, although I've seen relatively decent performance with up to 100k files/directory." http://roopindersingh.com/2008/05/10/ext3-handling-large-number-of-files-in-a-directory/ On jún. 9, 12:40, Jason Brower wrote: > I wonder if it would be better to sort by type. > /uploads/table_name/field_name/ > Working with those images/files should be done from a database don't you > think? When I deal with large amounts of files I use the console. > BR, > Jason Brower > > On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > > I wasn't able to continue the thread in > > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > > So... > > > I imagine that I would have lots of files say some 10 000 or more. :) > > I think with ext3/ext2... filesystems so many files in one directory > > is a mess. > > > Is there absoute out of question to have upload/download to handle > > this issue in trunk? > > > I think of some kind of directory structure like one directory (say > > upload/0) has X number of files then the new one (upload/1) is created > > and the new files are stored in it... > > ...and download could handle it out of the box. > > > Or the generated filenames first or first two character is the > > directory name under upload/ and the file is stored under that > > directory... it could be a Field switch which defaults to the old > > behavior... > >
[web2py] adding table to RBAC
Hello, I implement the RBAC in my app and I try to figure it out how I can add more table in the dropbox of auth_permission table... There is only the auth_ table in the dropbox... I'm not experienced with RBAC and web2py then the information in web2py book are a bit short to me. Thanks. Jonhy
[web2py] Re: tos download
Mind this works if web2py is serving static files, not if apache does. On Jun 9, 1:06 am, annet wrote: > Massimo, > > I used: > > > {{=A('terms of service',_href=URL(r=request,c='static',f='cms/files/ > > tos_fitwise.pdf',vars=dict(attachment=True)))}} > > and it works, so problem solved thanks. > > Annet.
[web2py] Re: Typo error in the official web2py book
thanks. here is a good place. On Jun 9, 3:25 am, Giuseppe Luca Scrofani wrote: > I dont know if this is the correct place to post this, but I have > found a typo inhttp://web2py.com/book/default/section/3/9 > In the wiki code presented (first block, the db model) at lines 39 and > 48 a function parameter (an empty string) is not correctly enclosed > causing a syntax error. Or maybe I dont get it... Better safe than > sorry :D
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess wrote: > That is the thing, its *almost* the same, but its not a true postgres > sequence. Postgres already has many years of development making sure > their auto number works, why can't I just use that instead of trying > to hack around the limitations of a system? > > I don't have a choice. I *must* have native support for autonumber, or > I have to use another system that already allows me to. > > -- > Thadeus > > On Tue, Jun 8, 2010 at 10:22 PM, mdipierro wrote: > > If it were possible to do a SQL insert without the dummy filed this > > almost the same as creating a sequence. web2py can create a table > > without any field but the "id", but I do not do not how to do an > > insert without any field value. > > > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > >> This *might* work. You are right, it is still horrible... It might be > >> *effectively* accomplishing the same thing that sequences do on > >> PostgreSQL, however I still wouldn't use it in production as it feels > >> "hacky". I already have to re-design this table, so I might as well do > >> it 100% right. > > >> I never expected the scale of inserts that happened yesterday and > >> today, nor had any proper benchmarking been done previously if it > >> could handle this kind of sudden rush of traffic. > > >> -- > >> Thadeus > > >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro wrote: > >> > I know this horrible but it does solve some of the problems... > > >> > db.define_table('whopper_seq',Field('dummy')) > > >> > db.define_table('yourtable',... > >> > Field("whopper_id", "integer",compute=lambda r: > >> > db.whopper_seq.insert(dummy=None)) > >> > ...) > > >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > >> >> I have a problem. > > >> >> I have this in the database > > >> >> Field("whopper_id", "string", default=None, unique=True), > > >> >> The thing with whopper_id is it always stores numbers. Said numbers > >> >> are anywhere from 2 to 6. > > >> >> Also upon entering a new entry, I do the following > > >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, > >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > >> >> So I do all this juju just to get the number to autoincrement. > > >> >> The problem is, this structure is bad... first I'm storing integers in > >> >> a string field, and then manually incrementing them > > >> >> I get errors like... IntegrityError: duplicate key value violates > >> >> unique constraint "table_whopper_id_key"... when two requests come in > >> >> to create a record within miliseconds of each other. > > >> >> Here is where I need some help please. > > >> >> I need to convert this entire field, into an autoincrementing integer > >> >> performed by the database, however ALL current whopper_ids must stay > >> >> EXACTLY the same. > > >> >> I don't know how to accomplish this with web2py. I know what I want... > > >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) > > >> >> But how do I convert all existing whopper_ids over and keep them the > >> >> exact same? > > >> >> Is this even possible with web2py and the DAL? > > >> >> -- > >> >> Thadeus
[web2py] Re: Funny ordering situation...
You have two options: 1) perform 4 quesries rows=db(query_first).select()+db(query_second).select() +db(query_third).select()+db(query_others).select(orderby=criteria) 2) perform one query and sort them in memoery rows=db(...).select().sort(lambda row: yoursortingfunction(row)) On Jun 9, 5:38 am, Jason Brower wrote: > I have a field in my database that I would like to order in a particular > way. It is string. > > Could I order the item by stating what should be first second third, and > then the rest can be alphabetical. > In particular. > db.orders, orderby=db.orders.status > That way I can get all the "Completed" and the second could be "At the > door" and so on? > BR, > Jason Brower
[web2py] Re: upload file -- lot of file in one directory
please email me this as an attachment. On Jun 9, 6:50 am, szimszon wrote: > Hmm... there are a lot of possibility to separate files into > folders... > > I typically would have lots of files with the same type... > > In the mean time I have a path to separate the uploaded files into > subdirectories based on uuid_key's first X character: > > cut > --- sql.py.orig 2010-06-08 23:45:04.0 +0200 > +++ sql.py 2010-06-09 12:50:46.0 +0200 > @@ -49,7 +49,7 @@ > > table_field = re.compile('[\w_]+\.[\w_]+') > oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] > +|'')*'\))") > -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') > +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? > P\w+)\.\w+$') > regex_cleanup_fn = re.compile('[\'"\s;]+') > > # list of drivers will be built on the fly > @@ -2600,7 +2600,9 @@ > # 'a_field_name' means store in this > field in db > # False means file content will be > discarded. > writable=True, readable=True, update=None, > authorize=None, > - autodelete=False, represent=None, uploadfolder=None) > + autodelete=False, represent=None, uploadfolder=None, > + uploadseparate=None # upload to separate directories by > uuid_keys > + # first X character) > > to be used as argument of SQLDB.define_table > > @@ -2636,6 +2638,7 @@ > autodelete=False, > represent=None, > uploadfolder=None, > + uploadseparate=None, > compute=None, > ): > > @@ -2655,6 +2658,7 @@ > self.unique = unique > self.uploadfield = uploadfield > self.uploadfolder = uploadfolder > + self.uploadseparate = uploadseparate > self.widget = widget > self.label = label > self.comment = comment > @@ -2695,6 +2699,10 @@ > path = self.uploadfolder > else: > path = os.path.join(self._db._folder, '..', > 'uploads') > + if self.uploadseparate: > + path = > os.path.join(path,uuid_key[:self.uploadseparate]) > + if not os.path.exists(path): > + os.mkdir(path) > pathfilename = os.path.join(path, newfilename) > dest_file = open(pathfilename, 'wb') > shutil.copyfileobj(file, dest_file) > @@ -2728,6 +2736,9 @@ > path = self.uploadfolder > else: > path = os.path.join(self._db._folder, '..', > 'uploads') > + if self.uploadseparate: > + u = m.group('uuidkey') > + path = os.path.join(path,u[:self.uploadseparate]) > return (filename, open(os.path.join(path, name), 'rb')) > > def formatter(self, value): > --- cut --- > > I introduced the "uploadseparate" parameter which is either None -- > default (backward compatible) or the number of characters of > uuid_key... > The directory is created automatically and this works with > uploadfolder too (uploadfolder/uploadseparate)... > > I don't know the name "uploadseparate" is acceptable... or the > patch :) There could be a better way... > > On jún. 9, 12:40, Jason Brower wrote: > > > I wonder if it would be better to sort by type. > > /uploads/table_name/field_name/ > > Working with those images/files should be done from a database don't you > > think? When I deal with large amounts of files I use the console. > > BR, > > Jason Brower > > > On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > > > I wasn't able to continue the thread in > > > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > > > So... > > > > I imagine that I would have lots of files say some 10 000 or more. :) > > > I think with ext3/ext2... filesystems so many files in one directory > > > is a mess. > > > > Is there absoute out of question to have upload/download to handle > > > this issue in trunk? > > > > I think of some kind of directory structure like one directory (say > > > upload/0) has X number of files then the new one (upload/1) is created > > > and the new files are stored in it... > > > ...and download could handle it out of the box. > > > > Or the generated filenames first or first two character is the > > > directory name under upload/ and the file is stored under that > > > directory... it could be a Field switch which defaults to the old > > > behavior...
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > In postgresql you get it native: > > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > On Jun 9, 5:28 am, Thadeus Burgess wrote: >> That is the thing, its *almost* the same, but its not a true postgres >> sequence. Postgres already has many years of development making sure >> their auto number works, why can't I just use that instead of trying >> to hack around the limitations of a system? >> >> I don't have a choice. I *must* have native support for autonumber, or >> I have to use another system that already allows me to. >> >> -- >> Thadeus >> >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro wrote: >> > If it were possible to do a SQL insert without the dummy filed this >> > almost the same as creating a sequence. web2py can create a table >> > without any field but the "id", but I do not do not how to do an >> > insert without any field value. >> >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: >> >> This *might* work. You are right, it is still horrible... It might be >> >> *effectively* accomplishing the same thing that sequences do on >> >> PostgreSQL, however I still wouldn't use it in production as it feels >> >> "hacky". I already have to re-design this table, so I might as well do >> >> it 100% right. >> >> >> I never expected the scale of inserts that happened yesterday and >> >> today, nor had any proper benchmarking been done previously if it >> >> could handle this kind of sudden rush of traffic. >> >> >> -- >> >> Thadeus >> >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro wrote: >> >> > I know this horrible but it does solve some of the problems... >> >> >> > db.define_table('whopper_seq',Field('dummy')) >> >> >> > db.define_table('yourtable',... >> >> > Field("whopper_id", "integer",compute=lambda r: >> >> > db.whopper_seq.insert(dummy=None)) >> >> > ...) >> >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: >> >> >> I have a problem. >> >> >> >> I have this in the database >> >> >> >> Field("whopper_id", "string", default=None, unique=True), >> >> >> >> The thing with whopper_id is it always stores numbers. Said numbers >> >> >> are anywhere from 2 to 6. >> >> >> >> Also upon entering a new entry, I do the following >> >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) >> >> >> >> So I do all this juju just to get the number to autoincrement. >> >> >> >> The problem is, this structure is bad... first I'm storing integers in >> >> >> a string field, and then manually incrementing them >> >> >> >> I get errors like... IntegrityError: duplicate key value violates >> >> >> unique constraint "table_whopper_id_key"... when two requests come in >> >> >> to create a record within miliseconds of each other. >> >> >> >> Here is where I need some help please. >> >> >> >> I need to convert this entire field, into an autoincrementing integer >> >> >> performed by the database, however ALL current whopper_ids must stay >> >> >> EXACTLY the same. >> >> >> >> I don't know how to accomplish this with web2py. I know what I want... >> >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) >> >> >> >> But how do I convert all existing whopper_ids over and keep them the >> >> >> exact same? >> >> >> >> Is this even possible with web2py and the DAL? >> >> >> >> -- >> >> >> Thadeus >
Re: [web2py] Re: PluginManager?
On Wed, Jun 9, 2010 at 3:34 AM, Thadeus Burgess wrote: > We have not fully agreed on the spec of PluginManager, it has been > added as a proof of concept, however no plugins to date have been > implemented with it. There are hundreds of posts debated what it > should do. > > Currently the spec for plugins is you can do anything you want as long > as it has the word plugin_ in front of it. > > PluginManager is an attempt to clean up the global namespace, so you > don't have tons of plugins littering with their own variables and > such. > > Not sure if you have seen this... > http://static.thadeusb.com/Web2py%20Plugin%20Specification.pdf My confusion was thinking that something in the released branch was ready for use and not a proof of concept. I notice what's there disagrees with the specification above (which I hadn't seen before) in that PluginManager in the released tools.py takes 1 arg, called 'env' and not a DAL and not a default value for that DAL either. One concept that I do need and will be prototyping is that of a persistent DAL connection. A plugin DAL should not exist just for the life of a request, and obviously then would have to manage it's own transactions. But the plugin I'm writing kind of needs it. It instantiates a singleton class that starts it's own thread to manage a scheduler, currently obviously at the end of the initial request that started the singleton the passed database connection is no longer valid. I could pass the DAL knowledge to the singleton but that seems 'wrong' And actually this is getting far afield of the original topic... On Wed, Jun 9, 2010 at 3:04 AM, AsmanCom wrote: > Hi, > > a Task Scheduler Plugin would be very nice. > Kindly keep me posted about your progress! > > What exactly is the Problem, do you have a traceback? >> plugins = PluginManager() >> db = plugins.plugin_scheduler.db or None My only problem was the comments in the source trunk didn't match the actual implementation 2 lines later :) I've moved on past it but was a bit confused.
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
I am testing this (both sqlite and postgresql). How do you do it in raw sql? This does not work in sqlite sql CREATE TABLE a( id INTEGER PRIMARY KEY AUTOINCREMENT, d CHAR(512), b INTEGER AUTOINCREMENT ); It does not seem to like two AUTOINCREMENT fields (which is what I thought). On Jun 9, 9:01 am, Thadeus Burgess wrote: > Great. What about sqlite? > > -- > Thadeus > > On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > > In postgresql you get it native: > > > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > > On Jun 9, 5:28 am, Thadeus Burgess wrote: > >> That is the thing, its *almost* the same, but its not a true postgres > >> sequence. Postgres already has many years of development making sure > >> their auto number works, why can't I just use that instead of trying > >> to hack around the limitations of a system? > > >> I don't have a choice. I *must* have native support for autonumber, or > >> I have to use another system that already allows me to. > > >> -- > >> Thadeus > > >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro wrote: > >> > If it were possible to do a SQL insert without the dummy filed this > >> > almost the same as creating a sequence. web2py can create a table > >> > without any field but the "id", but I do not do not how to do an > >> > insert without any field value. > > >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > >> >> This *might* work. You are right, it is still horrible... It might be > >> >> *effectively* accomplishing the same thing that sequences do on > >> >> PostgreSQL, however I still wouldn't use it in production as it feels > >> >> "hacky". I already have to re-design this table, so I might as well do > >> >> it 100% right. > > >> >> I never expected the scale of inserts that happened yesterday and > >> >> today, nor had any proper benchmarking been done previously if it > >> >> could handle this kind of sudden rush of traffic. > > >> >> -- > >> >> Thadeus > > >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro > >> >> wrote: > >> >> > I know this horrible but it does solve some of the problems... > > >> >> > db.define_table('whopper_seq',Field('dummy')) > > >> >> > db.define_table('yourtable',... > >> >> > Field("whopper_id", "integer",compute=lambda r: > >> >> > db.whopper_seq.insert(dummy=None)) > >> >> > ...) > > >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > >> >> >> I have a problem. > > >> >> >> I have this in the database > > >> >> >> Field("whopper_id", "string", default=None, unique=True), > > >> >> >> The thing with whopper_id is it always stores numbers. Said numbers > >> >> >> are anywhere from 2 to 6. > > >> >> >> Also upon entering a new entry, I do the following > > >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, > >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > >> >> >> So I do all this juju just to get the number to autoincrement. > > >> >> >> The problem is, this structure is bad... first I'm storing integers > >> >> >> in > >> >> >> a string field, and then manually incrementing them > > >> >> >> I get errors like... IntegrityError: duplicate key value violates > >> >> >> unique constraint "table_whopper_id_key"... when two requests come in > >> >> >> to create a record within miliseconds of each other. > > >> >> >> Here is where I need some help please. > > >> >> >> I need to convert this entire field, into an autoincrementing integer > >> >> >> performed by the database, however ALL current whopper_ids must stay > >> >> >> EXACTLY the same. > > >> >> >> I don't know how to accomplish this with web2py. I know what I > >> >> >> want... > > >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) > > >> >> >> But how do I convert all existing whopper_ids over and keep them the > >> >> >> exact same? > > >> >> >> Is this even possible with web2py and the DAL? > > >> >> >> -- > >> >> >> Thadeus
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
I am not sure about the postgresql solution. Tell me how you do it in SQL and i tell you how to do in web2pyese. On Jun 9, 9:01 am, Thadeus Burgess wrote: > Great. What about sqlite? > > -- > Thadeus > > On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > > In postgresql you get it native: > > > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > > On Jun 9, 5:28 am, Thadeus Burgess wrote: > >> That is the thing, its *almost* the same, but its not a true postgres > >> sequence. Postgres already has many years of development making sure > >> their auto number works, why can't I just use that instead of trying > >> to hack around the limitations of a system? > > >> I don't have a choice. I *must* have native support for autonumber, or > >> I have to use another system that already allows me to. > > >> -- > >> Thadeus > > >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro wrote: > >> > If it were possible to do a SQL insert without the dummy filed this > >> > almost the same as creating a sequence. web2py can create a table > >> > without any field but the "id", but I do not do not how to do an > >> > insert without any field value. > > >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > >> >> This *might* work. You are right, it is still horrible... It might be > >> >> *effectively* accomplishing the same thing that sequences do on > >> >> PostgreSQL, however I still wouldn't use it in production as it feels > >> >> "hacky". I already have to re-design this table, so I might as well do > >> >> it 100% right. > > >> >> I never expected the scale of inserts that happened yesterday and > >> >> today, nor had any proper benchmarking been done previously if it > >> >> could handle this kind of sudden rush of traffic. > > >> >> -- > >> >> Thadeus > > >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro > >> >> wrote: > >> >> > I know this horrible but it does solve some of the problems... > > >> >> > db.define_table('whopper_seq',Field('dummy')) > > >> >> > db.define_table('yourtable',... > >> >> > Field("whopper_id", "integer",compute=lambda r: > >> >> > db.whopper_seq.insert(dummy=None)) > >> >> > ...) > > >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > >> >> >> I have a problem. > > >> >> >> I have this in the database > > >> >> >> Field("whopper_id", "string", default=None, unique=True), > > >> >> >> The thing with whopper_id is it always stores numbers. Said numbers > >> >> >> are anywhere from 2 to 6. > > >> >> >> Also upon entering a new entry, I do the following > > >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, > >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > >> >> >> So I do all this juju just to get the number to autoincrement. > > >> >> >> The problem is, this structure is bad... first I'm storing integers > >> >> >> in > >> >> >> a string field, and then manually incrementing them > > >> >> >> I get errors like... IntegrityError: duplicate key value violates > >> >> >> unique constraint "table_whopper_id_key"... when two requests come in > >> >> >> to create a record within miliseconds of each other. > > >> >> >> Here is where I need some help please. > > >> >> >> I need to convert this entire field, into an autoincrementing integer > >> >> >> performed by the database, however ALL current whopper_ids must stay > >> >> >> EXACTLY the same. > > >> >> >> I don't know how to accomplish this with web2py. I know what I > >> >> >> want... > > >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) > > >> >> >> But how do I convert all existing whopper_ids over and keep them the > >> >> >> exact same? > > >> >> >> Is this even possible with web2py and the DAL? > > >> >> >> -- > >> >> >> Thadeus
[web2py] how to do a data picker?
Hello, I have different types of data that must be selected, but a dropbox is not adequate. A popup that could list in columns my different data type would be an interesting alternative. Is there exist a plugin that would do that? I search for the code of calendar date picker included in web2py ... Where is it? Thank you. Jonhy
Re: [web2py] Re: Best CSS framework for web2py
On Jun 9, 2010, at 5:54 AM, Pepe wrote: > Hello, > > ez-css is great for layout, I'm using it. > > for typography, you could use the "typography.css" of blueprint. That's what I'm doing. I started out with blueprint, but switched my layout to ez-css to get a variable-width section. Highly recommended. But ez-css has no typography, and blueprint does a nice job of it, nicely independent of its layout css. > > On Jun 8, 4:03 pm, Salvor Hardin wrote: >> I'm looking for a great CSS framework to use with web2py. >> >> Someone in this group mentioned using Blueprint for typography and ez- >> css for layout. >> >> I'd like to hear recommendations from web2py users. Which is your >> favorite? >> >> If you are unfamiliar with CSS frameworks, check out: >> *http://www.w3avenue.com/2009/04/29/definitive-list-of-css-frameworks-... >> *http://en.wikipedia.org/wiki/CSS_framework >> >> Some of them, like Blueprint, have a lot of >> features:http://www.blueprintcss.org/ >> * A CSS reset that eliminates the discrepancies across browsers. >> * A solid grid that can support the most complex of layouts. >> * Typography based on expert principles that predate the web. >> * Form styles for great looking user interfaces. >> * Print styles for making any webpage ready for paper. >> * Plugins for buttons, tabs and sprites. >> * Tools, editors, and templates for every step in your workflow. >> >> While others, like ez-css, are very lightweight by comparison. Again, >> I'd love to hear from web2py users about their favorite css >> framework(s).
Re: [web2py] Re: Pycon APAC and Web2py
On Tue, Jun 8, 2010 at 02:09, mdipierro wrote: > send us some slides when done. > sure, u will sharing voice recoder ;-) > On Jun 7, 2:29 am, Anand Vaidya wrote: >> Pycon APAC 2010 is scheduled to run from 9th to 11th in Singapore. >> >> On the 10th June, 11:10am we have a talk : >> >> "Electronic Laboratory Notebook on the Web2Py Framework (Yong Yao Ng, >> Maurice HT Ling) " >> >> Maurice Ling is a staff member of the local (Republic) Polytechnic and >> the Conference Chair. >> >> http://pycon.sit.rp.sg/conference-1 >> >> FYI -- http://zoomquiet.org 人生苦短? Pythonic!
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
On a second thought of this matterthis is nonsense. If a table has two autoincrement fields ("id" and "other") they always contain the same values or values that differ for a constant offset (If the started with different values). That is why some database backends probably do not even support it and that is why I did not add web2py APIs to do this. The only reason to to have two auto-increments fields is if one "id" belongs to the table and "other: belongs to multiple tables, i.e. its value has to be unique for records stored in multiple tables. In this latter case it is not an auto increment fields but a referent to a table with an auto increment field and the proposed solution of using an auxiliary table is more than a hack, but probably the way to do go. Going back to your original case whopper_id is, naively, 2+id so you do not need a second auto-increment fields. The problem is that because whopper_id<6, this leaves you only 4 records available unless you recycle the values. Using an auto-increment would allow you to recycle values. Massimo On Jun 9, 9:26 am, mdipierro wrote: > I am not sure about the postgresql solution. Tell me how you do it in > SQL and i tell you how to do in web2pyese. > > On Jun 9, 9:01 am, Thadeus Burgess wrote: > > > Great. What about sqlite? > > > -- > > Thadeus > > > On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > > > In postgresql you get it native: > > > > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > > > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > > > On Jun 9, 5:28 am, Thadeus Burgess wrote: > > >> That is the thing, its *almost* the same, but its not a true postgres > > >> sequence. Postgres already has many years of development making sure > > >> their auto number works, why can't I just use that instead of trying > > >> to hack around the limitations of a system? > > > >> I don't have a choice. I *must* have native support for autonumber, or > > >> I have to use another system that already allows me to. > > > >> -- > > >> Thadeus > > > >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro > > >> wrote: > > >> > If it were possible to do a SQL insert without the dummy filed this > > >> > almost the same as creating a sequence. web2py can create a table > > >> > without any field but the "id", but I do not do not how to do an > > >> > insert without any field value. > > > >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > > >> >> This *might* work. You are right, it is still horrible... It might be > > >> >> *effectively* accomplishing the same thing that sequences do on > > >> >> PostgreSQL, however I still wouldn't use it in production as it feels > > >> >> "hacky". I already have to re-design this table, so I might as well do > > >> >> it 100% right. > > > >> >> I never expected the scale of inserts that happened yesterday and > > >> >> today, nor had any proper benchmarking been done previously if it > > >> >> could handle this kind of sudden rush of traffic. > > > >> >> -- > > >> >> Thadeus > > > >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro > > >> >> wrote: > > >> >> > I know this horrible but it does solve some of the problems... > > > >> >> > db.define_table('whopper_seq',Field('dummy')) > > > >> >> > db.define_table('yourtable',... > > >> >> > Field("whopper_id", "integer",compute=lambda r: > > >> >> > db.whopper_seq.insert(dummy=None)) > > >> >> > ...) > > > >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > > >> >> >> I have a problem. > > > >> >> >> I have this in the database > > > >> >> >> Field("whopper_id", "string", default=None, unique=True), > > > >> >> >> The thing with whopper_id is it always stores numbers. Said numbers > > >> >> >> are anywhere from 2 to 6. > > > >> >> >> Also upon entering a new entry, I do the following > > > >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, > > >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > > >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > > >> >> >> So I do all this juju just to get the number to autoincrement. > > > >> >> >> The problem is, this structure is bad... first I'm storing > > >> >> >> integers in > > >> >> >> a string field, and then manually incrementing them > > > >> >> >> I get errors like... IntegrityError: duplicate key value violates > > >> >> >> unique constraint "table_whopper_id_key"... when two requests come > > >> >> >> in > > >> >> >> to create a record within miliseconds of each other. > > > >> >> >> Here is where I need some help please. > > > >> >> >> I need to convert this entire field, into an autoincrementing > > >> >> >> integer > > >> >> >> performed by the database, however ALL current whopper_ids must > > >> >> >> stay > > >> >> >> EXACTLY the same. > > > >> >> >> I don't know how to accomplish this with web2py. I know what I > > >> >> >> want... > > > >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) > > > >>
[web2py] Re: Best CSS framework for web2py
I like ez-css a lot also. It that is very flexible, super fast to learn and use (no manual required really) and it works great for creating "flowable" sites as well. As a result of this discussion I am going to give the blueprint typography.css a shot. the Blueprint license seems very interesting: "Copyright (c) 2007-2009 blueprintcss.org The Blueprint CSS Framework is available for use in all personal or commercial projects, under both the (modified) MIT and the GPL license. You may choose the one that fits your project." Cheers, Chris On Jun 8, 4:03 pm, Salvor Hardin wrote: > I'm looking for a great CSS framework to use with web2py. > > Someone in this group mentioned using Blueprint for typography and ez- > css for layout. > > I'd like to hear recommendations from web2py users. Which is your > favorite? > > If you are unfamiliar with CSS frameworks, check out: > *http://www.w3avenue.com/2009/04/29/definitive-list-of-css-frameworks-... > *http://en.wikipedia.org/wiki/CSS_framework > > Some of them, like Blueprint, have a lot of > features:http://www.blueprintcss.org/ > * A CSS reset that eliminates the discrepancies across browsers. > * A solid grid that can support the most complex of layouts. > * Typography based on expert principles that predate the web. > * Form styles for great looking user interfaces. > * Print styles for making any webpage ready for paper. > * Plugins for buttons, tabs and sprites. > * Tools, editors, and templates for every step in your workflow. > > While others, like ez-css, are very lightweight by comparison. Again, > I'd love to hear from web2py users about their favorite css > framework(s).
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Postgres CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT SERIAL); Or... CREATE SEQUENCE seq_foo_did START 2; CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT nextval('seq_foo_did')); SQLite however does not support multiple auto-increment fields unfortunately, so on sqlite it must be done the way of creating another table with a blank field and use its id as a sequence (basically like how postgres does behind the scenes). MySQL also supports multiple autonumber fields. Having two autonumber fields is an absolute requirement of the system and there is no way around this. Unfortunately I don't have time to work on implementing this in web2py, and I could probably re-write my app in something else faster than it would take me to implement this in the DAL since I am not familiar enough with the DALs internal quirks. I can't do anything for at least 3 weeks programming wise, so I won't even be getting around to fixing this issue until then. -- Thadeus On Wed, Jun 9, 2010 at 9:26 AM, mdipierro wrote: > I am not sure about the postgresql solution. Tell me how you do it in > SQL and i tell you how to do in web2pyese. > > On Jun 9, 9:01 am, Thadeus Burgess wrote: >> Great. What about sqlite? >> >> -- >> Thadeus >> >> On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: >> > In postgresql you get it native: >> >> > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY >> > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) >> >> > On Jun 9, 5:28 am, Thadeus Burgess wrote: >> >> That is the thing, its *almost* the same, but its not a true postgres >> >> sequence. Postgres already has many years of development making sure >> >> their auto number works, why can't I just use that instead of trying >> >> to hack around the limitations of a system? >> >> >> I don't have a choice. I *must* have native support for autonumber, or >> >> I have to use another system that already allows me to. >> >> >> -- >> >> Thadeus >> >> >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro >> >> wrote: >> >> > If it were possible to do a SQL insert without the dummy filed this >> >> > almost the same as creating a sequence. web2py can create a table >> >> > without any field but the "id", but I do not do not how to do an >> >> > insert without any field value. >> >> >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: >> >> >> This *might* work. You are right, it is still horrible... It might be >> >> >> *effectively* accomplishing the same thing that sequences do on >> >> >> PostgreSQL, however I still wouldn't use it in production as it feels >> >> >> "hacky". I already have to re-design this table, so I might as well do >> >> >> it 100% right. >> >> >> >> I never expected the scale of inserts that happened yesterday and >> >> >> today, nor had any proper benchmarking been done previously if it >> >> >> could handle this kind of sudden rush of traffic. >> >> >> >> -- >> >> >> Thadeus >> >> >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro >> >> >> wrote: >> >> >> > I know this horrible but it does solve some of the problems... >> >> >> >> > db.define_table('whopper_seq',Field('dummy')) >> >> >> >> > db.define_table('yourtable',... >> >> >> > Field("whopper_id", "integer",compute=lambda r: >> >> >> > db.whopper_seq.insert(dummy=None)) >> >> >> > ...) >> >> >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: >> >> >> >> I have a problem. >> >> >> >> >> I have this in the database >> >> >> >> >> Field("whopper_id", "string", default=None, unique=True), >> >> >> >> >> The thing with whopper_id is it always stores numbers. Said numbers >> >> >> >> are anywhere from 2 to 6. >> >> >> >> >> Also upon entering a new entry, I do the following >> >> >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, >> >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id >> >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) >> >> >> >> >> So I do all this juju just to get the number to autoincrement. >> >> >> >> >> The problem is, this structure is bad... first I'm storing integers >> >> >> >> in >> >> >> >> a string field, and then manually incrementing them >> >> >> >> >> I get errors like... IntegrityError: duplicate key value violates >> >> >> >> unique constraint "table_whopper_id_key"... when two requests come >> >> >> >> in >> >> >> >> to create a record within miliseconds of each other. >> >> >> >> >> Here is where I need some help please. >> >> >> >> >> I need to convert this entire field, into an autoincrementing >> >> >> >> integer >> >> >> >> performed by the database, however ALL current whopper_ids must stay >> >> >> >> EXACTLY the same. >> >> >> >> >> I don't know how to accomplish this with web2py. I know what I >> >> >> >> want... >> >> >> >> >> Field("whopper_id", "integer", unique=True, autoincrement=True) >> >> >> >> >> But how do I convert all existing whopper_ids over and keep them >> >> >
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
well, I am posting in trunk a modifiled sql.py that allows Field('name','autoincrement') and generates the following code for postgresql (only postgresql). Give it a try. Massimo On Jun 9, 10:38 am, Thadeus Burgess wrote: > Postgres > > CREATE TABLE foo ( > id integer PRIMARY KEY SERIAL, > bar varchar, > did integer DEFAULT SERIAL); > > Or... > > CREATE SEQUENCE seq_foo_did START 2; > > CREATE TABLE foo ( > id integer PRIMARY KEY SERIAL, > bar varchar, > did integer DEFAULT nextval('seq_foo_did')); > > SQLite however does not support multiple auto-increment fields > unfortunately, so on sqlite it must be done the way of creating > another table with a blank field and use its id as a sequence > (basically like how postgres does behind the scenes). > > MySQL also supports multiple autonumber fields. > > Having two autonumber fields is an absolute requirement of the system > and there is no way around this. Unfortunately I don't have time to > work on implementing this in web2py, and I could probably re-write my > app in something else faster than it would take me to implement this > in the DAL since I am not familiar enough with the DALs internal > quirks. > > I can't do anything for at least 3 weeks programming wise, so I won't > even be getting around to fixing this issue until then. > > -- > Thadeus > > On Wed, Jun 9, 2010 at 9:26 AM, mdipierro wrote: > > I am not sure about the postgresql solution. Tell me how you do it in > > SQL and i tell you how to do in web2pyese. > > > On Jun 9, 9:01 am, Thadeus Burgess wrote: > >> Great. What about sqlite? > > >> -- > >> Thadeus > > >> On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > >> > In postgresql you get it native: > > >> > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > >> > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > >> > On Jun 9, 5:28 am, Thadeus Burgess wrote: > >> >> That is the thing, its *almost* the same, but its not a true postgres > >> >> sequence. Postgres already has many years of development making sure > >> >> their auto number works, why can't I just use that instead of trying > >> >> to hack around the limitations of a system? > > >> >> I don't have a choice. I *must* have native support for autonumber, or > >> >> I have to use another system that already allows me to. > > >> >> -- > >> >> Thadeus > > >> >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro > >> >> wrote: > >> >> > If it were possible to do a SQL insert without the dummy filed this > >> >> > almost the same as creating a sequence. web2py can create a table > >> >> > without any field but the "id", but I do not do not how to do an > >> >> > insert without any field value. > > >> >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > >> >> >> This *might* work. You are right, it is still horrible... It might be > >> >> >> *effectively* accomplishing the same thing that sequences do on > >> >> >> PostgreSQL, however I still wouldn't use it in production as it feels > >> >> >> "hacky". I already have to re-design this table, so I might as well > >> >> >> do > >> >> >> it 100% right. > > >> >> >> I never expected the scale of inserts that happened yesterday and > >> >> >> today, nor had any proper benchmarking been done previously if it > >> >> >> could handle this kind of sudden rush of traffic. > > >> >> >> -- > >> >> >> Thadeus > > >> >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro > >> >> >> wrote: > >> >> >> > I know this horrible but it does solve some of the problems... > > >> >> >> > db.define_table('whopper_seq',Field('dummy')) > > >> >> >> > db.define_table('yourtable',... > >> >> >> > Field("whopper_id", "integer",compute=lambda r: > >> >> >> > db.whopper_seq.insert(dummy=None)) > >> >> >> > ...) > > >> >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > >> >> >> >> I have a problem. > > >> >> >> >> I have this in the database > > >> >> >> >> Field("whopper_id", "string", default=None, unique=True), > > >> >> >> >> The thing with whopper_id is it always stores numbers. Said > >> >> >> >> numbers > >> >> >> >> are anywhere from 2 to 6. > > >> >> >> >> Also upon entering a new entry, I do the following > > >> >> >> >> last_whopper_id = db(db.table.id > 0).select(db.table.whopper_id, > >> >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > >> >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > >> >> >> >> So I do all this juju just to get the number to autoincrement. > > >> >> >> >> The problem is, this structure is bad... first I'm storing > >> >> >> >> integers in > >> >> >> >> a string field, and then manually incrementing them > > >> >> >> >> I get errors like... IntegrityError: duplicate key value violates > >> >> >> >> unique constraint "table_whopper_id_key"... when two requests > >> >> >> >> come in > >> >> >> >> to create a record within miliseconds of each other. > > >> >> >> >> Here is where I need some help please. > > >> >> >> >> I need to convert this entire field, into an
[web2py] Re: Advice, convert from string storing numbers to autoincrement integer
This is not going to stay, it is just for you to look at. Consider defining the field as integer and create a trigger using SQL to autofill this field. On Jun 9, 10:52 am, mdipierro wrote: > well, I am posting in trunk a modifiled sql.py that > > allows Field('name','autoincrement') and generates the following code > for postgresql (only postgresql). Give it a try. > > Massimo > > On Jun 9, 10:38 am, Thadeus Burgess wrote: > > > Postgres > > > CREATE TABLE foo ( > > id integer PRIMARY KEY SERIAL, > > bar varchar, > > did integer DEFAULT SERIAL); > > > Or... > > > CREATE SEQUENCE seq_foo_did START 2; > > > CREATE TABLE foo ( > > id integer PRIMARY KEY SERIAL, > > bar varchar, > > did integer DEFAULT nextval('seq_foo_did')); > > > SQLite however does not support multiple auto-increment fields > > unfortunately, so on sqlite it must be done the way of creating > > another table with a blank field and use its id as a sequence > > (basically like how postgres does behind the scenes). > > > MySQL also supports multiple autonumber fields. > > > Having two autonumber fields is an absolute requirement of the system > > and there is no way around this. Unfortunately I don't have time to > > work on implementing this in web2py, and I could probably re-write my > > app in something else faster than it would take me to implement this > > in the DAL since I am not familiar enough with the DALs internal > > quirks. > > > I can't do anything for at least 3 weeks programming wise, so I won't > > even be getting around to fixing this issue until then. > > > -- > > Thadeus > > > On Wed, Jun 9, 2010 at 9:26 AM, mdipierro wrote: > > > I am not sure about the postgresql solution. Tell me how you do it in > > > SQL and i tell you how to do in web2pyese. > > > > On Jun 9, 9:01 am, Thadeus Burgess wrote: > > >> Great. What about sqlite? > > > >> -- > > >> Thadeus > > > >> On Wed, Jun 9, 2010 at 8:41 AM, mdipierro > > >> wrote: > > >> > In postgresql you get it native: > > > >> > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > > >> > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > > >> > On Jun 9, 5:28 am, Thadeus Burgess wrote: > > >> >> That is the thing, its *almost* the same, but its not a true postgres > > >> >> sequence. Postgres already has many years of development making sure > > >> >> their auto number works, why can't I just use that instead of trying > > >> >> to hack around the limitations of a system? > > > >> >> I don't have a choice. I *must* have native support for autonumber, or > > >> >> I have to use another system that already allows me to. > > > >> >> -- > > >> >> Thadeus > > > >> >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro > > >> >> wrote: > > >> >> > If it were possible to do a SQL insert without the dummy filed this > > >> >> > almost the same as creating a sequence. web2py can create a table > > >> >> > without any field but the "id", but I do not do not how to do an > > >> >> > insert without any field value. > > > >> >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: > > >> >> >> This *might* work. You are right, it is still horrible... It might > > >> >> >> be > > >> >> >> *effectively* accomplishing the same thing that sequences do on > > >> >> >> PostgreSQL, however I still wouldn't use it in production as it > > >> >> >> feels > > >> >> >> "hacky". I already have to re-design this table, so I might as > > >> >> >> well do > > >> >> >> it 100% right. > > > >> >> >> I never expected the scale of inserts that happened yesterday and > > >> >> >> today, nor had any proper benchmarking been done previously if it > > >> >> >> could handle this kind of sudden rush of traffic. > > > >> >> >> -- > > >> >> >> Thadeus > > > >> >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro > > >> >> >> wrote: > > >> >> >> > I know this horrible but it does solve some of the problems... > > > >> >> >> > db.define_table('whopper_seq',Field('dummy')) > > > >> >> >> > db.define_table('yourtable',... > > >> >> >> > Field("whopper_id", "integer",compute=lambda r: > > >> >> >> > db.whopper_seq.insert(dummy=None)) > > >> >> >> > ...) > > > >> >> >> > On Jun 7, 8:29 pm, Thadeus Burgess wrote: > > >> >> >> >> I have a problem. > > > >> >> >> >> I have this in the database > > > >> >> >> >> Field("whopper_id", "string", default=None, unique=True), > > > >> >> >> >> The thing with whopper_id is it always stores numbers. Said > > >> >> >> >> numbers > > >> >> >> >> are anywhere from 2 to 6. > > > >> >> >> >> Also upon entering a new entry, I do the following > > > >> >> >> >> last_whopper_id = db(db.table.id > > > >> >> >> >> 0).select(db.table.whopper_id, > > >> >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id > > >> >> >> >> db.insert(whopper_id = (int(last_whopper_id) + 1)) > > > >> >> >> >> So I do all this juju just to get the number to autoincrement. > > > >> >> >> >> The problem is, this structure is bad... first I'm storing > > >> >> >> >> integers in >
[web2py] Re: upload file -- lot of file in one directory
Already done :) On jún. 9, 15:45, mdipierro wrote: > please email me this as an attachment. > > On Jun 9, 6:50 am, szimszon wrote: > > > Hmm... there are a lot of possibility to separate files into > > folders... > > > I typically would have lots of files with the same type... > > > In the mean time I have a path to separate the uploaded files into > > subdirectories based on uuid_key's first X character: > > > cut > > --- sql.py.orig 2010-06-08 23:45:04.0 +0200 > > +++ sql.py 2010-06-09 12:50:46.0 +0200 > > @@ -49,7 +49,7 @@ > > > table_field = re.compile('[\w_]+\.[\w_]+') > > oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] > > +|'')*'\))") > > -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') > > +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? > > P\w+)\.\w+$') > > regex_cleanup_fn = re.compile('[\'"\s;]+') > > > # list of drivers will be built on the fly > > @@ -2600,7 +2600,9 @@ > > # 'a_field_name' means store in this > > field in db > > # False means file content will be > > discarded. > > writable=True, readable=True, update=None, > > authorize=None, > > - autodelete=False, represent=None, uploadfolder=None) > > + autodelete=False, represent=None, uploadfolder=None, > > + uploadseparate=None # upload to separate directories by > > uuid_keys > > + # first X character) > > > to be used as argument of SQLDB.define_table > > > @@ -2636,6 +2638,7 @@ > > autodelete=False, > > represent=None, > > uploadfolder=None, > > + uploadseparate=None, > > compute=None, > > ): > > > @@ -2655,6 +2658,7 @@ > > self.unique = unique > > self.uploadfield = uploadfield > > self.uploadfolder = uploadfolder > > + self.uploadseparate = uploadseparate > > self.widget = widget > > self.label = label > > self.comment = comment > > @@ -2695,6 +2699,10 @@ > > path = self.uploadfolder > > else: > > path = os.path.join(self._db._folder, '..', > > 'uploads') > > + if self.uploadseparate: > > + path = > > os.path.join(path,uuid_key[:self.uploadseparate]) > > + if not os.path.exists(path): > > + os.mkdir(path) > > pathfilename = os.path.join(path, newfilename) > > dest_file = open(pathfilename, 'wb') > > shutil.copyfileobj(file, dest_file) > > @@ -2728,6 +2736,9 @@ > > path = self.uploadfolder > > else: > > path = os.path.join(self._db._folder, '..', > > 'uploads') > > + if self.uploadseparate: > > + u = m.group('uuidkey') > > + path = os.path.join(path,u[:self.uploadseparate]) > > return (filename, open(os.path.join(path, name), 'rb')) > > > def formatter(self, value): > > --- cut --- > > > I introduced the "uploadseparate" parameter which is either None -- > > default (backward compatible) or the number of characters of > > uuid_key... > > The directory is created automatically and this works with > > uploadfolder too (uploadfolder/uploadseparate)... > > > I don't know the name "uploadseparate" is acceptable... or the > > patch :) There could be a better way... > > > On jún. 9, 12:40, Jason Brower wrote: > > > > I wonder if it would be better to sort by type. > > > /uploads/table_name/field_name/ > > > Working with those images/files should be done from a database don't you > > > think? When I deal with large amounts of files I use the console. > > > BR, > > > Jason Brower > > > > On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > > > > I wasn't able to continue the thread in > > > > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > > > > So... > > > > > I imagine that I would have lots of files say some 10 000 or more. :) > > > > I think with ext3/ext2... filesystems so many files in one directory > > > > is a mess. > > > > > Is there absoute out of question to have upload/download to handle > > > > this issue in trunk? > > > > > I think of some kind of directory structure like one directory (say > > > > upload/0) has X number of files then the new one (upload/1) is created > > > > and the new files are stored in it... > > > > ...and download could handle it out of the box. > > > > > Or the generated filenames first or first two character is the > > > > directory name under upload/ and the file is stored under that > > > > directory... it could be a Field switch which defaults to the old > > > > behavior... > >
[web2py] Re: Minimal Install on Embedded Arm System
Hi Ed, Just move the entire web2py source folder and you should be good to develop. To save some space you can delete the examples app and potentially the welcome app (if you don't need to create new apps directly on the target system). I was looking into this at my last contract and I think the potential for Web2py on embedded systems is pretty big for a lot of reasons. Let us know how it goes. Thanks, Christopher Steel On Jun 7, 2:55 pm, ed wrote: > I would like to install web2py with the minimal footprint on an embedded > Arm system. The embedded Arm system already has Python 2.6 installed. > > What files do I need to install for web2py to run? > What do you expect the total MB size to be? > > Is their a list of Python Modules that need to be installed? > > Thanks > Ed
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Understood. I will test this ASAP. -- Thadeus On Wed, Jun 9, 2010 at 11:05 AM, mdipierro wrote: > This is not going to stay, it is just for you to look at. > Consider defining the field as integer and create a trigger using SQL > to autofill this field. > > On Jun 9, 10:52 am, mdipierro wrote: >> well, I am posting in trunk a modifiled sql.py that >> >> allows Field('name','autoincrement') and generates the following code >> for postgresql (only postgresql). Give it a try. >> >> Massimo >> >> On Jun 9, 10:38 am, Thadeus Burgess wrote: >> >> > Postgres >> >> > CREATE TABLE foo ( >> > id integer PRIMARY KEY SERIAL, >> > bar varchar, >> > did integer DEFAULT SERIAL); >> >> > Or... >> >> > CREATE SEQUENCE seq_foo_did START 2; >> >> > CREATE TABLE foo ( >> > id integer PRIMARY KEY SERIAL, >> > bar varchar, >> > did integer DEFAULT nextval('seq_foo_did')); >> >> > SQLite however does not support multiple auto-increment fields >> > unfortunately, so on sqlite it must be done the way of creating >> > another table with a blank field and use its id as a sequence >> > (basically like how postgres does behind the scenes). >> >> > MySQL also supports multiple autonumber fields. >> >> > Having two autonumber fields is an absolute requirement of the system >> > and there is no way around this. Unfortunately I don't have time to >> > work on implementing this in web2py, and I could probably re-write my >> > app in something else faster than it would take me to implement this >> > in the DAL since I am not familiar enough with the DALs internal >> > quirks. >> >> > I can't do anything for at least 3 weeks programming wise, so I won't >> > even be getting around to fixing this issue until then. >> >> > -- >> > Thadeus >> >> > On Wed, Jun 9, 2010 at 9:26 AM, mdipierro wrote: >> > > I am not sure about the postgresql solution. Tell me how you do it in >> > > SQL and i tell you how to do in web2pyese. >> >> > > On Jun 9, 9:01 am, Thadeus Burgess wrote: >> > >> Great. What about sqlite? >> >> > >> -- >> > >> Thadeus >> >> > >> On Wed, Jun 9, 2010 at 8:41 AM, mdipierro >> > >> wrote: >> > >> > In postgresql you get it native: >> >> > >> > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY >> > >> > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) >> >> > >> > On Jun 9, 5:28 am, Thadeus Burgess wrote: >> > >> >> That is the thing, its *almost* the same, but its not a true postgres >> > >> >> sequence. Postgres already has many years of development making sure >> > >> >> their auto number works, why can't I just use that instead of trying >> > >> >> to hack around the limitations of a system? >> >> > >> >> I don't have a choice. I *must* have native support for autonumber, >> > >> >> or >> > >> >> I have to use another system that already allows me to. >> >> > >> >> -- >> > >> >> Thadeus >> >> > >> >> On Tue, Jun 8, 2010 at 10:22 PM, mdipierro >> > >> >> wrote: >> > >> >> > If it were possible to do a SQL insert without the dummy filed this >> > >> >> > almost the same as creating a sequence. web2py can create a table >> > >> >> > without any field but the "id", but I do not do not how to do an >> > >> >> > insert without any field value. >> >> > >> >> > On Jun 8, 8:12 pm, Thadeus Burgess wrote: >> > >> >> >> This *might* work. You are right, it is still horrible... It >> > >> >> >> might be >> > >> >> >> *effectively* accomplishing the same thing that sequences do on >> > >> >> >> PostgreSQL, however I still wouldn't use it in production as it >> > >> >> >> feels >> > >> >> >> "hacky". I already have to re-design this table, so I might as >> > >> >> >> well do >> > >> >> >> it 100% right. >> >> > >> >> >> I never expected the scale of inserts that happened yesterday and >> > >> >> >> today, nor had any proper benchmarking been done previously if it >> > >> >> >> could handle this kind of sudden rush of traffic. >> >> > >> >> >> -- >> > >> >> >> Thadeus >> >> > >> >> >> On Tue, Jun 8, 2010 at 4:36 PM, mdipierro >> > >> >> >> wrote: >> > >> >> >> > I know this horrible but it does solve some of the problems... >> >> > >> >> >> > db.define_table('whopper_seq',Field('dummy')) >> >> > >> >> >> > db.define_table('yourtable',... >> > >> >> >> > Field("whopper_id", "integer",compute=lambda r: >> > >> >> >> > db.whopper_seq.insert(dummy=None)) >> > >> >> >> > ...) >> >> > >> >> >> > On Jun 7, 8:29 pm, Thadeus Burgess >> > >> >> >> > wrote: >> > >> >> >> >> I have a problem. >> >> > >> >> >> >> I have this in the database >> >> > >> >> >> >> Field("whopper_id", "string", default=None, unique=True), >> >> > >> >> >> >> The thing with whopper_id is it always stores numbers. Said >> > >> >> >> >> numbers >> > >> >> >> >> are anywhere from 2 to 6. >> >> > >> >> >> >> Also upon entering a new entry, I do the following >> >> > >> >> >> >> last_whopper_id = db(db.table.id > >> > >> >> >> >> 0).select(db.table.whopper_id, >> > >> >> >> >> orderby=~db.table.whopper_id, limit=(0,1)).first().w
Re: [web2py] Minimal Install on Embedded Arm System
On Mon, Jun 7, 2010 at 15:55, ed wrote: > I would like to install web2py with the minimal footprint on an embedded > Arm system. The embedded Arm system already has Python 2.6 installed. > > What files do I need to install for web2py to run? > What do you expect the total MB size to be? > > Is their a list of Python Modules that need to be installed? I've used web2py in my Nokia N800 (ARM-based tablet witch runs Maemo - a Debian-based distro) and it worked out of the box. If you want to save space, delete the applications admin, welcome and examples. -- Álvaro Justen - Turicas http://blog.justen.eng.br/ 21 9898-0141
[web2py] email attachments not seen on Macs
I send email out to 150 club members. No problems with simple emails. However with attachments only PC users can see and download them, while Mac uses cannot even see the attachments. using web2py 1.79.1 on webfaction with webfaction email servers My code (simplified): from gluon.tools import Mail attachments = [Mail.Attachment(path-to-file1, filename=filename1)] mail = Mail( 'smtp.webfaction.com:587', club-email-address, club-email- login) mail.send( to = [club-member-addresses], subject = subject, message = plain-text-message, attachments = attachments, reply_to = my-email-address) I do not change any default mail.settings. If I cannot fix this, my backup option will be to store attachments on our server, and use links to these in the message instead of attachments. Thanks for any suggestions. Bob
[web2py] Re: email attachments not seen on Macs
I do not know how to help about this. This seems more of a problem with smtlib than web2py. If anybody has any more insight about this please let us know. The idea of linking the attachment seems a better way anyway because less load on the email server. On Jun 9, 12:46 pm, Bob_in_Comox wrote: > I send email out to 150 club members. No problems with simple emails. > However with attachments only PC users can see and download them, > while Mac uses cannot even see the attachments. > > using web2py 1.79.1 on webfaction with webfaction email servers > > My code (simplified): > > from gluon.tools import Mail > attachments = [Mail.Attachment(path-to-file1, filename=filename1)] > > mail = Mail( 'smtp.webfaction.com:587', club-email-address, club-email- > login) > mail.send( > to = [club-member-addresses], > subject = subject, > message = plain-text-message, > attachments = attachments, > reply_to = my-email-address) > > I do not change any default mail.settings. > > If I cannot fix this, my backup option will be to store attachments on > our server, and use links to these in the message instead of > attachments. > > Thanks for any suggestions. > > Bob
Re: [web2py] Re: Funny ordering situation...
Nice, I will try number one as I still don't know what the heck a lambda is. Best regards, Jason Brower On Wed, 2010-06-09 at 06:44 -0700, mdipierro wrote: > You have two options: > > 1) perform 4 quesries > > rows=db(query_first).select()+db(query_second).select() > +db(query_third).select()+db(query_others).select(orderby=criteria) > > 2) perform one query and sort them in memoery > > rows=db(...).select().sort(lambda row: yoursortingfunction(row)) > > On Jun 9, 5:38 am, Jason Brower wrote: > > I have a field in my database that I would like to order in a particular > > way. It is string. > > > > Could I order the item by stating what should be first second third, and > > then the rest can be alphabetical. > > In particular. > > db.orders, orderby=db.orders.status > > That way I can get all the "Completed" and the second could be "At the > > door" and so on? > > BR, > > Jason Brower
Re: [web2py] how to do a data picker?
It's in the default welcome example if you want to use it in a form. Or if your using a 'date' in your model you should have a date picker by default. Best Regards, Jason Brower On Wed, 2010-06-09 at 11:10 -0400, Jean Guy wrote: > Hello, > > I have different types of data that must be selected, but a dropbox is > not adequate. A popup that could list in columns my different data > type would be an interesting alternative. Is there exist a plugin that > would do that? I search for the code of calendar date picker included > in web2py ... Where is it? > > Thank you. > > Jonhy
Re: [web2py] how to do a data picker?
I found datepicker it is in /static... I'm still searching for a data picker in which I could list data from differents tables and let them be selected by check box... Jonhy 2010/6/9 Jason Brower > It's in the default welcome example if you want to use it in a form. Or > if your using a 'date' in your model you should have a date picker by > default. > Best Regards, > Jason Brower > > On Wed, 2010-06-09 at 11:10 -0400, Jean Guy wrote: > > Hello, > > > > I have different types of data that must be selected, but a dropbox is > > not adequate. A popup that could list in columns my different data > > type would be an interesting alternative. Is there exist a plugin that > > would do that? I search for the code of calendar date picker included > > in web2py ... Where is it? > > > > Thank you. > > > > Jonhy > > >
[web2py] Re: Funny ordering situation...
>>> a=lambda b: 'c' is the same as >>> def a(b): return 'c' but often you see >>> def f(a): a() >>> f(lambda b: 'c') 'c' this means that within f, a=lambda b:'c' but outside f, the function has no name. The function (lambda) exist only for the purposed to be passed to f. On Jun 9, 1:30 pm, Jason Brower wrote: > Nice, I will try number one as I still don't know what the heck a lambda > is. > Best regards, > Jason Brower > > On Wed, 2010-06-09 at 06:44 -0700, mdipierro wrote: > > You have two options: > > > 1) perform 4 quesries > > > rows=db(query_first).select()+db(query_second).select() > > +db(query_third).select()+db(query_others).select(orderby=criteria) > > > 2) perform one query and sort them in memoery > > > rows=db(...).select().sort(lambda row: yoursortingfunction(row)) > > > On Jun 9, 5:38 am, Jason Brower wrote: > > > I have a field in my database that I would like to order in a particular > > > way. It is string. > > > > Could I order the item by stating what should be first second third, and > > > then the rest can be alphabetical. > > > In particular. > > > db.orders, orderby=db.orders.status > > > That way I can get all the "Completed" and the second could be "At the > > > door" and so on? > > > BR, > > > Jason Brower
[web2py] Weird error when trying to change my avatar image in my profiles... (Using Auth())
When I try to change the avatar image in the profile I get a weird error... This is the actual pickle, as I have no way to read the files while I don't have admin access. Hence why I reported this feature about a month ago. (dp1 S'output' p2 S'' sS'layer' p3 S'Framework' p4 sS'code' p5 S'' sS'traceback' p6 S'Traceback (most recent call last):\n File "/home/interestid/interestid.com/gluon/main.py", line 407, in wsgibase\n session._try_store_on_disk(request, response)\n File "/home/interestid/interestid.com/gluon/globals.py", line 375, in _try_store_on_disk\ncPickle.dump(dict(self), response.session_file)\n File "copy_reg.py", line 69, in _reduce_ex\n raise TypeError, "can\'t pickle %s objects" % base.__name__\nTypeError: can\'t pickle file objects\n' p7 s. Attached is my db.py and this only happened after creating the country feild. Weird? Oh yeah. BR, Jason Brower from datetime import datetime, date, time now = datetime.utcnow() today = date.today() db = SQLDB('sqlite://interestID.db') countries = ['Afghanistan', '\xc3\x85land Islands', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia, Plurinational State of', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Indian Ocean Territory', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Congo, The Democratic Republic of the', 'Cook Islands', 'Costa Rica', "C\xc3\xb4te d'Ivoire", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Malvinas)', 'Faroe Islands', 'Fiji', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern Territories', 'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard Island and McDonald Islands', 'Holy See (Vatican City State)', 'Honduras', 'Hong Kong', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran, Islamic Republic of', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jersey', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', "Korea, Democratic People's Republic of", 'Korea, Republic of', 'Kuwait', 'Kyrgyzstan', "Lao People's Democratic Republic", 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libyan Arab Jamahiriya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macao', 'Macedonia, The Former Yugoslav Republic of', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia, Federated States of', 'Moldova, Republic of', 'Monaco', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands', 'Netherlands Antilles', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palestinian Territory, Occupied', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Pitcairn', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'R\xc3\xa9union', 'Romania', 'Russian Federation', 'Rwanda', 'Saint Barth\xc3\xa9lemy', 'Saint Helena, Ascension and Tristan Da Cunha', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'South Georgia and the South Sandwich Islands', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalba
[web2py] Re: Weird error when trying to change my avatar image in my profiles... (Using Auth())
And if I refresh the page that had the error, resubmitting. It logs me out and puts me at the loggin screen. It also seems to have worked when I am logged in.(Image changed and everything.) Very funky indeed. BR, J On Wed, 2010-06-09 at 22:02 +0300, Jason Brower wrote: > When I try to change the avatar image in the profile I get a weird > error... This is the actual pickle, as I have no way to read the files > while I don't have admin access. Hence why I reported this feature about > a month ago. > (dp1 > S'output' > p2 > S'' > sS'layer' > p3 > S'Framework' > p4 > sS'code' > p5 > S'' > sS'traceback' > p6 > S'Traceback (most recent call last):\n File > "/home/interestid/interestid.com/gluon/main.py", line 407, in wsgibase\n > session._try_store_on_disk(request, response)\n File > "/home/interestid/interestid.com/gluon/globals.py", line 375, in > _try_store_on_disk\ncPickle.dump(dict(self), > response.session_file)\n File "copy_reg.py", line 69, in _reduce_ex\n > raise TypeError, "can\'t pickle %s objects" % base.__name__\nTypeError: > can\'t pickle file objects\n' > p7 > s. > Attached is my db.py and this only happened after creating the country > feild. > Weird? Oh yeah. > BR, > Jason Brower
[web2py] Re: upload file -- lot of file in one directory
Does it make sense to have the value of uploadseparate be any different than 2? It is already 3844 subfolders. On Jun 9, 11:15 am, szimszon wrote: > Already done :) > > On jún. 9, 15:45, mdipierro wrote: > > > please email me this as an attachment. > > > On Jun 9, 6:50 am, szimszon wrote: > > > > Hmm... there are a lot of possibility to separate files into > > > folders... > > > > I typically would have lots of files with the same type... > > > > In the mean time I have a path to separate the uploaded files into > > > subdirectories based on uuid_key's first X character: > > > > cut > > > --- sql.py.orig 2010-06-08 23:45:04.0 +0200 > > > +++ sql.py 2010-06-09 12:50:46.0 +0200 > > > @@ -49,7 +49,7 @@ > > > > table_field = re.compile('[\w_]+\.[\w_]+') > > > oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] > > > +|'')*'\))") > > > -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') > > > +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? > > > P\w+)\.\w+$') > > > regex_cleanup_fn = re.compile('[\'"\s;]+') > > > > # list of drivers will be built on the fly > > > @@ -2600,7 +2600,9 @@ > > > # 'a_field_name' means store in this > > > field in db > > > # False means file content will be > > > discarded. > > > writable=True, readable=True, update=None, > > > authorize=None, > > > - autodelete=False, represent=None, uploadfolder=None) > > > + autodelete=False, represent=None, uploadfolder=None, > > > + uploadseparate=None # upload to separate directories by > > > uuid_keys > > > + # first X character) > > > > to be used as argument of SQLDB.define_table > > > > @@ -2636,6 +2638,7 @@ > > > autodelete=False, > > > represent=None, > > > uploadfolder=None, > > > + uploadseparate=None, > > > compute=None, > > > ): > > > > @@ -2655,6 +2658,7 @@ > > > self.unique = unique > > > self.uploadfield = uploadfield > > > self.uploadfolder = uploadfolder > > > + self.uploadseparate = uploadseparate > > > self.widget = widget > > > self.label = label > > > self.comment = comment > > > @@ -2695,6 +2699,10 @@ > > > path = self.uploadfolder > > > else: > > > path = os.path.join(self._db._folder, '..', > > > 'uploads') > > > + if self.uploadseparate: > > > + path = > > > os.path.join(path,uuid_key[:self.uploadseparate]) > > > + if not os.path.exists(path): > > > + os.mkdir(path) > > > pathfilename = os.path.join(path, newfilename) > > > dest_file = open(pathfilename, 'wb') > > > shutil.copyfileobj(file, dest_file) > > > @@ -2728,6 +2736,9 @@ > > > path = self.uploadfolder > > > else: > > > path = os.path.join(self._db._folder, '..', > > > 'uploads') > > > + if self.uploadseparate: > > > + u = m.group('uuidkey') > > > + path = os.path.join(path,u[:self.uploadseparate]) > > > return (filename, open(os.path.join(path, name), 'rb')) > > > > def formatter(self, value): > > > --- cut --- > > > > I introduced the "uploadseparate" parameter which is either None -- > > > default (backward compatible) or the number of characters of > > > uuid_key... > > > The directory is created automatically and this works with > > > uploadfolder too (uploadfolder/uploadseparate)... > > > > I don't know the name "uploadseparate" is acceptable... or the > > > patch :) There could be a better way... > > > > On jún. 9, 12:40, Jason Brower wrote: > > > > > I wonder if it would be better to sort by type. > > > > /uploads/table_name/field_name/ > > > > Working with those images/files should be done from a database don't you > > > > think? When I deal with large amounts of files I use the console. > > > > BR, > > > > Jason Brower > > > > > On Tue, 2010-06-08 at 23:45 -0700, szimszon wrote: > > > > > I wasn't able to continue the thread in > > > > > http://groups.google.com/group/web2py/browse_frm/thread/a81248fec1dce... > > > > > > So... > > > > > > I imagine that I would have lots of files say some 10 000 or more. :) > > > > > I think with ext3/ext2... filesystems so many files in one directory > > > > > is a mess. > > > > > > Is there absoute out of question to have upload/download to handle > > > > > this issue in trunk? > > > > > > I think of some kind of directory structure like one directory (say > > > > > upload/0) has X number of files then the new one (upload/1) is created > > > > > and the new files are stored in it... > > > > > ...and download could handle it out of the box. > > > > > > Or the generated filenames first or first two character is the > > > > > directory name under uploa
Re: [web2py] Re: Inserting data with foreign keys not from a form
Sorry to bump my own message but is there a better way to handle this? On Jun 4, 2010 8:02 AM, "Doug Warren" wrote: Yes, but the foreign key here is many to one, not one to one. (I guess I should have been more clear: if db(fk_table.id > 0).count() == 0: db.fk_table.insert(name="The Foreign Key") if db(table2.i... db.table2.insert(name = "Some name2", fk_id = fk.id, field2="some value2") db.table2.insert(name = "Some name3", fk_id = fk.id, field2="some value3") db.table2.insert(name = "Some name4", fk_id = fk.id, field2="some value4") On Fri, Jun 4, 2010 at 8:00 AM, mr.freeze wrote: > The insert function will ...
[web2py] Re: Inserting data with foreign keys not from a form
You can rewrite if db(fk_table.id > 0).count() == 0: db.fk_table.insert(name="The Foreign Key") if db(table2.id > 0).count() == 0: fk = db(db.fk_table.name == "The Foreign Key").select()[0] db.table2.insert(name = "Some name", fk_id = fk.id, field2="some value") as fk = db(db.fk_table.name == "The Foreign Key").select(limitby=(0,1)).first() if fk: fk_id=fk.id else: fk_id=db.fk_table.insert(name="The Foreign Key") if db(table2.id > 0).count() == 0: db.table2.insert(name = "Some name", fk_id = fk_id, field2="some value") Is this what you asked? On Jun 4, 9:48 am, Doug Warren wrote: > Hi, > > I defined all my tables in my model file and want to have a few > hundred rows of default foreign keys to maintain 3rd normal form. So > I have things in my code such as: > > if db(fk_table.id > 0).count() == 0: > db.fk_table.insert(name="The Foreign Key") > > if db(table2.id > 0).count() == 0: > fk = db(db.fk_table.name == "The Foreign Key").select()[0] > db.table2.insert(name = "Some name", fk_id = fk.id, field2="some value") > > I'm sure there's a better way to get the id of the foreign key than > doing select()[0].id, but I'm not sure what it is...
[web2py] Re: eliminated repeat values
What version of web2py I need use to try that, I download right now a 1.79.2 version from home site and in that version don't work that modification, and I not permission to download a trunk version. On Jun 9, 12:30 am, mdipierro wrote: > I changed the validator in trunk IS_IN_DB. Now it should be > automatically grouping similar items. Optionally you can specify > IS_IN_DB(...,groupby=...) > Give it a try. > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > Actually, that will not work since it modifies the collection in a > > loop. Try this: > > > def unique_items_widget(f,v): > > inp = SQLFORM.widgets.options.widget(f,v) > > options = inp.elements('option') > > vals = [] > > inp.components = [] > > for opt in options: > > val = opt['_value'] > > if not val in vals: > > vals.append(val) > > inp.append(opt) > > return inp > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > mdpierro is just saying that a simple patch needs to be made to > > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > > def unique_items_widget(f,v): > > > inp = SQLFORM.widgets.options.widget(f,v) > > > vals = [] > > > for k, opt in enumerate(inp): > > > if not opt['_value'] in vals: > > > vals.append(opt['_value']) > > > else: > > > del inp[k] > > > return inp > > > > vul.authors.name.widget = unique_items_widget > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > In what part of the sentence > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > aggregate a groupby option to work, because in that sentence that > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > How I can fixed that > > > > thank for your help > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > Hi I need a form to search, and in that form a field with some > > > > > > database values, I wrote the following > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > that work perfect but my problems is in my database exist several > > > > > > authors with the same name, and that code list all of them, how I > > > > > > show > > > > > > only one of all of the same name. > > > > > > > thank for your help
[web2py] Re: eliminated repeat values
sorry. Trunk version only On Jun 9, 2:36 pm, kike wrote: > What version of web2py I need use to try that, I download right now > a 1.79.2 version from home site and in that version don't work that > modification, and I not permission to download a trunk version. > > On Jun 9, 12:30 am, mdipierro wrote: > > > I changed the validator in trunk IS_IN_DB. Now it should be > > automatically grouping similar items. Optionally you can specify > > IS_IN_DB(...,groupby=...) > > Give it a try. > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > Actually, that will not work since it modifies the collection in a > > > loop. Try this: > > > > def unique_items_widget(f,v): > > > inp = SQLFORM.widgets.options.widget(f,v) > > > options = inp.elements('option') > > > vals = [] > > > inp.components = [] > > > for opt in options: > > > val = opt['_value'] > > > if not val in vals: > > > vals.append(val) > > > inp.append(opt) > > > return inp > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > > > def unique_items_widget(f,v): > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > vals = [] > > > > for k, opt in enumerate(inp): > > > > if not opt['_value'] in vals: > > > > vals.append(opt['_value']) > > > > else: > > > > del inp[k] > > > > return inp > > > > > vul.authors.name.widget = unique_items_widget > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > In what part of the sentence > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > > aggregate a groupby option to work, because in that sentence that > > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > How I can fixed that > > > > > thank for your help > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > > Hi I need a form to search, and in that form a field with some > > > > > > > database values, I wrote the following > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > that work perfect but my problems is in my database exist several > > > > > > > authors with the same name, and that code list all of them, how I > > > > > > > show > > > > > > > only one of all of the same name. > > > > > > > > thank for your help
[web2py] Re: eliminated repeat values
what do you mean "no permission" You do not need permission. On Jun 9, 2:36 pm, kike wrote: > What version of web2py I need use to try that, I download right now > a 1.79.2 version from home site and in that version don't work that > modification, and I not permission to download a trunk version. > > On Jun 9, 12:30 am, mdipierro wrote: > > > I changed the validator in trunk IS_IN_DB. Now it should be > > automatically grouping similar items. Optionally you can specify > > IS_IN_DB(...,groupby=...) > > Give it a try. > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > Actually, that will not work since it modifies the collection in a > > > loop. Try this: > > > > def unique_items_widget(f,v): > > > inp = SQLFORM.widgets.options.widget(f,v) > > > options = inp.elements('option') > > > vals = [] > > > inp.components = [] > > > for opt in options: > > > val = opt['_value'] > > > if not val in vals: > > > vals.append(val) > > > inp.append(opt) > > > return inp > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > > > def unique_items_widget(f,v): > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > vals = [] > > > > for k, opt in enumerate(inp): > > > > if not opt['_value'] in vals: > > > > vals.append(opt['_value']) > > > > else: > > > > del inp[k] > > > > return inp > > > > > vul.authors.name.widget = unique_items_widget > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > In what part of the sentence > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > > aggregate a groupby option to work, because in that sentence that > > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > How I can fixed that > > > > > thank for your help > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > > Hi I need a form to search, and in that form a field with some > > > > > > > database values, I wrote the following > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > that work perfect but my problems is in my database exist several > > > > > > > authors with the same name, and that code list all of them, how I > > > > > > > show > > > > > > > only one of all of the same name. > > > > > > > > thank for your help
[web2py] Re: Weird error when trying to change my avatar image in my profiles... (Using Auth())
This was fixed in 1.79.1 On Jun 9, 2:05 pm, Jason Brower wrote: > And if I refresh the page that had the error, resubmitting. It logs me > out and puts me at the loggin screen. > It also seems to have worked when I am logged in.(Image changed and > everything.) Very funky indeed. > BR, > J > > On Wed, 2010-06-09 at 22:02 +0300, Jason Brower wrote: > > When I try to change the avatar image in the profile I get a weird > > error... This is the actual pickle, as I have no way to read the files > > while I don't have admin access. Hence why I reported this feature about > > a month ago. > > (dp1 > > S'output' > > p2 > > S'' > > sS'layer' > > p3 > > S'Framework' > > p4 > > sS'code' > > p5 > > S'' > > sS'traceback' > > p6 > > S'Traceback (most recent call last):\n File > > "/home/interestid/interestid.com/gluon/main.py", line 407, in wsgibase\n > > session._try_store_on_disk(request, response)\n File > > "/home/interestid/interestid.com/gluon/globals.py", line 375, in > > _try_store_on_disk\n cPickle.dump(dict(self), > > response.session_file)\n File "copy_reg.py", line 69, in _reduce_ex\n > > raise TypeError, "can\'t pickle %s objects" % base.__name__\nTypeError: > > can\'t pickle file objects\n' > > p7 > > s. > > Attached is my db.py and this only happened after creating the country > > feild. > > Weird? Oh yeah. > > BR, > > Jason Brower
[web2py] Re: upload file -- lot of file in one directory
Good question :) Originally I was about to use only the first letter of uuid_key :) and a parameter true or false :) It's the gnome way to doing things. Keep it simple to the endusers... :-D But after that I considered to use the first two characters than came the idea to have an integer parameter to specify the length of characters to use. It's totally sufficient to me to have only two letters. It's up to you :-o I'm thinking about that the use of only that the first or the first two letter could be useful... and in the perspective of web2py you could hardcode the two... Has somebody an opinion about it? On jún. 9, 21:07, mdipierro wrote: > Does it make sense to have the value of uploadseparate be any > different than 2? It is already 3844 subfolders. > > On Jun 9, 11:15 am, szimszon wrote: > > > Already done :) > > > On jún. 9, 15:45, mdipierro wrote: > > > > please email me this as an attachment. > > > > On Jun 9, 6:50 am, szimszon wrote: > > > > > Hmm... there are a lot of possibility to separate files into > > > > folders... > > > > > I typically would have lots of files with the same type... > > > > > In the mean time I have a path to separate the uploaded files into > > > > subdirectories based on uuid_key's first X character: > > > > > cut > > > > --- sql.py.orig 2010-06-08 23:45:04.0 +0200 > > > > +++ sql.py 2010-06-09 12:50:46.0 +0200 > > > > @@ -49,7 +49,7 @@ > > > > > table_field = re.compile('[\w_]+\.[\w_]+') > > > > oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] > > > > +|'')*'\))") > > > > -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') > > > > +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? > > > > P\w+)\.\w+$') > > > > regex_cleanup_fn = re.compile('[\'"\s;]+') > > > > > # list of drivers will be built on the fly > > > > @@ -2600,7 +2600,9 @@ > > > > # 'a_field_name' means store in this > > > > field in db > > > > # False means file content will be > > > > discarded. > > > > writable=True, readable=True, update=None, > > > > authorize=None, > > > > - autodelete=False, represent=None, uploadfolder=None) > > > > + autodelete=False, represent=None, uploadfolder=None, > > > > + uploadseparate=None # upload to separate directories by > > > > uuid_keys > > > > + # first X character) > > > > > to be used as argument of SQLDB.define_table > > > > > @@ -2636,6 +2638,7 @@ > > > > autodelete=False, > > > > represent=None, > > > > uploadfolder=None, > > > > + uploadseparate=None, > > > > compute=None, > > > > ): > > > > > @@ -2655,6 +2658,7 @@ > > > > self.unique = unique > > > > self.uploadfield = uploadfield > > > > self.uploadfolder = uploadfolder > > > > + self.uploadseparate = uploadseparate > > > > self.widget = widget > > > > self.label = label > > > > self.comment = comment > > > > @@ -2695,6 +2699,10 @@ > > > > path = self.uploadfolder > > > > else: > > > > path = os.path.join(self._db._folder, '..', > > > > 'uploads') > > > > + if self.uploadseparate: > > > > + path = > > > > os.path.join(path,uuid_key[:self.uploadseparate]) > > > > + if not os.path.exists(path): > > > > + os.mkdir(path) > > > > pathfilename = os.path.join(path, newfilename) > > > > dest_file = open(pathfilename, 'wb') > > > > shutil.copyfileobj(file, dest_file) > > > > @@ -2728,6 +2736,9 @@ > > > > path = self.uploadfolder > > > > else: > > > > path = os.path.join(self._db._folder, '..', > > > > 'uploads') > > > > + if self.uploadseparate: > > > > + u = m.group('uuidkey') > > > > + path = os.path.join(path,u[:self.uploadseparate]) > > > > return (filename, open(os.path.join(path, name), 'rb')) > > > > > def formatter(self, value): > > > > --- cut --- > > > > > I introduced the "uploadseparate" parameter which is either None -- > > > > default (backward compatible) or the number of characters of > > > > uuid_key... > > > > The directory is created automatically and this works with > > > > uploadfolder too (uploadfolder/uploadseparate)... > > > > > I don't know the name "uploadseparate" is acceptable... or the > > > > patch :) There could be a better way... > > > > > On jún. 9, 12:40, Jason Brower wrote: > > > > > > I wonder if it would be better to sort by type. > > > > > /uploads/table_name/field_name/ > > > > > Working with those images/files should be done from a database don't > > > > > you > > > > > think? When I deal with large amounts of files I use the console. > > > > > BR, > > > > > Jason Brower > > > > > > On Tue, 2010-06-08 at
[web2py] Re: eliminated repeat values
let my explain, in the address http://web2py.com/examples/default/download in the trunk part are two link, the first mercurial repository in the section http://code.google.com/p/web2py/downloads/list they show me the error 403 Forbidden and tell me my client not have permission to get that url, and in the second link Baazar repository I cant find the download I need. On Jun 9, 3:54 pm, mdipierro wrote: > what do you mean "no permission" You do not need permission. > > On Jun 9, 2:36 pm, kike wrote: > > > What version of web2py I need use to try that, I download right now > > a 1.79.2 version from home site and in that version don't work that > > modification, and I not permission to download a trunk version. > > > On Jun 9, 12:30 am, mdipierro wrote: > > > > I changed the validator in trunk IS_IN_DB. Now it should be > > > automatically grouping similar items. Optionally you can specify > > > IS_IN_DB(...,groupby=...) > > > Give it a try. > > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > > Actually, that will not work since it modifies the collection in a > > > > loop. Try this: > > > > > def unique_items_widget(f,v): > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > options = inp.elements('option') > > > > vals = [] > > > > inp.components = [] > > > > for opt in options: > > > > val = opt['_value'] > > > > if not val in vals: > > > > vals.append(val) > > > > inp.append(opt) > > > > return inp > > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > > > > def unique_items_widget(f,v): > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > vals = [] > > > > > for k, opt in enumerate(inp): > > > > > if not opt['_value'] in vals: > > > > > vals.append(opt['_value']) > > > > > else: > > > > > del inp[k] > > > > > return inp > > > > > > vul.authors.name.widget = unique_items_widget > > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > > In what part of the sentence > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > > > aggregate a groupby option to work, because in that sentence that > > > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > > How I can fixed that > > > > > > thank for your help > > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > > > Hi I need a form to search, and in that form a field with some > > > > > > > > database values, I wrote the following > > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > > that work perfect but my problems is in my database exist > > > > > > > > several > > > > > > > > authors with the same name, and that code list all of them, how > > > > > > > > I show > > > > > > > > only one of all of the same name. > > > > > > > > > thank for your help
[web2py] Re: upload file -- lot of file in one directory
I suggest a subfolder for every table.field and one for every combinations of the first 2 chars? The simpler the better. On Jun 9, 3:01 pm, szimszon wrote: > Good question :) > > Originally I was about to use only the first letter of uuid_key :) and > a parameter true or false :) > It's the gnome way to doing things. Keep it simple to the > endusers... :-D > > But after that I considered to use the first two characters than came > the idea to have an integer parameter to specify the length of > characters to use. > > It's totally sufficient to me to have only two letters. It's up to > you :-o > > I'm thinking about that the use of only that the first or the first > two letter could be useful... and in the perspective of web2py you > could hardcode the two... > > Has somebody an opinion about it? > > On jún. 9, 21:07, mdipierro wrote: > > > Does it make sense to have the value of uploadseparate be any > > different than 2? It is already 3844 subfolders. > > > On Jun 9, 11:15 am, szimszon wrote: > > > > Already done :) > > > > On jún. 9, 15:45, mdipierro wrote: > > > > > please email me this as an attachment. > > > > > On Jun 9, 6:50 am, szimszon wrote: > > > > > > Hmm... there are a lot of possibility to separate files into > > > > > folders... > > > > > > I typically would have lots of files with the same type... > > > > > > In the mean time I have a path to separate the uploaded files into > > > > > subdirectories based on uuid_key's first X character: > > > > > > cut > > > > > --- sql.py.orig 2010-06-08 23:45:04.0 +0200 > > > > > +++ sql.py 2010-06-09 12:50:46.0 +0200 > > > > > @@ -49,7 +49,7 @@ > > > > > > table_field = re.compile('[\w_]+\.[\w_]+') > > > > > oracle_fix = re.compile("[^']*('[^']*'[^']*)*\:(?PCLOB\('([^'] > > > > > +|'')*'\))") > > > > > -regex_content = re.compile('([\w\-]+\.){3}(?P\w+)\.\w+$') > > > > > +regex_content = re.compile('([\w\-]+\.){2}(?P[\w\-]+)\.(? > > > > > P\w+)\.\w+$') > > > > > regex_cleanup_fn = re.compile('[\'"\s;]+') > > > > > > # list of drivers will be built on the fly > > > > > @@ -2600,7 +2600,9 @@ > > > > > # 'a_field_name' means store in this > > > > > field in db > > > > > # False means file content will be > > > > > discarded. > > > > > writable=True, readable=True, update=None, > > > > > authorize=None, > > > > > - autodelete=False, represent=None, uploadfolder=None) > > > > > + autodelete=False, represent=None, uploadfolder=None, > > > > > + uploadseparate=None # upload to separate directories by > > > > > uuid_keys > > > > > + # first X character) > > > > > > to be used as argument of SQLDB.define_table > > > > > > @@ -2636,6 +2638,7 @@ > > > > > autodelete=False, > > > > > represent=None, > > > > > uploadfolder=None, > > > > > + uploadseparate=None, > > > > > compute=None, > > > > > ): > > > > > > @@ -2655,6 +2658,7 @@ > > > > > self.unique = unique > > > > > self.uploadfield = uploadfield > > > > > self.uploadfolder = uploadfolder > > > > > + self.uploadseparate = uploadseparate > > > > > self.widget = widget > > > > > self.label = label > > > > > self.comment = comment > > > > > @@ -2695,6 +2699,10 @@ > > > > > path = self.uploadfolder > > > > > else: > > > > > path = os.path.join(self._db._folder, '..', > > > > > 'uploads') > > > > > + if self.uploadseparate: > > > > > + path = > > > > > os.path.join(path,uuid_key[:self.uploadseparate]) > > > > > + if not os.path.exists(path): > > > > > + os.mkdir(path) > > > > > pathfilename = os.path.join(path, newfilename) > > > > > dest_file = open(pathfilename, 'wb') > > > > > shutil.copyfileobj(file, dest_file) > > > > > @@ -2728,6 +2736,9 @@ > > > > > path = self.uploadfolder > > > > > else: > > > > > path = os.path.join(self._db._folder, '..', > > > > > 'uploads') > > > > > + if self.uploadseparate: > > > > > + u = m.group('uuidkey') > > > > > + path = os.path.join(path,u[:self.uploadseparate]) > > > > > return (filename, open(os.path.join(path, name), 'rb')) > > > > > > def formatter(self, value): > > > > > --- cut --- > > > > > > I introduced the "uploadseparate" parameter which is either None -- > > > > > default (backward compatible) or the number of characters of > > > > > uuid_key... > > > > > The directory is created automatically and this works with > > > > > uploadfolder too (uploadfolder/uploadseparate)... > > > > > > I don't know the name "uploadseparate" is acceptable... or the > > > > > patch :) There could be a better way... > > > > > > On jún. 9, 12:40, J
[web2py] Re: eliminated repeat values
you should just type: hg clone https://web2py.googlecode.com/hg/ web2py in your shell and it will donwload a copy On Jun 9, 3:08 pm, kike wrote: > let my explain, in the addresshttp://web2py.com/examples/default/download > in the trunk part are two link, the first mercurial repository in the > sectionhttp://code.google.com/p/web2py/downloads/listthey show me > the error 403 Forbidden and tell me my client not have permission to > get that url, and in the second link Baazar repository I cant find the > download I need. > > On Jun 9, 3:54 pm, mdipierro wrote: > > > what do you mean "no permission" You do not need permission. > > > On Jun 9, 2:36 pm, kike wrote: > > > > What version of web2py I need use to try that, I download right now > > > a 1.79.2 version from home site and in that version don't work that > > > modification, and I not permission to download a trunk version. > > > > On Jun 9, 12:30 am, mdipierro wrote: > > > > > I changed the validator in trunk IS_IN_DB. Now it should be > > > > automatically grouping similar items. Optionally you can specify > > > > IS_IN_DB(...,groupby=...) > > > > Give it a try. > > > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > > > Actually, that will not work since it modifies the collection in a > > > > > loop. Try this: > > > > > > def unique_items_widget(f,v): > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > options = inp.elements('option') > > > > > vals = [] > > > > > inp.components = [] > > > > > for opt in options: > > > > > val = opt['_value'] > > > > > if not val in vals: > > > > > vals.append(val) > > > > > inp.append(opt) > > > > > return inp > > > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > > > > > def unique_items_widget(f,v): > > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > > vals = [] > > > > > > for k, opt in enumerate(inp): > > > > > > if not opt['_value'] in vals: > > > > > > vals.append(opt['_value']) > > > > > > else: > > > > > > del inp[k] > > > > > > return inp > > > > > > > vul.authors.name.widget = unique_items_widget > > > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > > > In what part of the sentence > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > > > > aggregate a groupby option to work, because in that sentence that > > > > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > > > How I can fixed that > > > > > > > thank for your help > > > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > > > > Hi I need a form to search, and in that form a field with some > > > > > > > > > database values, I wrote the following > > > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > > > that work perfect but my problems is in my database exist > > > > > > > > > several > > > > > > > > > authors with the same name, and that code list all of them, > > > > > > > > > how I show > > > > > > > > > only one of all of the same name. > > > > > > > > > > thank for your help
[web2py] flot related help
Hello: I am trying to use flot to draw a graph by reading the data from the database I am stuck, need an example
Re: [web2py] Re: Inserting data with foreign keys not from a form
Yep! Thank you. I knew there would be a more idiomatic way of writing it, just wasn't sure what it would be. On Wed, Jun 9, 2010 at 12:27 PM, mdipierro wrote: > You can rewrite > > if db(fk_table.id > 0).count() == 0: > db.fk_table.insert(name="The Foreign Key") > if db(table2.id > 0).count() == 0: > fk = db(db.fk_table.name == "The Foreign Key").select()[0] > db.table2.insert(name = "Some name", fk_id = fk.id, field2="some > value") > > as > > fk = db(db.fk_table.name == "The Foreign > Key").select(limitby=(0,1)).first() > if fk: > fk_id=fk.id > else: > fk_id=db.fk_table.insert(name="The Foreign Key") > if db(table2.id > 0).count() == 0: > db.table2.insert(name = "Some name", fk_id = fk_id, field2="some > value") > > Is this what you asked? > > On Jun 4, 9:48 am, Doug Warren wrote: >> Hi, >> >> I defined all my tables in my model file and want to have a few >> hundred rows of default foreign keys to maintain 3rd normal form. So >> I have things in my code such as: >> >> if db(fk_table.id > 0).count() == 0: >> db.fk_table.insert(name="The Foreign Key") >> >> if db(table2.id > 0).count() == 0: >> fk = db(db.fk_table.name == "The Foreign Key").select()[0] >> db.table2.insert(name = "Some name", fk_id = fk.id, field2="some value") >> >> I'm sure there's a better way to get the id of the foreign key than >> doing select()[0].id, but I'm not sure what it is...
[web2py] bzr cleanup
Fran proposed cleaning up the bzr branch since it is getting slow. the easiest way to do it is bu deleting all previous revisions and their history. Any strong objection? Massimo
[web2py] Re: flot related help
Although this does not uses flot, it can give an idea. http://web2py.com/appliances/default/show/12 On Jun 9, 3:20 pm, dbb wrote: > Hello: > I am trying to use flot to draw a graph by reading the data from the > database > I am stuck, need an example
[web2py] Re: eliminated repeat values
the same problems I not permission. and now what On Jun 9, 4:12 pm, mdipierro wrote: > you should just type: > > hg clonehttps://web2py.googlecode.com/hg/web2py > > in your shell and it will donwload a copy > > On Jun 9, 3:08 pm, kike wrote: > > > let my explain, in the addresshttp://web2py.com/examples/default/download > > in the trunk part are two link, the first mercurial repository in the > > sectionhttp://code.google.com/p/web2py/downloads/listtheyshow me > > the error 403 Forbidden and tell me my client not have permission to > > get that url, and in the second link Baazar repository I cant find the > > download I need. > > > On Jun 9, 3:54 pm, mdipierro wrote: > > > > what do you mean "no permission" You do not need permission. > > > > On Jun 9, 2:36 pm, kike wrote: > > > > > What version of web2py I need use to try that, I download right now > > > > a 1.79.2 version from home site and in that version don't work that > > > > modification, and I not permission to download a trunk version. > > > > > On Jun 9, 12:30 am, mdipierro wrote: > > > > > > I changed the validator in trunk IS_IN_DB. Now it should be > > > > > automatically grouping similar items. Optionally you can specify > > > > > IS_IN_DB(...,groupby=...) > > > > > Give it a try. > > > > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > > > > Actually, that will not work since it modifies the collection in a > > > > > > loop. Try this: > > > > > > > def unique_items_widget(f,v): > > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > > options = inp.elements('option') > > > > > > vals = [] > > > > > > inp.components = [] > > > > > > for opt in options: > > > > > > val = opt['_value'] > > > > > > if not val in vals: > > > > > > vals.append(val) > > > > > > inp.append(opt) > > > > > > return inp > > > > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > > > > IS_IN_DB. Until then, you can create a widget to remove > > > > > > > duplicates: > > > > > > > > def unique_items_widget(f,v): > > > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > > > vals = [] > > > > > > > for k, opt in enumerate(inp): > > > > > > > if not opt['_value'] in vals: > > > > > > > vals.append(opt['_value']) > > > > > > > else: > > > > > > > del inp[k] > > > > > > > return inp > > > > > > > > vul.authors.name.widget = unique_items_widget > > > > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > > > > In what part of the sentence > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > > > > > > aggregate a groupby option to work, because in that sentence > > > > > > > > that > > > > > > > > parameter is incorrect and if I aggregate a groupby parameter in > > > > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > > > > How I can fixed that > > > > > > > > thank for your help > > > > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > > > > On Jun 7, 5:16 pm, kike wrote: > > > > > > > > > > > Hi I need a form to search, and in that form a field with > > > > > > > > > > some > > > > > > > > > > database values, I wrote the following > > > > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > > > > that work perfect but my problems is in my database exist > > > > > > > > > > several > > > > > > > > > > authors with the same name, and that code list all of them, > > > > > > > > > > how I show > > > > > > > > > > only one of all of the same name. > > > > > > > > > > > thank for your help
[web2py] Re: Keep the instance of a class during the session
As I mentioned, with the object caching works well. When I create the object you pass as argument the db. The problem I have is that when I save something in the database fails me because the base is closed. ... File "/usr/home/jose/web2py/applications/py_ccu/modules/ incidencias.py", line 124, in migrar_archivo self._db(qry_localidad).delete() File "/usr/home/jose/web2py/gluon/sql.py", line 3263, in delete self._db._execute(query) File "/usr/home/jose/web2py/gluon/sql.py", line 899, in self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: Cannot operate on a closed database. Not because it closes, as in the __init__ run multiple queries and I have no problems. It reminds me error when I use the web shell. Will be about the same? Jose
[web2py] Re: eliminated repeat values
I forget mention I'm cuban, and in my country I not access to googlecode On Jun 9, 4:37 pm, kike wrote: > the same problems I not permission. and now what > > On Jun 9, 4:12 pm, mdipierro wrote: > > > you should just type: > > > hg clonehttps://web2py.googlecode.com/hg/web2py > > > in your shell and it will donwload a copy > > > On Jun 9, 3:08 pm, kike wrote: > > > > let my explain, in the addresshttp://web2py.com/examples/default/download > > > in the trunk part are two link, the first mercurial repository in the > > > sectionhttp://code.google.com/p/web2py/downloads/listtheyshowme > > > the error 403 Forbidden and tell me my client not have permission to > > > get that url, and in the second link Baazar repository I cant find the > > > download I need. > > > > On Jun 9, 3:54 pm, mdipierro wrote: > > > > > what do you mean "no permission" You do not need permission. > > > > > On Jun 9, 2:36 pm, kike wrote: > > > > > > What version of web2py I need use to try that, I download right now > > > > > a 1.79.2 version from home site and in that version don't work that > > > > > modification, and I not permission to download a trunk version. > > > > > > On Jun 9, 12:30 am, mdipierro wrote: > > > > > > > I changed the validator in trunk IS_IN_DB. Now it should be > > > > > > automatically grouping similar items. Optionally you can specify > > > > > > IS_IN_DB(...,groupby=...) > > > > > > Give it a try. > > > > > > > On Jun 8, 11:07 pm, "mr.freeze" wrote: > > > > > > > > Actually, that will not work since it modifies the collection in a > > > > > > > loop. Try this: > > > > > > > > def unique_items_widget(f,v): > > > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > > > options = inp.elements('option') > > > > > > > vals = [] > > > > > > > inp.components = [] > > > > > > > for opt in options: > > > > > > > val = opt['_value'] > > > > > > > if not val in vals: > > > > > > > vals.append(val) > > > > > > > inp.append(opt) > > > > > > > return inp > > > > > > > > On Jun 8, 10:18 pm, "mr.freeze" wrote: > > > > > > > > > mdpierro is just saying that a simple patch needs to be made to > > > > > > > > IS_IN_DB. Until then, you can create a widget to remove > > > > > > > > duplicates: > > > > > > > > > def unique_items_widget(f,v): > > > > > > > > inp = SQLFORM.widgets.options.widget(f,v) > > > > > > > > vals = [] > > > > > > > > for k, opt in enumerate(inp): > > > > > > > > if not opt['_value'] in vals: > > > > > > > > vals.append(opt['_value']) > > > > > > > > else: > > > > > > > > del inp[k] > > > > > > > > return inp > > > > > > > > > vul.authors.name.widget = unique_items_widget > > > > > > > > > On Jun 8, 8:49 pm, kike wrote: > > > > > > > > > > In what part of the sentence > > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I > > > > > > > > > need > > > > > > > > > aggregate a groupby option to work, because in that sentence > > > > > > > > > that > > > > > > > > > parameter is incorrect and if I aggregate a groupby parameter > > > > > > > > > in > > > > > > > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > > > > > > > How I can fixed that > > > > > > > > > thank for your help > > > > > > > > > > On Jun 8, 1:39 am, mdipierro wrote: > > > > > > > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > > > > > > > On Jun 7, 5:16 pm, kike > > > > > > > > > > wrote: > > > > > > > > > > > > Hi I need a form to search, and in that form a field with > > > > > > > > > > > some > > > > > > > > > > > database values, I wrote the following > > > > > > > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > > > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > > > > > > > that work perfect but my problems is in my database exist > > > > > > > > > > > several > > > > > > > > > > > authors with the same name, and that code list all of > > > > > > > > > > > them, how I show > > > > > > > > > > > only one of all of the same name. > > > > > > > > > > > > thank for your help
Re: [web2py] bzr cleanup
On Wed, Jun 9, 2010 at 17:36, mdipierro wrote: > Fran proposed cleaning up the bzr branch since it is getting slow. the > easiest way to do it is bu deleting all previous revisions and their > history. Any strong objection? I think we should maintain only mercurial. -- Álvaro Justen - Turicas http://blog.justen.eng.br/ 21 9898-0141
[web2py] Separating models into their own files
Hi, I am trying to create an orm setup like in ruby on rails with the DAL. I have a user, post, and tag model. A user has many posts. A tag belongs to a user. A post has and belongs to many tags. A tag has and belongs to many posts. I have 4 separate files in my models folder: db.py, user.py, post.py, and tag.py db.py contains the db connection and mail configurations. The respective model files define the table structure and have a class named after the model to implement virtual fields. I noticed that defining the tables with relationships in the separate files does not work properly. The model files would load which appears to be in alphabetical order. So, my db.py would load first and then post.py which fails. post.py fails to recognize the table definition in user.py, so it cannot define the belongs to relationship. Is their anyway to setup a model file to import all the other models without the hassle of file load order and possibly import order which rails does implicitly?
[web2py] Re: Separating models into their own files
No. This the main issue with web2py design. This is the price we pay for not having imports of models. On Jun 9, 4:21 pm, Binh wrote: > Hi, > > I am trying to create an orm setup like in ruby on rails with the DAL. > I have a user, post, and tag model. > A user has many posts. > A tag belongs to a user. > A post has and belongs to many tags. > A tag has and belongs to many posts. > > I have 4 separate files in my models folder: db.py, user.py, post.py, > and tag.py > db.py contains the db connection and mail configurations. > The respective model files define the table structure and have a class > named after the model to implement virtual fields. > > I noticed that defining the tables with relationships in the separate > files does not work properly. > The model files would load which appears to be in alphabetical order. > So, my db.py would load first and then post.py which fails. > post.py fails to recognize the table definition in user.py, so it > cannot define the belongs to relationship. > > Is their anyway to setup a model file to import all the other models > without the hassle of file load order and possibly import order which > rails does implicitly?
[web2py] Nice libraries for UI design inspiration (or web2py integration)
I would share some pretty libraries. I like them a lot and maybe you'll like them elRTE :Open source WYSIWYG editor for website Demo: http://elrte.ru/en/elrte/demo Web: http://elrte.ru/en elFinder: File manager for website (Finder osx style) Demo: http://elrte.ru/en/elfinder/demo Web: http://elrte.ru/en/elfinder Online ButtonMaker: http://css-tricks.com/examples/ButtonMaker/ I hope you like them
[web2py] Re: email attachments not seen on Macs
There is no reason you need to use webfaction's mail servers if you are hosted on webfaction. try connecting to a different mail server, and run some tests and see what happens. On Jun 9, 12:49 pm, mdipierro wrote: > I do not know how to help about this. This seems more of a problem > with smtlib than web2py. If anybody has any more insight about this > please let us know. > > The idea of linking the attachment seems a better way anyway because > less load on the email server. > > On Jun 9, 12:46 pm, Bob_in_Comox wrote: > > > > > I send email out to 150 club members. No problems with simple emails. > > However with attachments only PC users can see and download them, > > while Mac uses cannot even see the attachments. > > > using web2py 1.79.1 on webfaction with webfaction email servers > > > My code (simplified): > > > from gluon.tools import Mail > > attachments = [Mail.Attachment(path-to-file1, filename=filename1)] > > > mail = Mail( 'smtp.webfaction.com:587', club-email-address, club-email- > > login) > > mail.send( > > to = [club-member-addresses], > > subject = subject, > > message = plain-text-message, > > attachments = attachments, > > reply_to = my-email-address) > > > I do not change any default mail.settings. > > > If I cannot fix this, my backup option will be to store attachments on > > our server, and use links to these in the message instead of > > attachments. > > > Thanks for any suggestions. > > > Bob
[web2py] Re: Nice libraries for UI design inspiration (or web2py integration)
really nice. Perhaps it is a time for an admin^2 On Jun 9, 4:49 pm, GoldenTiger wrote: > I would share some pretty libraries. > I like them a lot and maybe you'll like them > > elRTE :Open source WYSIWYG editor for website > Demo:http://elrte.ru/en/elrte/demo > Web:http://elrte.ru/en > > elFinder: File manager for website (Finder osx style) > Demo:http://elrte.ru/en/elfinder/demo > Web:http://elrte.ru/en/elfinder > > Online ButtonMaker:http://css-tricks.com/examples/ButtonMaker/ > > I hope you like them
[web2py] Re: Nice libraries for UI design inspiration (or web2py integration)
That is exactly what I was thinking :) On 10 jun, 00:07, mdipierro wrote: > really nice. Perhaps it is a time for an admin^2 > > On Jun 9, 4:49 pm, GoldenTiger wrote: > > > I would share some pretty libraries. > > I like them a lot and maybe you'll like them > > > elRTE :Open source WYSIWYG editor for website > > Demo:http://elrte.ru/en/elrte/demo > > Web:http://elrte.ru/en > > > elFinder: File manager for website (Finder osx style) > > Demo:http://elrte.ru/en/elfinder/demo > > Web:http://elrte.ru/en/elfinder > > > Online ButtonMaker:http://css-tricks.com/examples/ButtonMaker/ > > > I hope you like them
[web2py] Re: Best CSS framework for web2py
At http://www.ez-css.org/rapid_prototyping , code of Module3A and Module3B are identical, but looks different. I don't understand it. Any help please? On 9 jun, 17:36, Christopher Steel wrote: > I like ez-css a lot also. It that is very flexible, super fast to > learn and use (no manual required really) and it works great for > creating "flowable" sites as well. > > As a result of this discussion I am going to give the blueprint > typography.css a shot. > > the Blueprint license seems very interesting: > > "Copyright (c) 2007-2009 blueprintcss.org > > The Blueprint CSS Framework is available for use in all personal or > commercial projects, under both the (modified) MIT and the GPL > license. You > may choose the one that fits your project." > > Cheers, > > Chris > > On Jun 8, 4:03 pm, Salvor Hardin wrote: > > > I'm looking for a great CSS framework to use with web2py. > > > Someone in this group mentioned using Blueprint for typography and ez- > > css for layout. > > > I'd like to hear recommendations from web2py users. Which is your > > favorite? > > > If you are unfamiliar with CSS frameworks, check out: > > *http://www.w3avenue.com/2009/04/29/definitive-list-of-css-frameworks-... > > *http://en.wikipedia.org/wiki/CSS_framework > > > Some of them, like Blueprint, have a lot of > > features:http://www.blueprintcss.org/ > > * A CSS reset that eliminates the discrepancies across browsers. > > * A solid grid that can support the most complex of layouts. > > * Typography based on expert principles that predate the web. > > * Form styles for great looking user interfaces. > > * Print styles for making any webpage ready for paper. > > * Plugins for buttons, tabs and sprites. > > * Tools, editors, and templates for every step in your workflow. > > > While others, like ez-css, are very lightweight by comparison. Again, > > I'd love to hear from web2py users about their favorite css > > framework(s).
[web2py] Re: Nice libraries for UI design inspiration (or web2py integration)
If we were to do this, should have a single tree of applications and sub trees for models/views/controllers/etc. (option 1) or should have separate pages for the list of apps and one for the tree structure inside an app (option 2). Actually this would be easy now that I have seen not elRTE and elFinder work. The only thing I am not sure is where to put the additional buttons like: pack this app, bytecode compile, shell, appadmin, etc. I guess some of them (like the shell) could appear as files (executable serverside) but not all of them. Massimo On Jun 9, 5:30 pm, GoldenTiger wrote: > That is exactly what I was thinking :) > > On 10 jun, 00:07, mdipierro wrote: > > > really nice. Perhaps it is a time for an admin^2 > > > On Jun 9, 4:49 pm, GoldenTiger wrote: > > > > I would share some pretty libraries. > > > I like them a lot and maybe you'll like them > > > > elRTE :Open source WYSIWYG editor for website > > > Demo:http://elrte.ru/en/elrte/demo > > > Web:http://elrte.ru/en > > > > elFinder: File manager for website (Finder osx style) > > > Demo:http://elrte.ru/en/elfinder/demo > > > Web:http://elrte.ru/en/elfinder > > > > Online ButtonMaker:http://css-tricks.com/examples/ButtonMaker/ > > > > I hope you like them
[web2py] Re: Minimal Install on Embedded Arm System
Perhaps for embedded system, it could be good using Stackless python . Anyway, I didn't investigate about, so I'm not sure of being a good idea. On 9 jun, 18:50, Álvaro Justen wrote: > On Mon, Jun 7, 2010 at 15:55, ed wrote: > > I would like to install web2py with the minimal footprint on an embedded > > Arm system. The embedded Arm system already has Python 2.6 installed. > > > What files do I need to install for web2py to run? > > What do you expect the total MB size to be? > > > Is their a list of Python Modules that need to be installed? > > I've used web2py in my Nokia N800 (ARM-based tablet witch runs Maemo - > a Debian-based distro) and it worked out of the box. > If you want to save space, delete the applications admin, welcome and > examples. > > -- > Álvaro Justen - Turicas > http://blog.justen.eng.br/ > 21 9898-0141
[web2py] Re: Keep the instance of a class during the session
On 9 jun, 17:38, Jose wrote: > As I mentioned, with the object caching works well. > When I create the object you pass as argument the db. The problem I > have is that when I save something in the database fails me because > the base is closed. > > ... > File "/usr/home/jose/web2py/applications/py_ccu/modules/ > incidencias.py", line 124, in migrar_archivo > self._db(qry_localidad).delete() > File "/usr/home/jose/web2py/gluon/sql.py", line 3263, in delete > self._db._execute(query) > File "/usr/home/jose/web2py/gluon/sql.py", line 899, in > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) > ProgrammingError: Cannot operate on a closed database. > > Not because it closes, as in the __init__ run multiple queries and I > have no problems. > > It reminds me error when I use the web shell. Will be about the same? > > Jose The why is closed, is about creating a new db instance for each request. If so, should discard what I do? Jose
[web2py] web2pyslices update
VPS provider fail. I'm on the hunt for a new provider. I hope to have it back up tomorrow.
Re: [web2py] Re: Best CSS framework for web2py
On Jun 9, 2010, at 5:39 PM, GoldenTiger wrote: > At http://www.ez-css.org/rapid_prototyping , code of Module3A and > Module3B are identical, but looks different. > > I don't understand it. Any help please? The classes are subtly different. The difference is whether column 3, which does not have a width specified, is on the right or in the center.
[web2py] Re: Best CSS framework for web2py
On Jun 9, 5:59 pm, Jonathan Lundell wrote: > On Jun 9, 2010, at 5:39 PM, GoldenTiger wrote: > > > Athttp://www.ez-css.org/rapid_prototyping, code of Module3A and > > Module3B are identical, but looks different. > > > I don't understand it. Any help please? > > The classes are subtly different. The difference is whether column 3, which > does not have a width specified, is on the right or in the center. The "blue" are fixed width; the "white" is variable; The other difference is in 3A - there are two ez-fl (float left) sections; in 3B the second fixed width is ez-fr class (float right) --- there is similarly one other class difference (where the negative margin tweak is located).
[web2py] Re: Nice libraries for UI design inspiration (or web2py integration)
Well, maybe both of admin versions could start working together, or testing them as independient apps... but I don't know admin internally, so I can't be very usefull by now On 10 jun, 00:43, mdipierro wrote: > If we were to do this, should have a single tree of applications and > sub trees for models/views/controllers/etc. (option 1) or should have > separate pages for the list of apps and one for the tree structure > inside an app (option 2). > > Actually this would be easy now that I have seen not elRTE and > elFinder work. The only thing I am not sure is where to put the > additional buttons like: pack this app, bytecode compile, shell, > appadmin, etc. I guess some of them (like the shell) could appear as > files (executable serverside) but not all of them. > > Massimo > > On Jun 9, 5:30 pm, GoldenTiger wrote: > > > That is exactly what I was thinking :) > > > On 10 jun, 00:07, mdipierro wrote: > > > > really nice. Perhaps it is a time for an admin^2 > > > > On Jun 9, 4:49 pm, GoldenTiger wrote: > > > > > I would share some pretty libraries. > > > > I like them a lot and maybe you'll like them > > > > > elRTE :Open source WYSIWYG editor for website > > > > Demo:http://elrte.ru/en/elrte/demo > > > > Web:http://elrte.ru/en > > > > > elFinder: File manager for website (Finder osx style) > > > > Demo:http://elrte.ru/en/elfinder/demo > > > > Web:http://elrte.ru/en/elfinder > > > > > Online ButtonMaker:http://css-tricks.com/examples/ButtonMaker/ > > > > > I hope you like them
[web2py] Re: Best CSS framework for web2py
Thanks a lot, now I understand it :) On 10 jun, 01:06, Yarko Tymciurak wrote: > On Jun 9, 5:59 pm, Jonathan Lundell wrote: > > > On Jun 9, 2010, at 5:39 PM, GoldenTiger wrote: > > > > Athttp://www.ez-css.org/rapid_prototyping, code of Module3A and > > > Module3B are identical, but looks different. > > > > I don't understand it. Any help please? > > > The classes are subtly different. The difference is whether column 3, which > > does not have a width specified, is on the right or in the center. > > The "blue" are fixed width; the "white" is variable; > > The other difference is in 3A - there are two ez-fl (float left) > sections; in 3B the second fixed width is ez-fr class (float > right) --- there is similarly one other class difference (where the > negative margin tweak is located).
Re: [web2py] Re: Keep the instance of a class during the session
I ran into this a few nights ago, and if I wasn't about to leave on a vacation I'd try some prototype code for it, but from what I can tell at the end of any request all open database connections are marked to be closed (Except for those needed to keep the connection pool up to it's proper size.) What I'd propose is as an extension you can pass a dontclose flag to the constructor of the DAL that if set will bypass this keep alive. The downside is for my intended use, the user of that DAL would also need to manage the lifetime of the transaction. However, since the code exists in a module that may have a lifetime beyond that of a single request, that shouldn't be considered a bad thing. Are there any thoughts on adding an optional argument to not call connection.close() in close_all_instances if some property is set? (And yes I know about custom_commit / custom_rollback) On Wed, Jun 9, 2010 at 1:38 PM, Jose wrote: > > As I mentioned, with the object caching works well. > When I create the object you pass as argument the db. The problem I > have is that when I save something in the database fails me because > the base is closed. > > ... > File "/usr/home/jose/web2py/applications/py_ccu/modules/ > incidencias.py", line 124, in migrar_archivo > self._db(qry_localidad).delete() > File "/usr/home/jose/web2py/gluon/sql.py", line 3263, in delete > self._db._execute(query) > File "/usr/home/jose/web2py/gluon/sql.py", line 899, in > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) > ProgrammingError: Cannot operate on a closed database. > > Not because it closes, as in the __init__ run multiple queries and I > have no problems. > > It reminds me error when I use the web shell. Will be about the same? > > Jose
[web2py] Re: disable label
last time i was wrestling with the forms i noticed that everything has nice class names - use css to put no-wrap on the label class. (firebug plugin to firefox really helps with inspecting generated HTML). also i think i read something about being able to specify table or div based layouts for forms (a recent web2py addition that i have not made use of yet). cfh On Jun 8, 11:22 pm, annet wrote: > Thanks for providing me with this solution, problem solved. > > I have another problem with this form. In the first column some of the > field names are split up, like: > > Sub-dossiernumber * > : > > Is there a way to solve this? > > Kind regards, > > Annet.
[web2py] Re: Best CSS framework for web2py
One more question please About fieldset, I can read: "This solution is a hack as it relies on fieldset to escape caveats related to DIVs. It should not be used for production" Which problems could be found if used for production? On 10 jun, 01:17, GoldenTiger wrote: > Thanks a lot, now I understand it :) > > On 10 jun, 01:06, Yarko Tymciurak wrote: > > > On Jun 9, 5:59 pm, Jonathan Lundell wrote: > > > > On Jun 9, 2010, at 5:39 PM, GoldenTiger wrote: > > > > > Athttp://www.ez-css.org/rapid_prototyping, code of Module3A and > > > > Module3B are identical, but looks different. > > > > > I don't understand it. Any help please? > > > > The classes are subtly different. The difference is whether column 3, > > > which does not have a width specified, is on the right or in the center. > > > The "blue" are fixed width; the "white" is variable; > > > The other difference is in 3A - there are two ez-fl (float left) > > sections; in 3B the second fixed width is ez-fr class (float > > right) --- there is similarly one other class difference (where the > > negative margin tweak is located).
Re: [web2py] performance issue- multiple db connection
Sorry to bump an old email, but was this changed at some point? (master) [dwar...@thebigwave gluon]$ grep pool_size\= * dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8'): dal.py:def __init__(self, uri='sqlite://dummy.db', pool_size=0, folder=None, sql.py:def __init__(self, uri='sqlite://dummy.db', pool_size=0, sql.py:pool_size=0, The default for every adapter type seems to be 0 not 10? On Tue, May 11, 2010 at 5:55 AM, Timothy Farrell wrote: > When you create your model, there is a "pools" parameter that defaults to > 10. This means that the one web2py process will use a pool of 10 > connections on that one database. It leaves the connections open even after > the request is served so that they can serve the next connection without > having to reconnect to the database. > > -tim > > On 5/11/2010 3:58 AM, vihang wrote: >> >> Hello, >> >> I am trying to understand the possible performance setback if I try to >> open multiple db connections. Is there some mechanism in web2py which >> would optimizes the number of open connections to the database? >> >> Vihang >> > >
[web2py] Re: performance issue- multiple db connection
yes, this was always zero, mostly because it does not work with sqlite (default db) and because when introduced we did not want to change the previous behavior (backward compatibility). On Jun 9, 6:59 pm, Doug Warren wrote: > Sorry to bump an old email, but was this changed at some point? > (master) [dwar...@thebigwave gluon]$ grep pool_size\= * > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self,db,uri,pool_size=0,folder=None,db_codec > ='UTF-8'): > dal.py: def __init__(self, uri='sqlite://dummy.db', pool_size=0, > folder=None, > sql.py: def __init__(self, uri='sqlite://dummy.db', pool_size=0, > sql.py: pool_size=0, > > The default for every adapter type seems to be 0 not 10? > > On Tue, May 11, 2010 at 5:55 AM, Timothy Farrell wrote: > > When you create your model, there is a "pools" parameter that defaults to > > 10. This means that the one web2py process will use a pool of 10 > > connections on that one database. It leaves the connections open even after > > the request is served so that they can serve the next connection without > > having to reconnect to the database. > > > -tim > > > On 5/11/2010 3:58 AM, vihang wrote: > > >> Hello, > > >> I am trying to understand the possible performance setback if I try to > >> open multiple db connections. Is there some mechanism in web2py which > >> would optimizes the number of open connections to the database? > > >> Vihang
Re: [web2py] web2pyslices update
slicehost! =) -- Thadeus On Wed, Jun 9, 2010 at 6:01 PM, mr.freeze wrote: > VPS provider fail. I'm on the hunt for a new provider. I hope to have > it back up tomorrow. >
Re: [web2py] Re: Separating models into their own files
There are some things you can do to alleviate the situation. First, you can name you models so that they execute in the correct order. A_db.py B_user.py C_post.py E_tag.py That said, I usually try to keep all related models in the same file. In your case you might have B_user.py C_weblog.py Since post and tag both belong to the same logical set of tables, stick them together in one file. For objects, I also might subset it simpler such as C_weblog.py C_weblog_objects.py # contains virtualfield definitions. -- Thadeus On Wed, Jun 9, 2010 at 4:42 PM, mdipierro wrote: > No. This the main issue with web2py design. This is the price we pay > for not having imports of models. > > On Jun 9, 4:21 pm, Binh wrote: >> Hi, >> >> I am trying to create an orm setup like in ruby on rails with the DAL. >> I have a user, post, and tag model. >> A user has many posts. >> A tag belongs to a user. >> A post has and belongs to many tags. >> A tag has and belongs to many posts. >> >> I have 4 separate files in my models folder: db.py, user.py, post.py, >> and tag.py >> db.py contains the db connection and mail configurations. >> The respective model files define the table structure and have a class >> named after the model to implement virtual fields. >> >> I noticed that defining the tables with relationships in the separate >> files does not work properly. >> The model files would load which appears to be in alphabetical order. >> So, my db.py would load first and then post.py which fails. >> post.py fails to recognize the table definition in user.py, so it >> cannot define the belongs to relationship. >> >> Is their anyway to setup a model file to import all the other models >> without the hassle of file load order and possibly import order which >> rails does implicitly? >
[web2py] Re: Error on install script?
I don't know the answer but I may have found a clue. When I try to manually install the pwauth line of the script, it's not found in the repository. I copied Massimo's vimeo instructions exactly and got the same error. Oddly, it started working when I screwed with the link (but probably not as intended). On May 9, 8:24 pm, Pepe wrote: > setting up PAM > > Reading package lists... Done > Building dependency tree > Reading state information... Done > E: Couldn't find package pwauth > restarting apage > > * Restarting web server apache2 > * We failed to correctly shutdown apache, so we're now killing all > running apache processes. > This is almost certainly suboptimal, so please make sure your system > is working as you'd expect now! > > apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: > Could not open configuration file /etc/apache2/mods-enabled/ > authnz_external.load: No such file or directory > > on VPS.net ubuntu 8.04 LTS > > any help please!
[web2py] Re: web2pyslices update
vps.net I have not rebooted or restarted apache in 3 months (except when upgraded web2py) and only tickets due to known application bugs. On Jun 9, 9:13 pm, Thadeus Burgess wrote: > slicehost! =) > > -- > Thadeus > > On Wed, Jun 9, 2010 at 6:01 PM, mr.freeze wrote: > > VPS provider fail. I'm on the hunt for a new provider. I hope to have > > it back up tomorrow.
[web2py] Re: Separating models into their own files
My approach is to use db_blablabla1.py db_blablabla2.py db_blablabla3.py where db_blablabla.py defiles all tables that link each other for a specific purpose. The different files are independent and therefore the order of execution is not important. On Jun 9, 9:20 pm, Thadeus Burgess wrote: > There are some things you can do to alleviate the situation. > > First, you can name you models so that they execute in the correct order. > > A_db.py > B_user.py > C_post.py > E_tag.py > > That said, I usually try to keep all related models in the same file. > In your case you might have > > B_user.py > C_weblog.py > > Since post and tag both belong to the same logical set of tables, > stick them together in one file. For objects, I also might subset it > simpler such as > > C_weblog.py > C_weblog_objects.py # contains virtualfield definitions. > > -- > Thadeus > > On Wed, Jun 9, 2010 at 4:42 PM, mdipierro wrote: > > No. This the main issue with web2py design. This is the price we pay > > for not having imports of models. > > > On Jun 9, 4:21 pm, Binh wrote: > >> Hi, > > >> I am trying to create an orm setup like in ruby on rails with the DAL. > >> I have a user, post, and tag model. > >> A user has many posts. > >> A tag belongs to a user. > >> A post has and belongs to many tags. > >> A tag has and belongs to many posts. > > >> I have 4 separate files in my models folder: db.py, user.py, post.py, > >> and tag.py > >> db.py contains the db connection and mail configurations. > >> The respective model files define the table structure and have a class > >> named after the model to implement virtual fields. > > >> I noticed that defining the tables with relationships in the separate > >> files does not work properly. > >> The model files would load which appears to be in alphabetical order. > >> So, my db.py would load first and then post.py which fails. > >> post.py fails to recognize the table definition in user.py, so it > >> cannot define the belongs to relationship. > > >> Is their anyway to setup a model file to import all the other models > >> without the hassle of file load order and possibly import order which > >> rails does implicitly?
[web2py] Re: Error on install script?
You do not need it. Comment that part of the script related to pam. On Jun 9, 9:21 pm, cadrentes wrote: > I don't know the answer but I may have found a clue. When I try to > manually install the pwauth line of the script, it's not found in the > repository. I copied Massimo's vimeo instructions exactly and got the > same error. > Oddly, it started working when I screwed with the link (but probably > not as intended). > > On May 9, 8:24 pm, Pepe wrote: > > > setting up PAM > > > > Reading package lists... Done > > Building dependency tree > > Reading state information... Done > > E: Couldn't find package pwauth > > restarting apage > > > > * Restarting web server apache2 > > * We failed to correctly shutdown apache, so we're now killing all > > running apache processes. > > This is almost certainly suboptimal, so please make sure your system > > is working as you'd expect now! > > > apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: > > Could not open configuration file /etc/apache2/mods-enabled/ > > authnz_external.load: No such file or directory > > > on VPS.net ubuntu 8.04 LTS > > > any help please!
Re: [web2py] Re: web2pyslices update
Statusactive Distro Ubuntu 9.10 (karmic) Age 7 months Datacenter DFW1 Since I live in Austin, I like having my server so close. Most of slicehosts servers are in Dallas, they allocate your server based on your address, however they do have them located elsewhere and can request a different region if you need it. -- Thadeus On Wed, Jun 9, 2010 at 9:30 PM, mdipierro wrote: > vps.net > > I have not rebooted or restarted apache in 3 months (except when > upgraded web2py) and only tickets due to known application bugs. > > On Jun 9, 9:13 pm, Thadeus Burgess wrote: >> slicehost! =) >> >> -- >> Thadeus >> >> On Wed, Jun 9, 2010 at 6:01 PM, mr.freeze wrote: >> > VPS provider fail. I'm on the hunt for a new provider. I hope to have >> > it back up tomorrow. >
[web2py] Re: web2pyslices update
FWIW, I've had 600+ days of uptime running Debian + Apache + qmail at www.linode.com. It was rebooted recently to switch from uml to xen. I have two nodes there, one Debian (sarge) in Texas and one Ubuntu 10.04 in New Jersey. Linode's web-based interface is amazing (I love being able to resize my ext3 disks without losing data, or cloning them or creating as many disks as I'd like. And being able to have multiple distros available to boot. And rebooting as frequently as I'd like.) And get this: you can get remote console access (LISH) even when your own SSH server is misconfigured or not running (so you can see your Linux startup/boot messages in real time when you reboot your vps even while your own ssh server hasn't started yet.) I'm just a very happy customer/fan. Not affiliated with them in any way. On Jun 9, 6:01 pm, "mr.freeze" wrote: > VPS provider fail. I'm on the hunt for a new provider. I hope to have > it back up tomorrow.
[web2py] Key query support in Google App Engine
Hi all, attached is a patch for gql.py. Please review and Massimo, if people like this, can we add it to trunk? what does it do? it allows you to do key queries on Google App Engine. this means that you can now perform all ID queries on tables in google app engine. for example: belongs = db(db.test_tbl.id.belongs([69126,69127])).select() eq = db(db.test_tbl.id==69126).select() neq = db(db.test_tbl.id!=69126).select() lt = db(db.test_tbl.id<69126).select() gt = db(db.test_tbl.id>69126).select() lte = db(db.test_tbl.id<=69126).select() gte = db(db.test_tbl.id>=69126).select() all = db(db.test_tbl.id>0).select() it also adds "__key__" to _extra on each row in the result...just in case you really wanted to see that google key. if i missed some test cases please let me know and i'll verify them as well. thanks! Christian diff -r 52be2b542a3c gluon/contrib/gql.py --- a/gluon/contrib/gql.py Wed Jun 09 10:52:12 2010 -0500 +++ b/gluon/contrib/gql.py Wed Jun 09 20:48:24 2010 -0700 @@ -27,6 +27,7 @@ import gluon.sql from new import classobj from google.appengine.ext import db as gae +from google.appengine.api.datastore_types import Key MAX_ITEMS = 1000 # GAE main limitation @@ -531,12 +532,33 @@ # normal filter: field op value assert_filter_fields(left) if left.type == 'id': + #if the name is also id, treat it like an long + if left.name == 'id': try: -right = long(right or 0) +if type(right) == list: +#make this work for belongs +right = [long(r) for r in right] +else: +right = long(right or 0) except ValueError: raise SyntaxError, 'id value must be integer: %s' % id -if not (op == '=' or (op == '>' and right == 0)): -raise RuntimeError, '(field.id value) is not supported on GAE' +if op != '=' and not (op == '>' and right == 0): +#in this case we need to go a GAE __key__ query. change the +# name for query generation (we change the name back after the +# query is generated) +left.name="__key__" +#get key (or keys) based on path. Note if we later support +# ancesters this will not be the proper key for items with +# ancesters. +if op=='IN': +right = [Key.from_path(left._tablename, r) for r in right] +else: +right = Key.from_path(left._tablename, right) + else: +#this most likely means that the user created a field called +# __key__ that they want to use to do a query with a known +# key +right = Key(str(right or 0)) elif op=='IN': right = [dateobj_to_datetime(obj_represent(r, left.type, left._db)) \ for r in right] @@ -667,6 +689,11 @@ (limit, offset) = (lmax - lmin, lmin) items = items.fetch(limit, offset=offset) fields = self._db[tablename].fields + +#change the id name back to id from __key__ used in the query +id_field = self._db[tablename]['id'] +id_field.name='id' + return (items, tablename, fields) def select(self, *fields, **attributes): @@ -683,10 +710,17 @@ for t in fields: if t == 'id': new_item.append(int(item.key().id())) +elif t == '__key__': +#actually want the key value from GAE +new_item.append(item.key()) else: new_item.append(getattr(item, t)) +#add the key so it will be in _extra for the result +new_item.append(item.key()) rows.append(new_item) colnames = ['%s.%s' % (tablename, t) for t in fields] +#add __key__ name to extra +colnames.append('__key__') return self.parse(self._db, rows, colnames, False, SetClass=Set) @staticmethod
[web2py] Re: email attachments not seen on Macs
Notwithstanding my backup option of using links instead of attachments, I discovered a way to make email attachments work for both PC users as well as Mac users: Line 294 of gluon.tools.py: payload_in = MIMEMultipart.MIMEMultipart('related') changed to: payload_in = MIMEMultipart.MIMEMultipart('mixed') Not sure this is a 'bug' as such, but perhaps the wrong Content-Type for what I want. Maybe Macs are more strict about protocol than PCs. I used the following to come to this conclusion. http://en.wikipedia.org/wiki/MIME#Multipart_subtypes Content-Type 'multipart/related' consists of a root part which references other parts inline. Content-Type 'multipart/mixed' is used for sending files with different "Content-Type" headers inline or as attachments. Whatever, it works for all my users now. Bob On Jun 9, 10:46 am, Bob_in_Comox wrote: > I send email out to 150 club members. No problems with simple emails. > However with attachments only PC users can see and download them, > while Mac uses cannot even see the attachments. > > using web2py 1.79.1 on webfaction with webfaction email servers > > My code (simplified): > > from gluon.tools import Mail > attachments = [Mail.Attachment(path-to-file1, filename=filename1)] > > mail = Mail( 'smtp.webfaction.com:587', club-email-address, club-email- > login) > mail.send( > to = [club-member-addresses], > subject = subject, > message = plain-text-message, > attachments = attachments, > reply_to = my-email-address) > > I do not change any default mail.settings. > > If I cannot fix this, my backup option will be to store attachments on > our server, and use links to these in the message instead of > attachments. > > Thanks for any suggestions. > > Bob
[web2py] Re: Key query support in Google App Engine
The belongs is fine but I have a couple of problems: 1) adding __key__ in extra is not backward compatible because it changes the way records in Rows is acceessed 2) if you say db(db.table.id<1000) it does not actually select records if id<1000 but Key(id) wrote: > Hi all, > > attached is a patch for gql.py. Please review and Massimo, if people > like this, can we add it to trunk? > > what does it do? it allows you to do key queries on Google App Engine. > this means that you can now perform all ID queries on tables in google > app engine. for example: > > belongs = db(db.test_tbl.id.belongs([69126,69127])).select() > eq = db(db.test_tbl.id==69126).select() > neq = db(db.test_tbl.id!=69126).select() > lt = db(db.test_tbl.id<69126).select() > gt = db(db.test_tbl.id>69126).select() > lte = db(db.test_tbl.id<=69126).select() > gte = db(db.test_tbl.id>=69126).select() > all = db(db.test_tbl.id>0).select() > > it also adds "__key__" to _extra on each row in the result...just in > case you really wanted to see that google key. > > if i missed some test cases please let me know and i'll verify them as well. > > thanks! > > Christian > > gql_key_query_patch.diff > 3KViewDownload
[web2py] Re: email attachments not seen on Macs
In trunk! :-) On Jun 9, 11:04 pm, Bob_in_Comox wrote: > Notwithstanding my backup option of using links instead of > attachments, I discovered a way to make email attachments work for > both PC users as well as Mac users: > > Line 294 of gluon.tools.py: > payload_in = MIMEMultipart.MIMEMultipart('related') > > changed to: > payload_in = MIMEMultipart.MIMEMultipart('mixed') > > Not sure this is a 'bug' as such, but perhaps the wrong Content-Type > for what I want. Maybe Macs are more strict about protocol than PCs. > > I used the following to come to this > conclusion.http://en.wikipedia.org/wiki/MIME#Multipart_subtypes > > Content-Type 'multipart/related' consists of a root part which > references other parts inline. > > Content-Type 'multipart/mixed' is used for sending files with > different "Content-Type" headers inline or as attachments. > > Whatever, it works for all my users now. > > Bob > > On Jun 9, 10:46 am, Bob_in_Comox wrote: > > > I send email out to 150 club members. No problems with simple emails. > > However with attachments only PC users can see and download them, > > while Mac uses cannot even see the attachments. > > > using web2py 1.79.1 on webfaction with webfaction email servers > > > My code (simplified): > > > from gluon.tools import Mail > > attachments = [Mail.Attachment(path-to-file1, filename=filename1)] > > > mail = Mail( 'smtp.webfaction.com:587', club-email-address, club-email- > > login) > > mail.send( > > to = [club-member-addresses], > > subject = subject, > > message = plain-text-message, > > attachments = attachments, > > reply_to = my-email-address) > > > I do not change any default mail.settings. > > > If I cannot fix this, my backup option will be to store attachments on > > our server, and use links to these in the message instead of > > attachments. > > > Thanks for any suggestions. > > > Bob
Re: [web2py] Re: Weird error when trying to change my avatar image in my profiles... (Using Auth())
Thanks, thought I was installing the latest version. But I wasn't. Best Regards, Jason Brower On Wed, 2010-06-09 at 12:54 -0700, mdipierro wrote: > This was fixed in 1.79.1 > > On Jun 9, 2:05 pm, Jason Brower wrote: > > And if I refresh the page that had the error, resubmitting. It logs me > > out and puts me at the loggin screen. > > It also seems to have worked when I am logged in.(Image changed and > > everything.) Very funky indeed. > > BR, > > J > > > > On Wed, 2010-06-09 at 22:02 +0300, Jason Brower wrote: > > > When I try to change the avatar image in the profile I get a weird > > > error... This is the actual pickle, as I have no way to read the files > > > while I don't have admin access. Hence why I reported this feature about > > > a month ago. > > > (dp1 > > > S'output' > > > p2 > > > S'' > > > sS'layer' > > > p3 > > > S'Framework' > > > p4 > > > sS'code' > > > p5 > > > S'' > > > sS'traceback' > > > p6 > > > S'Traceback (most recent call last):\n File > > > "/home/interestid/interestid.com/gluon/main.py", line 407, in wsgibase\n > > > session._try_store_on_disk(request, response)\n File > > > "/home/interestid/interestid.com/gluon/globals.py", line 375, in > > > _try_store_on_disk\ncPickle.dump(dict(self), > > > response.session_file)\n File "copy_reg.py", line 69, in _reduce_ex\n > > > raise TypeError, "can\'t pickle %s objects" % base.__name__\nTypeError: > > > can\'t pickle file objects\n' > > > p7 > > > s. > > > Attached is my db.py and this only happened after creating the country > > > feild. > > > Weird? Oh yeah. > > > BR, > > > Jason Brower
[web2py] Re: Key query support in Google App Engine
1) i don't mind removing __key__ from extra. it was just something i was using while figuring it out. (though i don't understand what it changes in how Rows is accessed). 2) The Key on GAE is a base64 encoded string of "table_name: id=" (for the simple no-ancestor case). My understanding of how GAE executes the query is that it decodes the key, sorts on the numeric id, and then filters, so the transformation to the GAE Key class should not cause problems. at least that is how i understand it (and how it works in my limited usage so far). see http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html#Queries_on_Keys for a little better explanation. Does that help? shall i make a new patch w/o the __key__ in _extra? thanks! christian On Jun 9, 9:08 pm, mdipierro wrote: > The belongs is fine but I have a couple of problems: > > 1) adding __key__ in extra is not backward compatible because it > changes the way records in Rows is acceessed > > 2) if you say db(db.table.id<1000) it does not actually select records > if id<1000 but Key(id) > Did I misunderstand the source? > > On Jun 9, 10:54 pm, Christian Foster Howes wrote: > > > Hi all, > > > attached is a patch for gql.py. Please review and Massimo, if people > > like this, can we add it to trunk? > > > what does it do? it allows you to do key queries on Google App Engine. > > this means that you can now perform all ID queries on tables in google > > app engine. for example: > > > belongs = db(db.test_tbl.id.belongs([69126,69127])).select() > > eq = db(db.test_tbl.id==69126).select() > > neq = db(db.test_tbl.id!=69126).select() > > lt = db(db.test_tbl.id<69126).select() > > gt = db(db.test_tbl.id>69126).select() > > lte = db(db.test_tbl.id<=69126).select() > > gte = db(db.test_tbl.id>=69126).select() > > all = db(db.test_tbl.id>0).select() > > > it also adds "__key__" to _extra on each row in the result...just in > > case you really wanted to see that google key. > > > if i missed some test cases please let me know and i'll verify them as well. > > > thanks! > > > Christian > > > gql_key_query_patch.diff > > 3KViewDownload
[web2py] Controller Hierarchy
Controller would be useful for a facebook canvas app where all requests are delegated to all the other controllers. The example facebook app shows the use of pyfacebook to handle requests on the index action in the default controller. Is it possible to hookup pyfacebook in a DRY way that all controllers can handle facebook requests or controllers that can inherit from default.py or something like that?