[web2py:12461] Re: Passing values to the flash helper
Massimo, insert is wrong since I am presenting the user a form to manage her/his existing user settings. I needed commit() as a result of a discussion we had a few months ago, I am sending the user a verification mail and doing some other stuff in the same controller, it is supposed to trigger a save to the database immediately to circumvent timeout or race condition problems --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12462] Re: DAL - Segregate connections & queries
My only hesitation was defining the table twice and THATs SOLVED !!! Thanks a ton ! On Nov 25, 11:57 am, mdipierro <[EMAIL PROTECTED]> wrote: > If I understand... > > #create two connections > db1=SQLDB(...) > db2=SQLDB(...) > > #define the tables twice (perhaps using the following trick) > db1.define_table('mytable',) > db2.define_table('mytable',db1.mytable) > > then use db1 for select and db2 for update, insert, etc. > > Massimo > > On Nov 25, 1:52 am, vihang <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am working on a small project that requires me to direct certain > > queries to certain database connections. That is, simply put, all > > select queries to one database connection and update, insert queries > > to another. Can this be done in web2py without making mods to the DAL > > code? > > > Cheers > > Vihang --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12463] Re: Passing values to the flash helper
Here, Voltron - see if this makes more sense: On Tue, Nov 25, 2008 at 12:01 AM, mdipierro <[EMAIL PROTECTED]> wrote: > >id=db.users.update( > email= form.vars.email, > password = form.vars.password > ) > > should be > (I'll try to correct what Massimo suggested:) row = db(db.users.email == form.vars.email).select() row.update_record( >email= form.vars.new_email, > password = form.vars.password > ) > Of course, assuming new_email is wanted, and validated... you can work that out :-) > > else you are updating the db.users dictionary thus redefining the > meaning of field email and field password. > Massimo Above, Massimo makes an important point (I've been having a private discussion w/ him about the way this is all named, currently wrapped in classes, etc.). Hope that helps. Regards, Yarko > > > On Nov 24, 11:18 pm, voltron <[EMAIL PROTECTED]> wrote: > > I am using: > > > > Version 1.51 (2008-11-19 14:48:02) > > Database drivers available: SQLite3, Postgre > > > > The only code that could be of use is this snippet, the rest are > > several lines of forms, strings, mail templates and such > > > > user = db(db.users.id == session.user_id).select() > > > > if form.accepts(request.vars,session, > > formname="account_management_form") and > > form.vars.password==form.vars.password2: > > key = md5.new(str(random.randint(0,))).hexdigest() > > try: > > id=db.users.update( > >email= form.vars.email, > >password = form.vars.password > >) > > > > except Exception, detail: > > print 'Error:', detail > > response.flash = T("Update unsuccessful, please contact > > our service team") > > else: > > db.commit() > > session.flash = user[0].user_name > > redirect(URL(r=request, f="manage_account")) > > elif form.vars.password != form.vars.password2: > > form.errors.password2 = T('Passwords do not match') > > response.flash = T("Update unsuccessful, please contact our > > service team") > > elif form.errors: > > response.flash = T("Please check your values") > > else: > > pass > > #response.flash = T("Please fill in the registration form") > > > > return dict(form = form, page_title = page_title, page_content = > > page_content) > > > > Thanks > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12464] Re: Passing values to the flash helper
you can add this if / where you need: id = row.id On Tue, Nov 25, 2008 at 2:53 AM, Yarko Tymciurak <[EMAIL PROTECTED]> wrote: > Here, Voltron - see if this makes more sense: > > On Tue, Nov 25, 2008 at 12:01 AM, mdipierro <[EMAIL PROTECTED]>wrote: > >> >>id=db.users.update( >> email= form.vars.email, >> password = form.vars.password >> ) >> >> should be >> > > (I'll try to correct what Massimo suggested:) > > row = db(db.users.email == form.vars.email).select() > row.update_record( > >>email= form.vars.new_email, >> password = form.vars.password >> ) >> > > Of course, assuming new_email is wanted, and validated... you can work that > out :-) > > >> >> else you are updating the db.users dictionary thus redefining the >> meaning of field email and field password. > > >> Massimo > > > Above, Massimo makes an important point (I've been having a private > discussion w/ him about the way this is all named, currently wrapped in > classes, etc.). > > Hope that helps. > > Regards, > Yarko > > >> >> >> On Nov 24, 11:18 pm, voltron <[EMAIL PROTECTED]> wrote: >> > I am using: >> > >> > Version 1.51 (2008-11-19 14:48:02) >> > Database drivers available: SQLite3, Postgre >> > >> > The only code that could be of use is this snippet, the rest are >> > several lines of forms, strings, mail templates and such >> > >> > user = db(db.users.id == session.user_id).select() >> > >> > if form.accepts(request.vars,session, >> > formname="account_management_form") and >> > form.vars.password==form.vars.password2: >> > key = md5.new(str(random.randint(0,))).hexdigest() >> > try: >> > id=db.users.update( >> >email= form.vars.email, >> >password = form.vars.password >> >) >> > >> > except Exception, detail: >> > print 'Error:', detail >> > response.flash = T("Update unsuccessful, please contact >> > our service team") >> > else: >> > db.commit() >> > session.flash = user[0].user_name >> > redirect(URL(r=request, f="manage_account")) >> > elif form.vars.password != form.vars.password2: >> > form.errors.password2 = T('Passwords do not match') >> > response.flash = T("Update unsuccessful, please contact our >> > service team") >> > elif form.errors: >> > response.flash = T("Please check your values") >> > else: >> > pass >> > #response.flash = T("Please fill in the registration form") >> > >> > return dict(form = form, page_title = page_title, page_content = >> > page_content) >> > >> > Thanks >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12465] your recommended way of calling controllers from the command line ?
The subject says it all. I know a couple of methods (python -R wrapper, the older -S patch, piping, etc), but was wondering which you think is the cleanest (and cross platform) as I'd like to integrate it into my cron patch (so you could specify controllers/functions in your crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12466] Using database and session in a user-defined class
Hi all, Is there a simple way to access the dynamic web2py global variables (db, session, request, response) from inside a user defined class? If I were to define the class inside the controller, then I'd have no trouble. However, if I define the class in a separate module (i.e. in the "modules" subdirectory) then I'm not able to access these globals anymore from inside the class. All I've been able to find so far is passing the global variables as arguments to the constructor/methods, but this seems inelegant to me since db, request, etc. are _global_ variables. Accessing them is kind of like accessing logging or any other Singleton... Thanks in advance, --Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12467] Re: "No databases in this application" on GAE
On Nov 25, 5:01 am, sharekey <[EMAIL PROTECTED]> wrote: > I try your code, it work well, I can select records > fromhttp://127.0.0.1:8080/myapp/appadmin/select/db/mytablenow. I find the > two modifications in select function is : > 1) Replace "query='%s.id>0' % table" with "query = dbname + '.' + > table + '.id>0'" Thanks, I forgot about that one. So I made 4 changes total. :-) BTW, you can require secure access to appadmin on the deployment GAE server by adding this handler to your app.yaml file: - url: /(?P.+?)/appadmin.* script: gaehandler.py login: admin secure: always I haven't tested this yet, but it *should* work. :-) --Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12468] Re: "No databases in this application" on GAE
On Nov 24, 5:16 pm, mdipierro <[EMAIL PROTECTED]> wrote: > In principle I would like to move t2.search into appadmin and thet > would solve the problem. How do people fill about it? If it allows the appadmin to work fine on GAE, then I'm totally in favour. :-D --Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12469] Re: Using database and session in a user-defined class
Hi, You see, session, request and response are not globals "per se", they depend on the session you're responding to. From what I can tell the controller functions are "wrapped" inside an environment just before they're called and that's why you have those variables around. So, the way it's built, you do have to pass them on to the modules. Anyways, I guess I'm not the best person to answer your question, I've come to this conclusion because I had the same problem and I took a look at the web2py source code (I can see that happening in main.py and compile_app.py). I expect one of the experts around to have a better explanation for you. Regards, Deodoro Filho On Tue, Nov 25, 2008 at 11:19 AM, Jonathan Benn <[EMAIL PROTECTED]>wrote: > > Hi all, > > > Is there a simple way to access the dynamic web2py global variables > (db, session, request, response) from inside a user defined class? > > If I were to define the class inside the controller, then I'd have no > trouble. However, if I define the class in a separate module (i.e. in > the "modules" subdirectory) then I'm not able to access these globals > anymore from inside the class. > > All I've been able to find so far is passing the global variables as > arguments to the constructor/methods, but this seems inelegant to me > since db, request, etc. are _global_ variables. Accessing them is kind > of like accessing logging or any other Singleton... > > > Thanks in advance, > > --Jonathan > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12470] Re: Passing values to the flash helper
NEVER DO db.table.update() that changes the definition of the table not the records. To update records you need to follow Yarko suggestion: db(.).update(.) Massimo On Nov 25, 2:56 am, "Yarko Tymciurak" <[EMAIL PROTECTED]> wrote: > you can add this if / where you need: > id = row.id > > On Tue, Nov 25, 2008 at 2:53 AM, Yarko Tymciurak <[EMAIL PROTECTED]> wrote: > > Here, Voltron - see if this makes more sense: > > > On Tue, Nov 25, 2008 at 12:01 AM, mdipierro <[EMAIL PROTECTED]>wrote: > > >>id=db.users.update( > >> email= form.vars.email, > >> password = form.vars.password > >> ) > > >> should be > > > (I'll try to correct what Massimo suggested:) > > > row = db(db.users.email == form.vars.email).select() > > row.update_record( > > >>email= form.vars.new_email, > >> password = form.vars.password > >> ) > > > Of course, assuming new_email is wanted, and validated... you can work that > > out :-) > > >> else you are updating the db.users dictionary thus redefining the > >> meaning of field email and field password. > > >> Massimo > > > Above, Massimo makes an important point (I've been having a private > > discussion w/ him about the way this is all named, currently wrapped in > > classes, etc.). > > > Hope that helps. > > > Regards, > > Yarko > > >> On Nov 24, 11:18 pm, voltron <[EMAIL PROTECTED]> wrote: > >> > I am using: > > >> > Version 1.51 (2008-11-19 14:48:02) > >> > Database drivers available: SQLite3, Postgre > > >> > The only code that could be of use is this snippet, the rest are > >> > several lines of forms, strings, mail templates and such > > >> > user = db(db.users.id == session.user_id).select() > > >> > if form.accepts(request.vars,session, > >> > formname="account_management_form") and > >> > form.vars.password==form.vars.password2: > >> > key = md5.new(str(random.randint(0,))).hexdigest() > >> > try: > >> > id=db.users.update( > >> >email= form.vars.email, > >> >password = form.vars.password > >> >) > > >> > except Exception, detail: > >> > print 'Error:', detail > >> > response.flash = T("Update unsuccessful, please contact > >> > our service team") > >> > else: > >> > db.commit() > >> > session.flash = user[0].user_name > >> > redirect(URL(r=request, f="manage_account")) > >> > elif form.vars.password != form.vars.password2: > >> > form.errors.password2 = T('Passwords do not match') > >> > response.flash = T("Update unsuccessful, please contact our > >> > service team") > >> > elif form.errors: > >> > response.flash = T("Please check your values") > >> > else: > >> > pass > >> > #response.flash = T("Please fill in the registration form") > > >> > return dict(form = form, page_title = page_title, page_content = > >> > page_content) > > >> > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12471] Re: your recommended way of calling controllers from the command line ?
-R is the cleanest way. ;-) On Nov 25, 4:55 am, achipa <[EMAIL PROTECTED]> wrote: > The subject says it all. I know a couple of methods (python -R > wrapper, the older -S patch, piping, etc), but was wondering which you > think is the cleanest (and cross platform) as I'd like to integrate it > into my cron patch (so you could specify controllers/functions in your > crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12472] Re: Using database and session in a user-defined class
You should look into the T2 source code. The class T2 is defined in a module. When the module is imported and instantiated you pass request, response, session, cache, T and db to it and store references to them as member variables. Another way would be to execute modules, instead of importing them. I think importing is cleaner. Massimo On Nov 25, 8:01 am, "José Deodoro de Oliveira Filho" <[EMAIL PROTECTED]> wrote: > Hi, > You see, session, request and response are not globals "per se", they depend > on the session you're responding to. From what I can tell the controller > functions are "wrapped" inside an environment just before they're called and > that's why you have those variables around. So, the way it's built, you do > have to pass them on to the modules. > > Anyways, I guess I'm not the best person to answer your question, I've come > to this conclusion because I had the same problem and I took a look at the > web2py source code (I can see that happening in main.py and compile_app.py). > I expect one of the experts around to have a better explanation for you. > > Regards, > > Deodoro Filho > > On Tue, Nov 25, 2008 at 11:19 AM, Jonathan Benn <[EMAIL PROTECTED]>wrote: > > > > > Hi all, > > > Is there a simple way to access the dynamic web2py global variables > > (db, session, request, response) from inside a user defined class? > > > If I were to define the class inside the controller, then I'd have no > > trouble. However, if I define the class in a separate module (i.e. in > > the "modules" subdirectory) then I'm not able to access these globals > > anymore from inside the class. > > > All I've been able to find so far is passing the global variables as > > arguments to the constructor/methods, but this seems inelegant to me > > since db, request, etc. are _global_ variables. Accessing them is kind > > of like accessing logging or any other Singleton... > > > Thanks in advance, > > > --Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12473] Re: your recommended way of calling controllers from the command line ?
Maybe it's just the lack of coffee, but... how do you call a function in the controller via -R without ending up with cruft in the calling code or the controller itself ? On Nov 25, 3:26 pm, mdipierro <[EMAIL PROTECTED]> wrote: > -R is the cleanest way. ;-) > > On Nov 25, 4:55 am, achipa <[EMAIL PROTECTED]> wrote: > > > The subject says it all. I know a couple of methods (python -R > > wrapper, the older -S patch, piping, etc), but was wondering which you > > think is the cleanest (and cross platform) as I'd like to integrate it > > into my cron patch (so you could specify controllers/functions in your > > crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12474] DAL IntegrityError
The following lines of code are part of my model: db.define_table('sleutelwoord', SQLField('woord', length=20, notnull=True, unique=True), SQLField('verzameling', type='integer', length=1, notnull=True, unique=True), migrate='sleutelwoord.table') db.define_table('event', SQLField('bedrijf', db.bedrijf, notnull=True), SQLField('event', length=50, notnull=True), SQLField('vandatum', type='date', notnull=True,), SQLField('totdatum', type='date', notnull=True), SQLField('duur', length=10, notnull=True), SQLField('plaatsnaam', length=40, notnull=True), SQLField('locatie', length=50), SQLField('omschrijving', type='text'), SQLField('sleutelwoord', db.sleutelwoord, notnull=True, ondelete='RESTRICT'), SQLField('doelgroep', db.doelgroep, notnull=True, ondelete='RESTRICT'), SQLField('scope', db.scope, notnull=True, ondelete='RESTRICT'), migrate='event.table') db.event.sleutelwoord.requires=IS_IN_DB(db, 'sleutelwoord.id', '% (woord)s') When I removed the unique=True constraint from the sleutelwoord tabel and saved the model, it raised the following error: S'Traceback (most recent call last):\n File "/Library/Python/2.5/site- packages/web2py/gluon/restricted.py", line 62, in restricted\nexec ccode in environment\n File "/Library/Python/2.5/site-packages/web2py/ applications/b2c/models/db.py", line 147, in \nmigrate= \'sleutelwoord.table\')\n File "/Library/Python/2.5/site-packages/ web2py/gluon/sql.py", line 558, in define_table\nraise e \nIntegrityError: column "verzameling__tmp" contains null values At the moment the error was raised, the table contained one record: values: 1,event,2 so no null values, as far as I can judge. Since I have experienced this problem a couple of times before, I consider it worth a post. This brings me to one of my greatest worries, I am working with web2py and postgres on Mac OS 10.5.4 and every now and then the DAL got me confused, simple changes like the one above raise errors I do not understand. My postgres database contains example records for development purposes, so it is no big deal to drop and re-create some tables every now and then. But what when these errors occur after deployment on a production server. After initial deployment, when I continue developing my application, the database in my development environment will start to differ from the one on the production server. When I redeploy my application on the production server, the files that make up the model match my development database, but not my production database. How does web2py deal with these differences? I hope one of you can reassure me. Best regards, Annet. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12476] Re: DAL IntegrityError
I think the problem is that you have a notnull column without default. This causes a problem when doing a migration. On Nov 25, 9:13 am, annet <[EMAIL PROTECTED]> wrote: > The following lines of code are part of my model: > > db.define_table('sleutelwoord', > SQLField('woord', length=20, notnull=True, unique=True), > SQLField('verzameling', type='integer', length=1, notnull=True, > unique=True), > migrate='sleutelwoord.table') > > db.define_table('event', > SQLField('bedrijf', db.bedrijf, notnull=True), > SQLField('event', length=50, notnull=True), > SQLField('vandatum', type='date', notnull=True,), > SQLField('totdatum', type='date', notnull=True), > SQLField('duur', length=10, notnull=True), > SQLField('plaatsnaam', length=40, notnull=True), > SQLField('locatie', length=50), > SQLField('omschrijving', type='text'), > SQLField('sleutelwoord', db.sleutelwoord, notnull=True, > ondelete='RESTRICT'), > SQLField('doelgroep', db.doelgroep, notnull=True, > ondelete='RESTRICT'), > SQLField('scope', db.scope, notnull=True, ondelete='RESTRICT'), > migrate='event.table') > > db.event.sleutelwoord.requires=IS_IN_DB(db, 'sleutelwoord.id', '% > (woord)s') > > When I removed the unique=True constraint from the sleutelwoord tabel > and saved the model, it raised the following error: > > S'Traceback (most recent call last):\n File "/Library/Python/2.5/site- > packages/web2py/gluon/restricted.py", line 62, in restricted\nexec > ccode in environment\n File "/Library/Python/2.5/site-packages/web2py/ > applications/b2c/models/db.py", line 147, in \nmigrate= > \'sleutelwoord.table\')\n File "/Library/Python/2.5/site-packages/ > web2py/gluon/sql.py", line 558, in define_table\nraise e > \nIntegrityError: column "verzameling__tmp" contains null values > > At the moment the error was raised, the table contained one record: > > values: 1,event,2 > > so no null values, as far as I can judge. Since I have experienced > this problem a couple of times before, I consider it worth a post. > > This brings me to one of my greatest worries, I am working with web2py > and postgres on Mac OS 10.5.4 and every now and then the DAL got me > confused, simple changes like the one above raise errors I do not > understand. My postgres database contains example records for > development purposes, so it is no big deal to drop and re-create some > tables every now and then. But what when these errors occur after > deployment on a production server. > > After initial deployment, when I continue developing my application, > the database in my development environment will start to differ from > the one on the production server. When I redeploy my application on > the production server, the files that make up the model match my > development database, but not my production database. How does web2py > deal with these differences? > > I hope one of you can reassure me. > > Best regards, > > Annet. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12477] Re: Passing values to the flash helper
ahh, that was the problem, a typo of some sort! I was staring at it the whole time and did not see it, no reason for me to update the table definitions :-)) Thanks a lot guys --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12475] Re: your recommended way of calling controllers from the command line ?
Sorry, I misunderstood the question. Answer a) With -R you can execute a script. You can use exec_environment(...) to call a function in a controller. It is described in the manual. Answer b) If you feel you need to do this perhaps something is wrong. perhaps the function belongs to a module, not a controller. Or perhaps you are doing something I never thought of. Massimo On Nov 25, 9:04 am, achipa <[EMAIL PROTECTED]> wrote: > Maybe it's just the lack of coffee, but... how do you call a function > in the controller via -R without ending up with cruft in the calling > code or the controller itself ? > > On Nov 25, 3:26 pm, mdipierro <[EMAIL PROTECTED]> wrote: > > > -R is the cleanest way. ;-) > > > On Nov 25, 4:55 am, achipa <[EMAIL PROTECTED]> wrote: > > > > The subject says it all. I know a couple of methods (python -R > > > wrapper, the older -S patch, piping, etc), but was wondering which you > > > think is the cleanest (and cross platform) as I'd like to integrate it > > > into my cron patch (so you could specify controllers/functions in your > > > crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12478] Re: DAL - Segregate connections & queries
and you can save more coding with one statement that duplicates all tables: [db2.define_table(name,db1[name]) for name in db1.tables] On Nov 25, 2:42 am, vihang <[EMAIL PROTECTED]> wrote: > My only hesitation was defining the table twice and THATs SOLVED !!! > Thanks a ton ! > > On Nov 25, 11:57 am, mdipierro <[EMAIL PROTECTED]> wrote: > > > If I understand... > > > #create two connections > > db1=SQLDB(...) > > db2=SQLDB(...) > > > #define the tables twice (perhaps using the following trick) > > db1.define_table('mytable',) > > db2.define_table('mytable',db1.mytable) > > > then use db1 for select and db2 for update, insert, etc. > > > Massimo > > > On Nov 25, 1:52 am, vihang <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I am working on a small project that requires me to direct certain > > > queries to certain database connections. That is, simply put, all > > > select queries to one database connection and update, insert queries > > > to another. Can this be done in web2py without making mods to the DAL > > > code? > > > > Cheers > > > Vihang --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:/] Re: your recommended way of calling controllers from the command line ?
a) is clear b) Benchmarking, notifications, automation, basically anything that is not an interactive user request coming from a browser. Modules are cumbersome as you have to import loads of controller style logic and you end up with one-liner controller functions which just invoke module functions and a bloated module with all sorts of imports and calls that web2py controllers do by default. That's what I meant by referring to cruft. Note that the fact that it's not a browser call does NOT mean it does not have an output ! In the simplest form, I want to get rid of wget http://localhost/app/controller/function style calls in favor of direct calls (wget calls being the dark side, I know, but so much simpler and quicker than moving controller content to modules). On Nov 25, 4:24 pm, mdipierro <[EMAIL PROTECTED]> wrote: > Sorry, I misunderstood the question. > > Answer a) > With -R you can execute a script. You can use exec_environment(...) to > call a function in a controller. It is described in the manual. > > Answer b) > If you feel you need to do this perhaps something is wrong. perhaps > the function belongs to a module, not a controller. Or perhaps you are > doing something I never thought of. > > Massimo > > On Nov 25, 9:04 am, achipa <[EMAIL PROTECTED]> wrote: > > > Maybe it's just the lack of coffee, but... how do you call a function > > in the controller via -R without ending up with cruft in the calling > > code or the controller itself ? > > > On Nov 25, 3:26 pm, mdipierro <[EMAIL PROTECTED]> wrote: > > > > -R is the cleanest way. ;-) > > > > On Nov 25, 4:55 am, achipa <[EMAIL PROTECTED]> wrote: > > > > > The subject says it all. I know a couple of methods (python -R > > > > wrapper, the older -S patch, piping, etc), but was wondering which you > > > > think is the cleanest (and cross platform) as I'd like to integrate it > > > > into my cron patch (so you could specify controllers/functions in your > > > > crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12480] Re: your recommended way of calling controllers from the command line ?
Understood. That is what exec_environment is for. On Nov 25, 9:54 am, achipa <[EMAIL PROTECTED]> wrote: > a) is clear > > b) Benchmarking, notifications, automation, basically anything that is > not an interactive user request coming from a browser. Modules are > cumbersome as you have to import loads of controller style logic and > you end up with one-liner controller functions which just invoke > module functions and a bloated module with all sorts of imports and > calls that web2py controllers do by default. That's what I meant by > referring to cruft. Note that the fact that it's not a browser call > does NOT mean it does not have an output ! In the simplest form, I > want to get rid of wgethttp://localhost/app/controller/functionstyle > calls in favor of direct calls (wget calls being the dark side, I > know, but so much simpler and quicker than moving controller content > to modules). > > On Nov 25, 4:24 pm, mdipierro <[EMAIL PROTECTED]> wrote: > > > Sorry, I misunderstood the question. > > > Answer a) > > With -R you can execute a script. You can use exec_environment(...) to > > call a function in a controller. It is described in the manual. > > > Answer b) > > If you feel you need to do this perhaps something is wrong. perhaps > > the function belongs to a module, not a controller. Or perhaps you are > > doing something I never thought of. > > > Massimo > > > On Nov 25, 9:04 am, achipa <[EMAIL PROTECTED]> wrote: > > > > Maybe it's just the lack of coffee, but... how do you call a function > > > in the controller via -R without ending up with cruft in the calling > > > code or the controller itself ? > > > > On Nov 25, 3:26 pm, mdipierro <[EMAIL PROTECTED]> wrote: > > > > > -R is the cleanest way. ;-) > > > > > On Nov 25, 4:55 am, achipa <[EMAIL PROTECTED]> wrote: > > > > > > The subject says it all. I know a couple of methods (python -R > > > > > wrapper, the older -S patch, piping, etc), but was wondering which you > > > > > think is the cleanest (and cross platform) as I'd like to integrate it > > > > > into my cron patch (so you could specify controllers/functions in your > > > > > crontab file, not just executables). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12481] Re: Date
I took up replacing my HTML forms with FORMs. My first use case is a page on which a visitor types in a city and submits the page by clicking a submit button (a form in the left column of the page). The controller function should query the database for leisure clubs in that city and the result should be displayed in a table in the right column of the same page. The function reads like this: def byplace(): response.functionname=T('Club locator op plaats') form=FORM('Type een plaatsnaam:', INPUT(_type='text',_name='plaatsnaam',requires=IS_NOT_EMPTY ()), INPUT(_type='submit')) if form.accepts(request.vars,session): clubs=db((db.bedrijf.id==db.adres.bedrijf)& (db.bedrijf.id==db.bedrijfbranche.bedrijf)&\ (db.adres.plaatsnaam==request.vars.plaatsnaam)& (db.adres.adressoort==2)&(db.bedrijfbranche.branche==2))\ .select (db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.ranking,db.adres.straatnaam, \ orderby=db.bedrijf.ranking|db.bedrijf.bedrijfsnaam) response.flash='Clubs in' else: response.flash='Formuleer een zoekopdracht' return dict(form=form,clubs=clubs) And the view reads like this: {{=form}} {{include 'functionnavigation.html'}} {{if response.flash:}} {{=response.flash}} {{pass}} bedrijfsnaam straatnaam {{for club in clubs:}} {{=A(club.bedrijf.bedrijfsnaam,_href=URL (r=request,f='clubdetails', args=[club.bedrijf.id]),_target="_blank")}} {{=club.adres.straatnaam}} {{pass}} Exposing the function results in the following error: Traceback (most recent call last): File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 62, in restricted exec ccode in environment File "/Library/Python/2.5/site-packages/web2py/applications/b2c/ controllers/clubs.py", line 60, in File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py", line 55, in self._caller=lambda f: f() File "/Library/Python/2.5/site-packages/web2py/applications/b2c/ controllers/clubs.py", line 26, in byplace return dict(form=form,clubs=clubs) UnboundLocalError: local variable 'clubs' referenced before assignment I do understand why it does but I do not know how to solve this problem. I hope one of you does. Best regards, Annet. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12483] Re: Date
I added some lines and marked with # def byplace(): response.functionname=T('Club locator op plaats') form=FORM('Type een plaatsnaam:', INPUT(_type='text',_name='plaatsnaam',requires=IS_NOT_EMPTY ()), INPUT(_type='submit')) if form.accepts(request.vars,session): clubs=db((db.bedrijf.id==db.adres.bedrijf)& (db.bedrijf.id==db.bedrijfbranche.bedrijf)&\ (db.adres.plaatsnaam==request.vars.plaatsnaam)& (db.adres.adressoort==2)&(db.bedrijfbranche.branche==2))\ .select (db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.ranking,db.adres.straatnaam, \ orderby=db.bedrijf.ranking|db.bedrijf.bedrijfsnaam) response.flash='Clubs in' else: clubs=[] ### response.flash='Formuleer een zoekopdracht' return dict(form=form,clubs=clubs) And the view reads like this: {{=form}} {{include 'functionnavigation.html'}} {{if response.flash:}} {{=response.flash}} {{pass}} {{ if not clubs:}} {{}} No clubs {{else:}} {{}} bedrijfsnaam straatnaam {{for club in clubs:}} {{=A(club.bedrijf.bedrijfsnaam,_href=URL (r=request,f='clubdetails', args= [club.bedrijf.id]),_target="_blank")}} {{=club.adres.straatnaam}} {{pass}} {{pass}} {{}} On Nov 25, 11:04 am, annet <[EMAIL PROTECTED]> wrote: > I took up replacing my HTML forms with FORMs. > > My first use case is a page on which a visitor types in a city and > submits the page by clicking a submit button (a form in the left > column of the page). The controller function should query the database > for leisure clubs in that city and the result should be displayed in a > table in the right column of the same page. The function reads like > this: > > def byplace(): > response.functionname=T('Club locator op plaats') > form=FORM('Type een plaatsnaam:', > INPUT(_type='text',_name='plaatsnaam',requires=IS_NOT_EMPTY > ()), > INPUT(_type='submit')) > if form.accepts(request.vars,session): > clubs=db((db.bedrijf.id==db.adres.bedrijf)& > (db.bedrijf.id==db.bedrijfbranche.bedrijf)&\ > (db.adres.plaatsnaam==request.vars.plaatsnaam)& > (db.adres.adressoort==2)&(db.bedrijfbranche.branche==2))\ > .select > (db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.ranking,db.adres.straatnaam, > \ > orderby=db.bedrijf.ranking|db.bedrijf.bedrijfsnaam) > response.flash='Clubs in' > else: > response.flash='Formuleer een zoekopdracht' > return dict(form=form,clubs=clubs) > > And the view reads like this: > > > {{=form}} > {{include 'functionnavigation.html'}} > > > {{if response.flash:}} > > {{=response.flash}} > > {{pass}} > > > > > bedrijfsnaam > straatnaam > > > > {{for club in clubs:}} > > {{=A(club.bedrijf.bedrijfsnaam,_href=URL > (r=request,f='clubdetails', > args=[club.bedrijf.id]),_target="_blank")}} > > {{=club.adres.straatnaam}} > > {{pass}} > > > > > > Exposing the function results in the following error: > > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", > line 62, in restricted > exec ccode in environment > File "/Library/Python/2.5/site-packages/web2py/applications/b2c/ > controllers/clubs.py", line 60, in > File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py", > line 55, in > self._caller=lambda f: f() > File "/Library/Python/2.5/site-packages/web2py/applications/b2c/ > controllers/clubs.py", line 26, in byplace > return dict(form=form,clubs=clubs) > UnboundLocalError: local variable 'clubs' referenced before assignment > > I do understand why it does but I do not know how to solve this > problem. I hope one of you does. > > Best regards, > > Annet. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at htt
[web2py:12482] Re: Passing values to the flash helper
NP Voltron - In one way, I'm grateful you had this trouble. We are sure to have some slow, good-thinking discussion on how a crisply defined table-CRUD set would look and be separated from a record CRUD. Massimo raised the point of everything deriving from the built-in class "dict" (including "update()")... I'm looking forward into playing more with inheritance behaviors, selectively overriding. Regards, Yarko On Tue, Nov 25, 2008 at 9:33 AM, voltron <[EMAIL PROTECTED]> wrote: > > ahh, that was the problem, a typo of some sort! I was staring at it > the whole time and did not see it, no reason for me to update the > table definitions :-)) > > Thanks a lot guys > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12484] Re: Date
Massimo, Thanks for your reply, solutions like this add to my enthusiasm for web2py and Python. Best regards, Annet. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12485] response.stream
Testing the video streaming app i saw that response.stream of web2py has a redirect cookie to /admin so it isn't possible to flash player to stream it. How can i solve this problem ?? thx in advance :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12486] Re: response.stream
in html i have ="{{=URL(r=request, c='appadmin',f='download',args= ['db',video.converted_video])}}"> this "string" return me the correct url but with a location cookie :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12487] Re: response.stream
I'm not on GAE :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12488] Re: response.stream
I suggest you contact the author of the app directly. Massimo On Nov 25, 2:29 pm, "ga2arch(GA)" <[EMAIL PROTECTED]> wrote: > in html i have ="{{=URL(r=request, c='appadmin',f='download',args= > ['db',video.converted_video])}}"> > > this "string" return me the correct url but with a location cookie :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12489] IS_IN_DATASET validator for filling SELECT with data from code not database
I wanted to have a field on an SQLFORM that behaved like IS_IN_DB (i.e. a drop box with values shown to the user and a corresponding id inserted into the database). I didn't want to take the source data from the database though because it is more program data than user data and I wanted to use internationalisation. I made this validator. I'm no Python expert so maybe there is a better way. I include it as a meagre offering in case it's helpful and for comments and improvements. class IS_IN_DATASET(object): """ Like IS_IN_DB but gets its data from code not the database, so can do internationalisation etc. e.g. given testSet = { 'fields': [ 'storeVal', 'name' ], 'rows' : [[0, T('Alpha')], [1, T('Beta')], [2, T ('Gamma')]]} can have something like db.table.myField.requires=IS_IN_DATASET (testSet,'storeVal',label='name') renders as a drop-box like IS_IN_DB """ def __init__(self,dbset,forDb,label=None,error_message='value not in data set!'): forDb=str(forDb) if not label: label='%%(%s)s' % forDb self.forDbPos = dbset['fields'].index(forDb) if forDb in dbset ['fields'] else 0 self.forUserPos = dbset['fields'].index(label) if label in dbset['fields'] else 0 mulog.debug("forDbPos is " + str(self.forDbPos) + " for user " + str(self.forUserPos)) self.error_message=error_message self.theset=None # theset is a list of the values that are put in the record # labels is what is shown to the user self.theset=[ str(r[self.forDbPos]) for r in dbset['rows'] ] self.labels=[ r[self.forUserPos] for r in dbset['rows']] def options(self): return [(k,self.labels[i]) for i,k in enumerate(self.theset)] def __call__(self,value): if value in self.theset: return(value, None) return (value,self.error_message) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12490] Join + Update a field
Hi folks, I'm trying to update a value from a inner join query: new=db((db.character.id==1)&(db.character.id ==db.characterHasAttribute.id_character)&(db.characterHasAttribute.id_attribute==3)).select()[0] new.update_record(characterHasAttribute.total_value=2) The error is: new.update_record(characterHasAttribute['total_value']=2) SyntaxError: keyword can't be an expression What am I missing here? Thanks! -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12491] Re: Join + Update a field
Tito, change: new.update_record(characterHasAttribute.total_value=2) to: new.characterHasAttribute.update_record(total_value=2) Do a dir(new) and you will see why. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12492] Re: IS_IN_DATASET validator for filling SELECT with data from code not database
cj, wouldn't that be equivalent to: db.table.myField.requires=IS_IN_SET([0,1,2],labels=[T('Alpha'), T ('Beta'),T('Gamma')]) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12493] Re: Using database and session in a user-defined class
Hi, Ok, thanks for the responses. On Nov 25, 5:30 pm, mdipierro <[EMAIL PROTECTED]> wrote: > You should look into the T2 source code. The class T2 is defined in a > module. When the module is imported and instantiated you pass request, > response, session, cache, T and db to it and store references to them > as member variables. Thanks, that's a good option. > Another way would be to execute modules, instead of importing them. I > think importing is cleaner. Yes, I didn't think of that! I agree that it's less clean though (potentially more confusing). I'll keep it as a backup option. Another option I found is to use web2py's exec_environment command. If you hard-code the path to the model then it reduces your module's reusability, but if you pass the model path string to the module class's constructor then it seems to give the same result as separately passing the db/request/response/session. It might be a bit slower though. --Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:12494] Re: itemize temporary data
thanks guys for your advice. > I would just take the code out of t2 itemize and adapt to your purposes. It > is relatively small. > I did suggest at the outset (18/11) that creating a new version of itemize > was probably the easiest solution :-). As I said I already have my own itemize function. But I'm trying to reuse T2 where practical/possible. Is T2 intended to stay as a link between model and view, or will it be abstracted for the controller? Baron On Nov 22, 10:15 am, billf <[EMAIL PROTECTED]> wrote: > I did suggest at the outset (18/11) that creating a new version of > itemize was probably the easiest solution :-). > > The in-memory database was just a response to "how can I pass data to > itemize?" - not a recommendation. > > On Nov 21, 10:18 pm, "Yarko Tymciurak" <[EMAIL PROTECTED]> wrote: > > > On Fri, Nov 21, 2008 at 4:15 PM, mdipierro <[EMAIL PROTECTED]> wrote: > > > > The fact we can store a database in memory does not mean this is the > > > right solution to your problem. > > > > I would just take the code out of t2 itemize and adapt to your > > > purposes. It is relatively small. > > > +1 > > > > itemize does very very little for you so I doubt you need it. > > > > Massimo > > > > On Nov 21, 4:07 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > sorry, I may have my object types wrong. > > > > > To summarize: > > > > I'm trying to pass data directly to t2.itemize() without having to > > > > write to a database. > > > > > If I understood right, Bill was hinting that writing to an in-memory > > > > database was the easiest way, so I was wondering what was the harder > > > > alternative way. > > > > I was hoping there was a way to directly instantiate the required > > > > input for t2.itemize() directly without going through a database. > > > > Writing to a temporary in-memory database 'smells' bad for me. > > > > > For now I've created my own itemize. > > > > > Baron > > > > > On Nov 21, 8:11 am, mdipierro <[EMAIL PROTECTED]> wrote: > > > > > > What for? SQLTable or SQLTABLE? I am confused. > > > > > > Massimo > > > > > > On Nov 20, 3:06 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > The easiest way to construct an SQLTable is to use define_table > > > > > > > (as > > > in a model like db.py). > > > > > > > You say 'easiest' - is there an alternative way to instantiate an > > > > > > SQLTable object? > > > > > > > On Nov 19, 9:20 pm, billf <[EMAIL PROTECTED]> wrote: > > > > > > > > OK, I see. The objects passed to itemize are an SQLTable and, > > > > > > > optionally, an SQLQuery, that basically filters the rows returned. > > > > > > > The easiest way to construct an SQLTable is to use define_table > > > > > > > (as > > > in > > > > > > > a model like db.py). That's why I was suggesting an in-memory > > > > > > > database which Massimo has now implemented in trunk. > > > > > > > > So you should be able to say (I haven't tested this and the while > > > is > > > > > > > pseudo-code): > > > > > > > > dbm=SQLDB('sqlite:memory:') > > > > > > > > dbm.define_table('temp_data',SQLField('temp_field1),SQLField > > > > > > > ('temp_field2'), etc) > > > > > > > > while creating_temp_data: > > > > > > > dbm.temp_data.insert(temp_field1='X',temp_field2='Y') > > > > > > > > t2.itemize(dbm.temp_data) > > > > > > > > And all the temp data is just held in memory. Does that help? > > > > > > > > On Nov 19, 8:49 am, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > > > When you say "these tables are Python objects", I assume you > > > are > > > > > > > > > refererring to your temporary data(?) > > > > > > > > > No, to the table input to itemize. This input is a python > > > > > > > > object. > > > So > > > > > > > > can this object be instantiated directly without going through a > > > > > > > > database? > > > > > > > > > On Nov 19, 5:36 pm, billf <[EMAIL PROTECTED]> wrote: > > > > > > > > > > When you say "these tables are Python objects", I assume you > > > are > > > > > > > > > refererring to your temporary data(?) > > > > > > > > > > The "detour" above about in-memory tables was just to provide > > > an > > > > > > > > > alternative to making your own itemize, i.e.: > > > > > > > > > - define your temp tables as in-memory tables > > > > > > > > > - insert your "rows" instead of appending to your Python > > > objects > > > > > > > > > - pass the in-memory tables to the existing itemize > > > > > > > > > > (Apologies if that was stating the obvious) > > > > > > > > > > On Nov 18, 10:48 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > These tables are Python objects, so is there a way to > > > instantiate them > > > > > > > > > > without a database? > > > > > > > > > > > Otherwise I'll do as you suggest, Bill, and make my own > > > itemize. > > > > > > > > > > Baron > > > > > > > > > > > On Nov 19, 12:33 am, billf <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > > > > > I don't think you can - as you say itemize takes tables > > > > > > > > > > > and > > > an > > > > > > > > > > >
[web2py:12495] Re: itemize temporary data
What are you suggesting? On Nov 25, 11:17 pm, Baron <[EMAIL PROTECTED]> wrote: > thanks guys for your advice. > > > I would just take the code out of t2 itemize and adapt to your purposes. It > > is relatively small. > > I did suggest at the outset (18/11) that creating a new version of itemize > > was probably the easiest solution :-). > > As I said I already have my own itemize function. But I'm trying to > reuse T2 where practical/possible. > Is T2 intended to stay as a link between model and view, or will it be > abstracted for the controller? > > Baron > > On Nov 22, 10:15 am, billf <[EMAIL PROTECTED]> wrote: > > > I did suggest at the outset (18/11) that creating a new version of > > itemize was probably the easiest solution :-). > > > The in-memory database was just a response to "how can I pass data to > > itemize?" - not a recommendation. > > > On Nov 21, 10:18 pm, "Yarko Tymciurak" <[EMAIL PROTECTED]> wrote: > > > > On Fri, Nov 21, 2008 at 4:15 PM, mdipierro <[EMAIL PROTECTED]> wrote: > > > > > The fact we can store a database in memory does not mean this is the > > > > right solution to your problem. > > > > > I would just take the code out of t2 itemize and adapt to your > > > > purposes. It is relatively small. > > > > +1 > > > > > itemize does very very little for you so I doubt you need it. > > > > > Massimo > > > > > On Nov 21, 4:07 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > > sorry, I may have my object types wrong. > > > > > > To summarize: > > > > > I'm trying to pass data directly to t2.itemize() without having to > > > > > write to a database. > > > > > > If I understood right, Bill was hinting that writing to an in-memory > > > > > database was the easiest way, so I was wondering what was the harder > > > > > alternative way. > > > > > I was hoping there was a way to directly instantiate the required > > > > > input for t2.itemize() directly without going through a database. > > > > > Writing to a temporary in-memory database 'smells' bad for me. > > > > > > For now I've created my own itemize. > > > > > > Baron > > > > > > On Nov 21, 8:11 am, mdipierro <[EMAIL PROTECTED]> wrote: > > > > > > > What for? SQLTable or SQLTABLE? I am confused. > > > > > > > Massimo > > > > > > > On Nov 20, 3:06 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > > The easiest way to construct an SQLTable is to use define_table > > > > > > > > (as > > > > in a model like db.py). > > > > > > > > You say 'easiest' - is there an alternative way to instantiate an > > > > > > > SQLTable object? > > > > > > > > On Nov 19, 9:20 pm, billf <[EMAIL PROTECTED]> wrote: > > > > > > > > > OK, I see. The objects passed to itemize are an SQLTable and, > > > > > > > > optionally, an SQLQuery, that basically filters the rows > > > > > > > > returned. > > > > > > > > The easiest way to construct an SQLTable is to use define_table > > > > > > > > (as > > > > in > > > > > > > > a model like db.py). That's why I was suggesting an in-memory > > > > > > > > database which Massimo has now implemented in trunk. > > > > > > > > > So you should be able to say (I haven't tested this and the > > > > > > > > while > > > > is > > > > > > > > pseudo-code): > > > > > > > > > dbm=SQLDB('sqlite:memory:') > > > > > > > > > dbm.define_table('temp_data',SQLField('temp_field1),SQLField > > > > > > > > ('temp_field2'), etc) > > > > > > > > > while creating_temp_data: > > > > > > > > dbm.temp_data.insert(temp_field1='X',temp_field2='Y') > > > > > > > > > t2.itemize(dbm.temp_data) > > > > > > > > > And all the temp data is just held in memory. Does that help? > > > > > > > > > On Nov 19, 8:49 am, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > When you say "these tables are Python objects", I assume you > > > > are > > > > > > > > > > refererring to your temporary data(?) > > > > > > > > > > No, to the table input to itemize. This input is a python > > > > > > > > > object. > > > > So > > > > > > > > > can this object be instantiated directly without going > > > > > > > > > through a > > > > > > > > > database? > > > > > > > > > > On Nov 19, 5:36 pm, billf <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > When you say "these tables are Python objects", I assume you > > > > are > > > > > > > > > > refererring to your temporary data(?) > > > > > > > > > > > The "detour" above about in-memory tables was just to > > > > > > > > > > provide > > > > an > > > > > > > > > > alternative to making your own itemize, i.e.: > > > > > > > > > > - define your temp tables as in-memory tables > > > > > > > > > > - insert your "rows" instead of appending to your Python > > > > objects > > > > > > > > > > - pass the in-memory tables to the existing itemize > > > > > > > > > > > (Apologies if that was stating the obvious) > > > > > > > > > > > On Nov 18, 10:48 pm, Baron <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > These tables are Python objects, so is there a way to > > > > instantiate them > > > > > > > > > > > without a database? >
[web2py:12496] Re: IS_IN_DATASET validator for filling SELECT with data from code not database
Ah, thought there must be an existing way of doing it but I didn't realise you could use 'labels=' with IS_IN_SET :-) On Nov 26, 1:59 am, DenesL <[EMAIL PROTECTED]> wrote: > cj, wouldn't that be equivalent to: > > db.table.myField.requires=IS_IN_SET([0,1,2],labels=[T('Alpha'), T > ('Beta'),T('Gamma')]) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---