[web2py] Re: Where should I put functions that are useful/common to muliple applications?
I suppose you could use URL(a=??) in order to share those files across apps although I think that's fairly uncommon. I find that I learn SQL even as I use DAL. But if you still do want to use raw SQL you can use the DAL's db.executesql() function. But you lose a ton of DAL functionality. --
[web2py] T function and database records - html entities
Hi all, I'm using the T function to produce some text in a multilingual application, but I'm facing a small problem. If i use T('Aller à') I receive the exact same string but when using T(' blabla') I receive 'gt; blabla'. In the second case the greater than sign is correctly rendered in html entity whereas the letter 'à' is not. Am I doing something wrong ? I have similar problems when putting text in a database table, some characters are converted to html entities others not. Any idea / comment welcome. Thanks for your time. --
[web2py] Re: web2py.app runs live from Dropbox - and backups on dropbox
lol, cool. Incidently, Dropbox is also a Python app. On Wednesday, 15 August 2012 16:57:24 UTC+1, Rob_McC wrote: *Just for information... * I backup my web2py files (.app) on dropbox free account https://www.dropbox.com/ This works well for me as a clould solution, quick, easy and fast backup of my work. I guess I shouldn't have been surprised... but I was, when I found I could *run and edit web2py directly from my dropbox* (screenshot attached) ~Rob --
[web2py] Re: web2py.app runs live from Dropbox - and backups on dropbox
As you say, it shouldn't be a surprise because the dropbox folder is just like any other folder, but it also seems like a good solution for anyone working alone and using the same dev system at home and the office. --
[web2py] Re: incorporate carsales from web into web2py on my computer
Tar is simply to decompress the folder. On windows I believe you could for example use 7-zip http://www.7-zip.org to do that. On Friday, August 17, 2012 6:29:59 AM UTC+1, jayvandal wrote: I put my applications in c:/python27/projects i make my application = cars I change my directory to cars I run some program tar zxvf/\/c:/web2py/applications/web2py.app.carsale.w2p i am running Vista what should tar zxvf be in Vista? I think web2py is good for learning web in python! I appreciate your help On Thursday, August 16, 2012 8:11:24 PM UTC-6, Massimo Di Pierro wrote: BTW... it is a very simple example written by a student. On Thursday, 16 August 2012 21:11:01 UTC-5, Massimo Di Pierro wrote: You should use admin to install applications. If you want to do it manually you need do cd applications mkdir appname cd appname tar zxvf /path/to/web2py.app.carsales.w2p at voila'? The w2p files do not contain the parent folder because, to avoid conflict, they want you to name the app. On Thursday, 16 August 2012 20:55:52 UTC-5, jayvandal wrote: I down;oaded a file of web2py examples and I wanted to put carsales in my web2py applications sso I could see how the application looks. I downloaded the file that contained car sales and unzipped it .I thought I could unzip it into my folder projects where I could have my applications.I cannot see the carsales application. what is the manner I can use to do this? --
Re: [web2py] Auth with Google Oauth2 - Google Plus, Gmail and other scopes
Hi Bruno, Can we get an update on this? Thanks On Tuesday, January 17, 2012 4:44:16 AM UTC+11, rochacbruno wrote: yes we can! the difference is only some keys passed to auth and token url, also the redirect page and the api caller. I think we can create an api proxy to decide which class to use and have the google/facebook/linkedin etc mappings in a single file. I will try and if works I send a patch. http://zerp.ly/rochacbruno Em 16/01/2012 09:25, Michele Comitini michele@gmail.comjavascript: escreveu: Hi Bruno, Do you think we can integrate all in one oath20 module? tnx mic 2012/1/16 Bruno Rocha rocha...@gmail.com javascript:: Hi, I just implemented Google Connect Oauth2 in http://movu.ca/demo If someone interested in the code it is in https://github.com/rochacbruno/Movuca/blob/master/modules/oauth20_account_google.py (modified module) https://github.com/rochacbruno/Movuca/blob/master/modules/helpers/googleplus.py (modified handler, can go in models or modules) https://github.com/rochacbruno/Movuca/blob/master/modules/handlers/person.py#L378 (action handler) https://github.com/rochacbruno/Movuca/blob/master/controllers/person.py#L95 (controller) It is based in the facebook version with some changes, but still needs improvements. To use it you have to create API keys in https://code.google.com/apis/console/ and the other things will be just like the facebook version. I guess the twitter version can be implemented in the same way. ** im my code I am using Movuca config to get the option values, you just need to replace them with your API keys. I also found an issue in Auth http://code.google.com/p/web2py/issues/detail?id=616 -- Bruno Rocha [http://rochacbruno.com.br] --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Hi Rob I hope Massimo will consider to incorporate this into Welcome. It is much to the credit of web2py that security is given top priority and it is apt that the default scheme should be a thoughtful implementation. A well thought out Auth configuration is useful to everyone and the fact that it mirrors Gmail makes it a notable feature. For those that don't like it, it is much easier to disable or water-down than it is to reinvent -- as this thread amply illustrates. Otherwise, as this is more of a configuration rather than an app, I would suggest uploading it as a recipe to web2pyslices. Many thanks, David --
[web2py] Best way to insert 200k records?
Hello: What is the prescribed method for doing large bulk inserts? I am using sqllite as my backend. Is it ok to just write a Python script that talks to the db directly or should the DAL be used? The book says the bulk_insert method is not more advantageous than a for loop. I searched this group for an answer but didn't find anything definitive. Thanks. PS Kudos to the web2py creator and contributors. Every day I am struck by how elegant, easy and well-designed it is. --
[web2py] Catch rows in Javascript
Hi, How can I catch rows in Javascript code ? Thanks Mathias --
Re: [web2py] Best way to insert 200k records?
Maybe you can face transaction size problems with this volume. Web2py, by default, just commits after a successful transaction. So, try to db.commit() after some transaction completion identification. But I think processing time wouldn't be your problem. -- Vinicius Assef On 08/17/2012 08:50 AM, Mike Girard wrote: Hello: What is the prescribed method for doing large bulk inserts? I am using sqllite as my backend. Is it ok to just write a Python script that talks to the db directly or should the DAL be used? The book says the bulk_insert method is not more advantageous than a for loop. I searched this group for an answer but didn't find anything definitive. Thanks. PS Kudos to the web2py creator and contributors. Every day I am struck by how elegant, easy and well-designed it is. --
Re: [web2py] Best way to insert 200k records?
But what method should I use? Is there anything better than bulk_insert? Naturally I would like this to work as fast as possible. Thanks. --
[web2py] Re: Best way to insert 200k records?
You can enter either via db(query).insert(name=value, ...) or by a CSV file. Both are convenient. I suppose you could argue that CSV is convenient if your data are dumped from some other db without computing an intermediate value. If your data are less clean, perhaps, or you need to do some complex intermediate logic and computation on the fly to come up with a value to insert into the db, or just for all around flexibility, then db(query).insert(...) works great. Both are equally useful. I use both all the time. Mostly, it depends on the source of data and how ready they are to insert into the db without me having to muck with them. --
Re: [web2py] Best way to insert 200k records?
I'd choose bulk_insert, but you should run some benchmarks, too. On 08/17/2012 09:08 AM, Mike Girard wrote: But what method should I use? Is there anything better than bulk_insert? Naturally I would like this to work as fast as possible. Thanks. --
[web2py] Re: Where should I put functions that are useful/common to muliple applications?
CSS belongs under static. Packages and common routines belong under modules and are imported. You could have a common static and modules and symbolically link. I have never done that, but it makes sense. I suppose you could also put the CSS just about anywhere on the file system. And modules could be put under the python package library and imported from there. I haven't tried that, but seems like it would work. On Friday, August 17, 2012 11:57:02 AM UTC+8, curiouslearn wrote: Hello, What is the recommended place in web2py folder where I should store custom functions that are useful to multiple applications? For example, suppose I have a function such as the following: *def connecttodb():* *if request.is_local:* *user=user* *passwd=passed* *host=localhost* *else:* *user=user_nonlocal* *passwd=passwd_nonlocal* *host=nonlocalhost* *con = mdb.connect(user=user,* * passwd=passwd,* * host=host)* *c = con.cursor()* *return con, c* I will need this in every application. Further, if I decide to change the host, I have to go and change the values in every application. There are other useful functions common to all applications. Can I just store them in one folder and import them, so that they work both on local and web hosts? If so, where do you recommend I save them? Thank you. --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- --
Re: [web2py] Best way to insert 200k records?
I would do commit after each 1 inserts data #some array of dicts for i in xrange(len(data)): db.table.insert(**data[i]) if i%1==0: db.commit() db.commit() --
[web2py] Re: Best way to insert 200k records?
The data will be coming from a large XML file, so my script will parse that and make inserts into several different tables. It's fairly straightforward. So is it correct to say that - 1. There is no compelling reason to do this without the DAL 2. My options in the DAL are bulk_insert, looping db.query and csv import and that performance wise they're similar? --
[web2py] How to email attachment with original filename
How can I email uploaded files with the original file name? I realize it is possible to make a copy of the file with the original name and attach that, but that seems like a waste of resources. Is there a better way? thanks, Cliff Kachinske --
[web2py] Re: How to email attachment with original filename
I'm currently storing the files as BLOBs in MySQL along with a field for the filename. That has been working for me. On Friday, August 17, 2012 8:35:38 AM UTC-4, Cliff Kachinske wrote: How can I email uploaded files with the original file name? I realize it is possible to make a copy of the file with the original name and attach that, but that seems like a waste of resources. Is there a better way? thanks, Cliff Kachinske --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Thanks David and Anthony: 1- I will reorder validtors for final example, most common ones first. 2- Good suggestion: I'll try to write a web2pyslices, I like that site a lot as it can offer more complete solutions than these discussions often do. 2- A validator? *Question:* Would it be worth considering an actual validator for username and user-like fields. *IS_LIKE_GOOGLE* IS_LIKE_GOOGLE validator enforces a username policy similar to Google Accounts (as of 2012), min 6 - 30 characters, only letters (a-z) and numbers (0-9), and periods, can't start or end with a period, can't have consecutive periods, and of course can't exist in database. Note: if an optional IS_LIKE_GOOGLE(db, 'table.fieldname') - then any user created user type field would be validated, Cheers, Today, I'm going to work on bad words in username feature, this should complete my example. Rob --
[web2py] Re: Electronic voting anybody?
Thanks Massimo for your attention to matter. Note 1) is actually a feature. All ballots are always public. OK, I get it it just with real elections, ballots are secret, and handled with such care... but... maybe electronic voting is different... *However *For the public to know the ORDER that the ballots were cast, bothers me a little, for some reason. Rob --
[web2py] Re: How to email attachment with original filename
Attachments take an optional parameter to specify the filename, so what is your current problem ? You have the original name on the table, you have the path on the table, you have the file in the uploads directory. Seems to me that you don't have to copy anything around mail.send('y...@example.com', 'Message subject', 'Message body', attachments = [Mail.Attachment('/path/to/fist.file', filename= myfilename.jpg), Mail.Attachment('/path/to/second.file', filename= myfilename2.zip)]) On Friday, August 17, 2012 2:35:38 PM UTC+2, Cliff Kachinske wrote: How can I email uploaded files with the original file name? I realize it is possible to make a copy of the file with the original name and attach that, but that seems like a waste of resources. Is there a better way? thanks, Cliff Kachinske --
[web2py] Congratulations to Bruno and Mariano
Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
[web2py] Re: Electronic voting anybody?
I like this idea, but when I tried it, this happened: I set up a ballot and received an email, I clicked the link and got the voting page. I voted but immediately received a ticket. --
[web2py] Re: Congratulations to Bruno and Mariano
Congrats ! On Friday, August 17, 2012 9:13:45 AM UTC-5, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Still trying to make my username example, google-like. Google prohibits a very small set of bad words. I have a BADWORDS working outside of the validation, but when I insert in validation, I get error. Any help would be appreciated, I bet it is one little thing :) I get error type 'exceptions.NameError' name 'BADWORDS' is not defined- Thanks! Rob *Summary: * badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] *Complete code, just insert in a new app. like Welcome..* ## - START CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## # | Summary: # | Modify web2py to allow user registrations similar to # | Google registrations. # | i.e. # | - lower case only [a-z] # | - numbers [0-9] and period are OK # | - can't end in a period # | - can't start with a period # | - can't have consecutive periods # | - min 8 letter password # | - username can't be changed once registered # | # | Note: Messages are nearly same as Google displays ## create all tables needed by auth if not custom tables # use usernames rather than email addresses to register auth.define_tables(username=True) # allow username only on registration, but can only # be viewed (readable) in Profile # user can't change username once registered. #if auth.is_logged_in(): #db.auth_user.username.writable = False #db.auth_user.username.readable = True #custom message for password length - like Google # ref: https://groups.google.com/forum/?fromgroups#!searchin/web2py/$20default$20length$20for$20password/web2py/k5os3bMz228/vG-UOLbhcBUJ[1-25] #add a comments to exlain policy db.auth_user.username.comment='NO BAD WORDS..min. 6 letters (a-z), you may use numbers, and periods.' # apply nearly identical username policy and message that Google Accounts use. # this OVERWRITES web2py's default username validation # reference and thanks to web2py community for help: # https://groups.google.com/forum/?fromgroups#!starred/web2py/HBODB00HMfU[1-25] # this import is required in web2py import base64, re #let's assume: # username can't contain spaces, just a-z and periods # 'frig' is a very bad word, and poop too :) # 'sadf' is a racial slur # so even if a person's name as frig, or asdf in it # we will not let them use that. # asdf- is a bad username # asdfyou - is a bad username # youasdf - is a bad username badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] ## - END CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## --
[web2py] Re: Help me to write SQL query in web2py
You can try this: from gluon.dal import Expression t = db.abc_tbl max_created_on = t.max() query = Expression(db,date_sub(now(), interval interval_time minute)) db(query).select(t.device_id,t.sensor_id,t.max(),group_by=t.device_id|t.sensor_id) On Thursday, 16 August 2012 23:01:44 UTC-5, Amit wrote: I have written one sql query: select device_id, sensor_id, max(created_on) from test.abc_tbl where date_sub(now(), interval interval_time minute) created_on group by device_id, sensor_id; How to write it in web2py? Please help me to do the same. Thanks. --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
On 17 Aug 2012, at 7:18 AM, Rob_McC mrmccorm...@gmail.com wrote: Still trying to make my username example, google-like. Google prohibits a very small set of bad words. I have a BADWORDS working outside of the validation, but when I insert in validation, I get error. Any help would be appreciated, I bet it is one little thing :) IS_EXPR is an imported function, and runs in its own namespace. It doesn't see your globals. Rather than use IS_EXPR, you'd be better off writing a custom validator. An added benefit of doing it that way is that you can include the overhead of BADWORDS in the validator's execution code (not its init), so it only gets executed when the validator is actually used. Validators are easy to write. Choose a simple one from gluon/validators.py to use as a template. I suggest IS_EQUAL_TO. I get error type 'exceptions.NameError' name 'BADWORDS' is not defined - Thanks! Rob Summary: badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] Complete code, just insert in a new app. like Welcome.. ## - START CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## # | Summary: # | Modify web2py to allow user registrations similar to # | Google registrations. # | i.e. # | - lower case only [a-z] # | - numbers [0-9] and period are OK # | - can't end in a period # | - can't start with a period # | - can't have consecutive periods # | - min 8 letter password # | - username can't be changed once registered # | # | Note: Messages are nearly same as Google displays ## create all tables needed by auth if not custom tables # use usernames rather than email addresses to register auth.define_tables(username=True) # allow username only on registration, but can only # be viewed (readable) in Profile # user can't change username once registered. #if auth.is_logged_in(): #db.auth_user.username.writable = False #db.auth_user.username.readable = True #custom message for password length - like Google # ref: https://groups.google.com/forum/?fromgroups#!searchin/web2py/$20default$20length$20for$20password/web2py/k5os3bMz228/vG-UOLbhcBUJ[1-25] #add a comments to exlain policy db.auth_user.username.comment='NO BAD WORDS..min. 6 letters (a-z), you may use numbers, and periods.' # apply nearly identical username policy and message that Google Accounts use. # this OVERWRITES web2py's default username validation # reference and thanks to web2py community for help: # https://groups.google.com/forum/?fromgroups#!starred/web2py/HBODB00HMfU[1-25] # this import is required in web2py import base64, re #let's assume: # username can't contain spaces, just a-z and periods # 'frig' is a very bad word, and poop too :) # 'sadf' is a racial slur # so even if a person's name as frig, or asdf in it # we will not let them use that. # asdf- is a bad username # asdfyou - is a bad username # youasdf - is a bad username badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] ## - END CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## -- --
[web2py] Re: Electronic voting anybody?
Sorry. I was editing the code live. Try now. On Friday, 17 August 2012 09:15:56 UTC-5, villas wrote: I like this idea, but when I tried it, this happened: I set up a ballot and received an email, I clicked the link and got the voting page. I voted but immediately received a ticket. --
[web2py] Re: How to email attachment with original filename
The problem is I didn't pay attention while looking this up in the manual. :) applies palm to forehead On Friday, August 17, 2012 9:53:51 AM UTC-4, Niphlod wrote: Attachments take an optional parameter to specify the filename, so what is your current problem ? You have the original name on the table, you have the path on the table, you have the file in the uploads directory. Seems to me that you don't have to copy anything around mail.send('y...@example.com javascript:', 'Message subject', 'Message body', attachments = [Mail.Attachment('/path/to/fist.file', filename= myfilename.jpg), Mail.Attachment('/path/to/second.file', filename= myfilename2.zip)]) On Friday, August 17, 2012 2:35:38 PM UTC+2, Cliff Kachinske wrote: How can I email uploaded files with the original file name? I realize it is possible to make a copy of the file with the original name and attach that, but that seems like a waste of resources. Is there a better way? thanks, Cliff Kachinske --
[web2py] Source compile error - local vs. remote - frustrating
My site is hosted on webfaction. The web2py src code is the same on local remote - both have the latest web2py src. Compiled my site locally, uploaded to my remote site and I get raise SystemError, 'compiled code is incompatible' SystemError: compiled code is incompatible The Webfaction install script says This installs web2py for Python 2.7 along with Apache + mod_wsgi v3.3 ... I do have python 2.5 installed in a different folder outside of web2py and I'm assuming that web2py is not using that installation instance to compile the application. Any suggestions as to how I might remedy this problem would be greatly appreciated. --
Re: [web2py] Source compile error - local vs. remote - frustrating
On 17 Aug 2012, at 7:41 AM, wdtatenh wdt...@comcast.net wrote: My site is hosted on webfaction. The web2py src code is the same on local remote - both have the latest web2py src. Compiled my site locally, uploaded to my remote site and I get raise SystemError, 'compiled code is incompatible' SystemError: compiled code is incompatible The Webfaction install script says This installs web2py for Python 2.7 along with Apache + mod_wsgi v3.3 ... I do have python 2.5 installed in a different folder outside of web2py and I'm assuming that web2py is not using that installation instance to compile the application. Any suggestions as to how I might remedy this problem would be greatly appreciated. A first step would be to verify which versions of Python are involved. Alternatively, compile the app on the server instead. --
[web2py] Adding LinkedIn authentication as an option to existing username/password authentication
Big hat tip to: Udi Milo These steps will enable a Web2py app that currently authenticates users using username/password (or email.password) to add the option for users to use their LinkedIn account instead. Once logged in, the app can access the LinkedIn API to access user LinkedIn data. *1. Go to LinkedIn.com and get your developer key and secret.* *2. Create folder called web2py/linkedin* Place files: linkedin.py, model.py, helper.py from http://code.google.com/p/python-linkedin/ Also create a new file linkedin_wrapper.py this will glue LI api into Web2py framework In this add add: from gluon.http import HTTP try: import linkedin except ImportError: raise HTTP(400,linkedin module not found) class LinkedInAccount(object): def __init__(self,request,session,key,secret,return_url): self.request = request self.session = session if self.session.linkedin is None: self.session.verified = False self.session.linkedin = linkedin.LinkedIn(key,secret,return_url, gae=request.env.web2py_runtime_gae) self.session.linkedin.request_token() def verify(self, verifier): self.session.verified = verifier and self.session.linkedin. access_token(verifier = verifier) return self.session.verified def login_url(self, next=/): return self.session.linkedin.get_authorize_url() def logout_url(self, next=/): self.session.linkedin = None return next def get_user(self): if self.session.verified: profile = self.session.linkedin.get_profile(fields=['id', 'first-name', 'last-name','picture-url','industry']) return dict(first_name = profile.first_name, last_name = profile.last_name, picture_url = profile.picture_url, industry = profile.industry, username = profile.id) *3. In dal/db.py* Just above auth.define_tables() add: # create custom field 'username' for linkedin profile # the data will be pulled by get_user() in linkedin_wrapper.py auth.settings.extra_fields['auth_user']= [ Field('username', writable=False, readable=False), Field('picture_url', writable=False, readable=False), Field('industry', writable=False, readable=False),] at the bottom add: if request.vars.agent == 'linkedin' or session.linkedin: from linkedin.linkedAccount import LinkedInAccount auth.settings.login_form=LinkedInAccount(request, session, [[YOUR_LI_KEY]], [[YOUR_LI_SECRET]], 'http://' + request.env.http_host + '/[[YOUR_APP]]/default/user/verify') auth.settings.actions_disabled=['register','change_password','request_reset_password','retrieve_username'] *4. In your controller (assumed by dal code above to be called default.py)* def user(): if len(request.args)0 and request.args(0)=='verify': auth.settings.login_form.verify(request.vars.oauth_verifier) redirect(URL('user', args='login')) return dict(form=auth()) In your controller functions you can access LinkedIn API at auth.settings. login_form.session.linkedin eg auth.settings.login_form.session.linkedin.get_search() # this function will enable users to login using their LinkedIn account via http://.../[YOUR_APP]/default/agent # and other users to use their username/password via http://.../[YOUR_APP] /default/user def agent(): redirect(URL('user', args='login', vars=dict(agent='linkedin'))) Post reply [image: More message actions] Apr 4 --
[web2py] Re: Electronic voting anybody?
Yep, worked this time! On Friday, August 17, 2012 3:31:26 PM UTC+1, Massimo Di Pierro wrote: Sorry. I was editing the code live. Try now. On Friday, 17 August 2012 09:15:56 UTC-5, villas wrote: I like this idea, but when I tried it, this happened: I set up a ballot and received an email, I clicked the link and got the voting page. I voted but immediately received a ticket. --
[web2py] computed fields are not executed with Table inheritance
Hi all, I've just discovered that the fields defined as computed in the 'upper table' are not executed in the table that inherits the fields. The following is the definition of the upper table pictures_fields = db.Table(db, 'picture', Field(picture, upload, uploadfolder=request.folder+'uploads/pictures', uploadseparate=True, autodelete=True, requires=[IS_NOT_EMPTY(), IS_IMAGE(), IS_UPLOAD_FILENAME(extension='jpg|jpeg|png'),IS_IMAGE(extensions=('jpeg', 'png'))]), Field(normal, upload, uploadfolder=request.folder+'uploads/pictures', uploadseparate=True, autodelete=True, requires=[IS_IMAGE()]), Field(thumbnail, upload, uploadfolder=request.folder+'uploads/pictures', uploadseparate=True, autodelete=True, requires=[IS_IMAGE()]), Field('picture_desc', 'text', requires=[IS_TRIM(), IS_LENGTH(140,error_message=T('Warning, description too long'))]), ) pictures_fields.thumbnail.compute = lambda row: THUMBER(row.picture, 200, 200, name='thumb') pictures_fields.normal.compute = lambda row: THUMBER(row.picture, 600, 600, name='normal') pictures_fields.picture_desc.label = T('Picture description') What is wrong? Regards, paolo --
Re: [web2py] Congratulations to Bruno and Mariano
Parabéns Bruno! - Felicitaciones Mariano! 2012/8/17 Massimo Di Pierro massimo.dipie...@gmail.com Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html -- --
[web2py] Re: How to find duplicate rows with Web2py DAL
Thanks a lot. BR Loreia On Thursday, August 16, 2012 1:23:39 PM UTC+2, Niphlod wrote: group by your unique columns, count the rows, find the ones with count 1. db.define_table( 'finddup', Field('f1_name'), Field('f2_name'), Field('f3_name') ) fd = db.finddup count = fd.id.count() rtn = db(fd.id0).select(fd.f1_name, fd.f2_name, fd.f3_name, count,groupby =fd.f1_name|fd.f2_name|fd.f3_name, having=count1) On Thursday, August 16, 2012 11:20:54 AM UTC+2, Loreia wrote: Hi, I am looking for a way to automatically find any possible duplicate records (rows) in one table of my Postgres database. Quick google-ing reveals it is easy to do it with pure SQL, e.g. one way specific for Postgres: http://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries-in-postgresql But I would like to be able to do it with web2p DAL (which would make it database independent). Is there a way to do it with web2py DAL? I just want to be able to find those duplicates, I don't need to delete them. Thank you and best regards, Loreia --
[web2py] Select a table given its table name?
Hi, I want to achieve something like this: def feed(table): return db(db.table.id0).select() How should the code be written? Thanks! --
Re: [web2py] Select a table given its table name?
def feed(table): return db(db[table].id0).select() --
Re: [web2py] Select a table given its table name?
Thank you Bruno! That was quick! On Friday, August 17, 2012 11:37:58 PM UTC+8, rochacbruno wrote: def feed(table): return db(db[table].id0).select() --
[web2py] Re: Congratulations to Bruno and Mariano
Congratulations, guys!! On Friday, August 17, 2012 10:13:45 PM UTC+8, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
Re: [web2py] Source compile error - local vs. remote - frustrating
Thanks - I'm installing python 2.7 on my machine and that should resolve the problem. --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
OK. Im getting close, but Im stuck on the following SQLAlchemy code conversion: recipients = relationship( 'Recipient', secondary = mr_link, backref = 'message', lazy = 'dynamic' ) attachments = relationship( 'Attachment', secondary = ma_link, backref = 'message', lazy = 'dynamic' ) I don't see how to adapt this in the manual. TIA, Larry On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote: Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- --
Re: [web2py] Re: Congratulations to Bruno and Mariano
+1! 2012/8/17 lyn2py lyn...@gmail.com: Congratulations, guys!! On Friday, August 17, 2012 10:13:45 PM UTC+8, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html -- --
[web2py] web2py and python 2.7 - won't compile
Installed python 2.7. Trying to start up web2py and I get the following traceback - note URLLIB and SOCKET are located in ...python27/Lib Appreciate help. No handlers could be found for logger web2py Traceback (most recent call last): File web2py.py, line 16, in module import gluon.widget File c:\web2py\gluon\__init__.py, line 15, in module from globals import current File c:\web2py\gluon\globals.py, line 18, in module from streamer import streamer, stream_file_or_304_or_206, DEFAULT_CHUNK_SIZE File c:\web2py\gluon\streamer.py, line 15, in module import rewrite File c:\web2py\gluon\rewrite.py, line 24, in module import urllib File C:\Python27\lib\urllib.py, line 26, in module import socket File C:\Python27\lib\socket.py, line 47, in module import _socket ImportError: DLL load failed: The specified module could not be found. --
Re: [web2py] Re: Can't import external modules
Indeed I wrote the patch to allow raising a meaningful error if the module is not loaded. The action taken should be the same as before the patch i.e.: return super(_Web2pyImporter, self).__call__(name, globals, locals, fromlist, level) but the error from the call is raised instead of resulting in a stack trace ending in custom_import.py. Even with this exception stack trace can be misleading sometimes. I also experienced invisibility of modules. What I found is that creating an instance by doing: python web2py.py -S my_new_app works. While doing things by copying or hand sometimes make the modules directory content not importable... I would be interesting to know if it is just OSX or any that has problems. mic Il giorno venerdì 17 agosto 2012 01:19:30 UTC+2, Massimo Di Pierro ha scritto: Can you help us test this. If anything caused it, could be changeset: 3324:ef7523559742 --- a/gluon/custom_import.py Wed Jun 06 11:37:28 2012 -0500 +++ b/gluon/custom_import.py Thu Aug 16 18:18:23 2012 -0500 @@ -287,14 +287,14 @@ return super(_Web2pyImporter, self) \ .__call__(modules_prefix+.+name, globals, locals, fromlist, level) -except ImportError: -pass +except ImportError, e: +try: +return super(_Web2pyImporter, self).__call__(name, globals, locals, +fromlist, level) +except ImportError, e1: +raise e return super(_Web2pyImporter, self).__call__(name, globals, locals, fromlist, level) -#except Exception, e: -#raise e # Don't hide something that went wrong -#finally: -self.end() If you revert it, does the problem go away? massimo On Thursday, 16 August 2012 15:52:54 UTC-5, Matt wrote: On Thursday, August 16, 2012 12:24:34 AM UTC-4, Matt wrote: On Wed, Aug 15, 2012 at 10:03 PM, Anthony abas...@gmail.com wrote: Is there any way around this? This seems to have broken only with the upgrade to Mountain Lion. We develop this app primarily on (and for) linux, however I do most of my development on my laptop, so it's quite inconvenient to have to use a separate install just on this computer. Do you have any idea where to look in order to solve this problem? I am very willing (and motivated!) to help fix this problem. What are you trying to work around? If you want to use the Python installed on your system along with any modules you may have installed with it, then just run the source version of web2py -- it works fine on OS X and is just as easy to install (just download and unzip). What do you mean by a separate install just on this computer -- you'll need web2py installed on any computer on which you want to use it? I might be experiencing a different problem here. I'm currently having a problem where I can no longer import modules from the modules directory in my application on osx. I've updated to the latest 1.99.7 to no avail, and am currently trying to work through why it's no longer loading properly (this worked just fine in 1.99.4, but as I said I also upgraded to Mountain Lion this past weekend). I fixed this problem by just using local_import. I was under the impression this method was deprecated and I should just be able to use import directly. Hope this helps someone Anthony -- --
[web2py] Re: Catch rows in Javascript
How can I catch rows in Javascript code ? What does this mean? Can you give an example? --
[web2py] New Django REST library
Worth taking a look at: https://github.com/freshplum/django-simple-rest --
[web2py] Re: Best way to insert 200k records?
On Friday, August 17, 2012 8:29:12 AM UTC-4, Mike Girard wrote: The data will be coming from a large XML file, so my script will parse that and make inserts into several different tables. It's fairly straightforward. So is it correct to say that - 1. There is no compelling reason to do this without the DAL 2. My options in the DAL are bulk_insert, looping db.query and csv import and that performance wise they're similar? 2 is correct (as long as you are going through the DAL; db.executesql would be the non-DAL way from within web2py - and of course, you could use your DB's native facilities) 1. Is correct if you are not doing this often - e.g., it might take 10 minutes as opposed to 1 minute without DAL (just assuming, not based on any actual measurement). So what? If you do this once an hour, then DAL processing and the individual record insertion (even if you use bulk_insert or csv) might make it too slow for you, and you would be better off looking at your database's native bulk loading facilities. --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
IS_EXPR executes the expression in an environment that only contains the value being validated (but not any other globals defined in your model). For this to work, you would have to include all of the necessary code in the expression (i.e., the definition of badlist and BADWORDS). A better option is probably a custom validator. Anthony On Friday, August 17, 2012 10:18:57 AM UTC-4, Rob_McC wrote: Still trying to make my username example, google-like. Google prohibits a very small set of bad words. I have a BADWORDS working outside of the validation, but when I insert in validation, I get error. Any help would be appreciated, I bet it is one little thing :) I get error type 'exceptions.NameError' name 'BADWORDS' is not defined- Thanks! Rob *Summary: * badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] *Complete code, just insert in a new app. like Welcome..* ## - START CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## # | Summary: # | Modify web2py to allow user registrations similar to # | Google registrations. # | i.e. # | - lower case only [a-z] # | - numbers [0-9] and period are OK # | - can't end in a period # | - can't start with a period # | - can't have consecutive periods # | - min 8 letter password # | - username can't be changed once registered # | # | Note: Messages are nearly same as Google displays ## create all tables needed by auth if not custom tables # use usernames rather than email addresses to register auth.define_tables(username=True) # allow username only on registration, but can only # be viewed (readable) in Profile # user can't change username once registered. #if auth.is_logged_in(): #db.auth_user.username.writable = False #db.auth_user.username.readable = True #custom message for password length - like Google # ref: https://groups.google.com/forum/?fromgroups#!searchin/web2py/$20default$20length$20for$20password/web2py/k5os3bMz228/vG-UOLbhcBUJ[1-25] #add a comments to exlain policy db.auth_user.username.comment='NO BAD WORDS..min. 6 letters (a-z), you may use numbers, and periods.' # apply nearly identical username policy and message that Google Accounts use. # this OVERWRITES web2py's default username validation # reference and thanks to web2py community for help: # https://groups.google.com/forum/?fromgroups#!starred/web2py/HBODB00HMfU[1-25] # this import is required in web2py import base64, re #let's assume: # username can't contain spaces, just a-z and periods # 'frig' is a very bad word, and poop too :) # 'sadf' is a racial slur # so even if a person's name as frig, or asdf in it # we will not let them use that. # asdf- is a bad username # asdfyou - is a bad username # youasdf - is a bad username badlist = ['frig', 'asdf', 'poop'] BADWORDS = re.compile(r'|'.join(badlist)) auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_EXPR(BADWORDS.search(value), error_message='Bad word'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] ## - END CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
*Question:* Would it be worth considering an actual validator for username and user-like fields. *IS_LIKE_GOOGLE* IS_LIKE_GOOGLE validator enforces a username policy similar to Google Accounts (as of 2012), min 6 - 30 characters, only letters (a-z) and numbers (0-9), and periods, can't start or end with a period, can't have consecutive periods, and of course can't exist in database. Note: if an optional IS_LIKE_GOOGLE(db, 'table.fieldname') - then any user created user type field would be validated, Not a bad idea, but I would make it more generic and configurable, much like the IS_STRONG validator for passwords. Maybe something like IS_USERNAME, and have it take several arguments to configure the various validation options (including ability to provide a custom bad words list, and custom error messages for each potential problem). Anthony --
Re: [web2py] Congratulations to Bruno and Mariano
Mazel tov! Samuel Marks On Sat, Aug 18, 2012 at 12:13 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html -- --
[web2py] define existing tables
Hi, I am writing an app to connect to and run some functions against a PrestaShop Database on MySQL. There are a lot of fields and a lot of tables in the databases which would take quite some time to create define_table for all of them. Does anyone know of any automation script that exists where I can give the connection parameters for my database and have it generate the define_table structures for me? Many Thanks Simon Carr --
[web2py] Re: web2py does not start as windows service
I've just join the group today searching for the answer to the same problem as you. I've read dozens of post and will try some of this: - at the en of this post https://groups.google.com/forum/?fromgroups#!searchin/web2py/service$20windows/web2py/j-NT5gsMasE/SQV3g-kHHp8J[1-25]is described a posible solution - others talk about the need to install Mark Hammond's Win32 Extensions, though it seems if for another service problem (not the timeout one we both have): http://starship.python.net/~skippy/win32/ http://python.net/crew/mhammond/win32/Downloads.html - some wrote that password='recycle' should be written in Window like password=recycle BTW: I'm trying at W2000Professional and W2000Server. On Tuesday, May 15, 2012 11:15:38 PM UTC+2, Fernando Macedo wrote: Hello all, I need some help on this. I'm trying to distribute my app as an exe file, and it should run as a windows service. Tested on trunk an also with windows binary distro. The web2py was registered as windows service, but don't starts. D:\web2py_winweb2py.exe -W install web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.7 (2012-03-04 22:12:08) stable Database drivers available: SQLite3, pymysql, pg8000, IMAP Starting hardcron... Installing service web2py Changing service configuration Service updated D:\web2py_winweb2py.exe -W start web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.7 (2012-03-04 22:12:08) stable Database drivers available: SQLite3, pymysql, pg8000, IMAP Starting hardcron... Starting service web2py Error starting service: O serviþo nÒo respondeu Ó requisiþÒo de inÝcio ou contro le em tempo hßbil. D:\web2py_win I got the error Erro 1053: O serviço não respondeu à requisição de início ou controle em tempo hábil., It's from Windows Os (in portuguese), something like Error 1053: The service did not respond to the start or control request in a timely manner. options.py as default: 1. #!/usr/bin/python 2. # -*- coding: utf-8 -*- 3. 4. # when web2py is run as a windows service (web2py.exe -W) 5. # it does not load the command line options but it 6. # expects to find conifguration settings in a file called 7. # 8. # web2py/options.py 9. # 10. # this file is an example for options.py 11. 12. import socket 13. import os 14. 15. ip = '0.0.0.0' 16. port = 80 17. interfaces=[('0.0.0.0',80),('0.0.0.0',443,'ssl_private_key.pem', 'ssl_certificate.pem')] 18. password = 'recycle' # ## recycle means use the previous password 19. pid_filename = 'httpserver.pid' 20. log_filename = 'httpserver.log' 21. profiler_filename = None 22. #ssl_certificate = 'ssl_certificate.pem' # ## path to certificate file 23. #ssl_private_key = 'ssl_private_key.pem' # ## path to private key file 24. #numthreads = 50 # ## deprecated; remove 25. minthreads = None 26. maxthreads = None 27. server_name = socket.gethostname() 28. request_queue_size = 5 29. timeout = 30 30. shutdown_timeout = 5 31. folder = os.getcwd() 32. extcron = None 33. nocron = None Any adeas? Thanks in advance, Fernando Macedo --
Re: [web2py] Select a table given its table name?
How to get the list of the fields names? On Friday, August 17, 2012 6:37:58 PM UTC+3, rochacbruno wrote: def feed(table): return db(db[table].id0).select() --
[web2py] Re: Congratulations to Bruno and Mariano
besides congratulations, what do you eat ? maybe this is the reason for being smart. Ashraf On Friday, August 17, 2012 5:13:45 PM UTC+3, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
Re: [web2py] Re: Congratulations to Bruno and Mariano
deservedly a double Pythonistas Ovidio Marinho Falcao Neto Web Developer ovidio...@gmail.com ovidiomari...@itjp.net.br ITJP - itjp.net.br 83 8826 9088 - Oi 83 9334 0266 - Claro Brasil 2012/8/17 apps in tables ad...@aqar-riyadh.com besides congratulations, what do you eat ? maybe this is the reason for being smart. Ashraf On Friday, August 17, 2012 5:13:45 PM UTC+3, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.**br/2012/08/welcome-new-psf-**members.htmlhttp://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html -- --
[web2py] Re: Congratulations to Bruno and Mariano
or congratulating offering cookies ;-P On Friday, August 17, 2012 8:38:07 PM UTC+2, apps in tables wrote: besides congratulations, what do you eat ? maybe this is the reason for being smart. Ashraf --
[web2py] Re: How to find duplicate rows with Web2py DAL
np. BTW: no simple ways to do that. Just mind that if there are millions rows (especially if the columns are not indexed) that is going to take some time. On Friday, August 17, 2012 5:09:40 PM UTC+2, Loreia wrote: Thanks a lot. BR Loreia On Thursday, August 16, 2012 1:23:39 PM UTC+2, Niphlod wrote: group by your unique columns, count the rows, find the ones with count 1. db.define_table( 'finddup', Field('f1_name'), Field('f2_name'), Field('f3_name') ) fd = db.finddup count = fd.id.count() rtn = db(fd.id0).select(fd.f1_name, fd.f2_name, fd.f3_name, count,groupby =fd.f1_name|fd.f2_name|fd.f3_name, having=count1) On Thursday, August 16, 2012 11:20:54 AM UTC+2, Loreia wrote: Hi, I am looking for a way to automatically find any possible duplicate records (rows) in one table of my Postgres database. Quick google-ing reveals it is easy to do it with pure SQL, e.g. one way specific for Postgres: http://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries-in-postgresql But I would like to be able to do it with web2p DAL (which would make it database independent). Is there a way to do it with web2py DAL? I just want to be able to find those duplicates, I don't need to delete them. Thank you and best regards, Loreia --
[web2py] Re: How to email attachment with original filename
no problem. It's just that sometimes questions seems sketchy and I really don't understand what the issue really is. Fortunately manual (and source code) are handy :P On Friday, August 17, 2012 4:36:23 PM UTC+2, Cliff Kachinske wrote: The problem is I didn't pay attention while looking this up in the manual. :) applies palm to forehead --
Re: [web2py] Select a table given its table name?
db.mytable.fields returns a list of the field names, and db.mytable.fields() returns a copy of that list (so if you mutate the copy, the original list doesn't change). Anthony On Friday, August 17, 2012 2:27:22 PM UTC-4, apps in tables wrote: How to get the list of the fields names? On Friday, August 17, 2012 6:37:58 PM UTC+3, rochacbruno wrote: def feed(table): return db(db[table].id0).select() --
[web2py] Re: Best way to insert 200k records?
10 minutes is all right. Still, if there are two methods and they are qualitatively equal apart from speed, I'd prefer to use the faster one. So posing the question, once again, is there a compelling reason to use the DAL for bulk uploads. More specficially, what extras, if any, are being added by the DAL for inserts that a bulk insert using SQLLite directly won't add? On Friday, August 17, 2012 12:58:01 PM UTC-4, nick name wrote: On Friday, August 17, 2012 8:29:12 AM UTC-4, Mike Girard wrote: The data will be coming from a large XML file, so my script will parse that and make inserts into several different tables. It's fairly straightforward. So is it correct to say that - 1. There is no compelling reason to do this without the DAL 2. My options in the DAL are bulk_insert, looping db.query and csv import and that performance wise they're similar? 2 is correct (as long as you are going through the DAL; db.executesql would be the non-DAL way from within web2py - and of course, you could use your DB's native facilities) 1. Is correct if you are not doing this often - e.g., it might take 10 minutes as opposed to 1 minute without DAL (just assuming, not based on any actual measurement). So what? If you do this once an hour, then DAL processing and the individual record insertion (even if you use bulk_insert or csv) might make it too slow for you, and you would be better off looking at your database's native bulk loading facilities. --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
It depends on context. Web2py DAL is closer to SQL than on ORM. Assuming db.define_table('person',Field('name'),Field('email')) you have two options: 1) db.define_table('message',Field('body'),Field('recipients','list:reference person')) for row in db(db.message).select(): # one select for recipient in row.recipents: print recipient.name # one select per recipient to get name (lazy) 2) db.define_table('message',Field('body')) db.define_table('recipient',Field('message',db.message),Field('person',db.person)) for message in db(db.message).select(): for recipient in message.recipient.select() # one select/message print recipient.person.name # one select/recipient or with a single select using joins: for row in db(db.message.id==db.recipient.message)(db.recipient.person==person.id).select() print row.message.body, row.person.id On Friday, 17 August 2012 11:01:34 UTC-5, Larry Wapnitsky wrote: OK. Im getting close, but Im stuck on the following SQLAlchemy code conversion: recipients = relationship( 'Recipient', secondary = mr_link, backref = 'message', lazy = 'dynamic' ) attachments = relationship( 'Attachment', secondary = ma_link, backref = 'message', lazy = 'dynamic' ) I don't see how to adapt this in the manual. TIA, Larry On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote: Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- --
[web2py] id field? when using SQLForm.grid
Do I need an ID field in my database when using the SQLForm.grid I am reading data from a legacy MySQL database which does not have an id field. Many thanks Simon --
Re: [web2py] Re: How to find duplicate rows with Web2py DAL
Don't worry this table is modest in size. Any solution is good enough for me, as long as it gets the job done :-)) Thanks and BR Loreia On Fri, Aug 17, 2012 at 9:06 PM, Niphlod niph...@gmail.com wrote: np. BTW: no simple ways to do that. Just mind that if there are millions rows (especially if the columns are not indexed) that is going to take some time. On Friday, August 17, 2012 5:09:40 PM UTC+2, Loreia wrote: Thanks a lot. BR Loreia On Thursday, August 16, 2012 1:23:39 PM UTC+2, Niphlod wrote: group by your unique columns, count the rows, find the ones with count 1. db.define_table( 'finddup', Field('f1_name'), Field('f2_name'), Field('f3_name') ) fd = db.finddup count = fd.id.count() rtn = db(fd.id0).select(fd.f1_name, fd.f2_name, fd.f3_name, count,groupby =fd.f1_name|fd.f2_name|**fd.f3_name, having=count1) On Thursday, August 16, 2012 11:20:54 AM UTC+2, Loreia wrote: Hi, I am looking for a way to automatically find any possible duplicate records (rows) in one table of my Postgres database. Quick google-ing reveals it is easy to do it with pure SQL, e.g. one way specific for Postgres: http://**stackoverflow.com/questions/** 1746213/how-to-delete-**duplicate-entries-in-**postgresqlhttp://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries-in-postgresql But I would like to be able to do it with web2p DAL (which would make it database independent). Is there a way to do it with web2py DAL? I just want to be able to find those duplicates, I don't need to delete them. Thank you and best regards, Loreia -- --
[web2py] Re: New Django REST library
looks familiar On Friday, 17 August 2012 11:57:50 UTC-5, pbreit wrote: Worth taking a look at: https://github.com/freshplum/django-simple-rest --
[web2py] Re: Congratulations to Bruno and Mariano
I think you have a point. Bruno is Vegan. Mariano eats excellent quality Argentinian meat. We in US on the other side eat processed food mixed with hydrogenated fats and corn syrup. No good. On Friday, 17 August 2012 13:38:07 UTC-5, apps in tables wrote: besides congratulations, what do you eat ? maybe this is the reason for being smart. Ashraf On Friday, August 17, 2012 5:13:45 PM UTC+3, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
mind if I post my SQLAlchemy code on Monday? I'm still a bit off with what I'm trying to accomplish in web2py. Thanks On 8/17/2012 3:41 PM, Massimo Di Pierro wrote: It depends on context. Web2py DAL is closer to SQL than on ORM. Assuming db.define_table('person',Field('name'),Field('email')) you have two options: 1) db.define_table('message',Field('body'),Field('recipients','list:reference person')) for row in db(db.message).select(): # one select for recipient in row.recipents: print recipient.name # one select per recipient to get name (lazy) 2) db.define_table('message',Field('body')) db.define_table('recipient',Field('message',db.message),Field('person',db.person)) for message in db(db.message).select(): for recipient in message.recipient.select() # one select/message print recipient.person.name # one select/recipient or with a single select using joins: for row in db(db.message.id==db.recipient.message)(db.recipient.person==person.id).select() print row.message.body, row.person.id On Friday, 17 August 2012 11:01:34 UTC-5, Larry Wapnitsky wrote: OK. Im getting close, but Im stuck on the following SQLAlchemy code conversion: | recipients =relationship('Recipient', secondary =mr_link, backref ='message', lazy ='dynamic') attachments =relationship('Attachment', secondary =ma_link, backref ='message', lazy ='dynamic') | I don't see how to adapt this in the manual. TIA, Larry On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote: Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- -- --
[web2py] Re: define existing tables
Take a look at web2py/scripts/extract_mysql_models.py --
Re: [web2py] id field? when using SQLForm.grid
Hi, I found the answer to this question, so if anyone else is looking for an answer to this question, here is the solution. in your model you need to just add 'id' to the to your primary field here is an example. db.define_table( 'product', Field('id_product','id'), your other fields as usual notice the 'id' which web2py then knows that this should be treated as the ID field that it is looking for. Thanks Simon On 17 August 2012 20:45, Simon Carr simonjc...@gmail.com wrote: Do I need an ID field in my database when using the SQLForm.grid I am reading data from a legacy MySQL database which does not have an id field. Many thanks Simon -- --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
also, do you think I might be better off doing this in MongoDB rather than MySQL/SQLAlchemy? On 8/17/2012 3:41 PM, Massimo Di Pierro wrote: It depends on context. Web2py DAL is closer to SQL than on ORM. Assuming db.define_table('person',Field('name'),Field('email')) you have two options: 1) db.define_table('message',Field('body'),Field('recipients','list:reference person')) for row in db(db.message).select(): # one select for recipient in row.recipents: print recipient.name # one select per recipient to get name (lazy) 2) db.define_table('message',Field('body')) db.define_table('recipient',Field('message',db.message),Field('person',db.person)) for message in db(db.message).select(): for recipient in message.recipient.select() # one select/message print recipient.person.name # one select/recipient or with a single select using joins: for row in db(db.message.id==db.recipient.message)(db.recipient.person==person.id).select() print row.message.body, row.person.id On Friday, 17 August 2012 11:01:34 UTC-5, Larry Wapnitsky wrote: OK. Im getting close, but Im stuck on the following SQLAlchemy code conversion: | recipients =relationship('Recipient', secondary =mr_link, backref ='message', lazy ='dynamic') attachments =relationship('Attachment', secondary =ma_link, backref ='message', lazy ='dynamic') | I don't see how to adapt this in the manual. TIA, Larry On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote: Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- -- --
[web2py] Re: web2py does not start as windows service
Below is an excerpt from the book -- please note that you should also look at the -L option: if you run web2py as Windows Service, -W, it is not convenient to pass the configuration using command line arguments. For this reason, in the web2py folder there is a sample options_std.py configuration file for the internal web server: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. import socket import os ip = '0.0.0.0' port = 80 interfaces=[('0.0.0.0',80)] #interfaces.append(('0.0.0.0',443,'ssl_private_key.pem','ssl_certificate.pem')) password = 'recycle' # ## recycle means use the previous password pid_filename = 'httpserver.pid' log_filename = 'httpserver.log' profiler_filename = None minthreads = None maxthreads = None server_name = socket.gethostname() request_queue_size = 5 timeout = 30 shutdown_timeout = 5 folder = os.getcwd() extcron = None nocron = None This file contains the web2py defaults. If you edit this file, you need to import it explicitly with the -L command-line option. It only works if you run web2py as a Windows Service. On Friday, August 17, 2012 1:33:55 PM UTC+1, mcamel wrote: I've just join the group today searching for the answer to the same problem as you. I've read dozens of post and will try some of this: - at the en of this post https://groups.google.com/forum/?fromgroups#!searchin/web2py/service$20windows/web2py/j-NT5gsMasE/SQV3g-kHHp8J[1-25]is described a posible solution - others talk about the need to install Mark Hammond's Win32 Extensions, though it seems if for another service problem (not the timeout one we both have): http://starship.python.net/~skippy/win32/ http://python.net/crew/mhammond/win32/Downloads.html - some wrote that password='recycle' should be written in Window like password=recycle BTW: I'm trying at W2000Professional and W2000Server. On Tuesday, May 15, 2012 11:15:38 PM UTC+2, Fernando Macedo wrote: Hello all, I need some help on this. I'm trying to distribute my app as an exe file, and it should run as a windows service. Tested on trunk an also with windows binary distro. The web2py was registered as windows service, but don't starts. D:\web2py_winweb2py.exe -W install web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.7 (2012-03-04 22:12:08) stable Database drivers available: SQLite3, pymysql, pg8000, IMAP Starting hardcron... Installing service web2py Changing service configuration Service updated D:\web2py_winweb2py.exe -W start web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.7 (2012-03-04 22:12:08) stable Database drivers available: SQLite3, pymysql, pg8000, IMAP Starting hardcron... Starting service web2py Error starting service: O serviþo nÒo respondeu Ó requisiþÒo de inÝcio ou contro le em tempo hßbil. D:\web2py_win I got the error Erro 1053: O serviço não respondeu à requisição de início ou controle em tempo hábil., It's from Windows Os (in portuguese), something like Error 1053: The service did not respond to the start or control request in a timely manner. options.py as default: 1. #!/usr/bin/python 2. # -*- coding: utf-8 -*- 3. 4. # when web2py is run as a windows service (web2py.exe -W) 5. # it does not load the command line options but it 6. # expects to find conifguration settings in a file called 7. # 8. # web2py/options.py 9. # 10. # this file is an example for options.py 11. 12. import socket 13. import os 14. 15. ip = '0.0.0.0' 16. port = 80 17. interfaces=[('0.0.0.0',80),('0.0.0.0',443,'ssl_private_key.pem', 'ssl_certificate.pem')] 18. password = 'recycle' # ## recycle means use the previous password 19. pid_filename = 'httpserver.pid' 20. log_filename = 'httpserver.log' 21. profiler_filename = None 22. #ssl_certificate = 'ssl_certificate.pem' # ## path to certificate file 23. #ssl_private_key = 'ssl_private_key.pem' # ## path to private key file 24. #numthreads = 50 # ## deprecated; remove 25. minthreads = None 26. maxthreads = None 27. server_name = socket.gethostname() 28. request_queue_size = 5 29. timeout = 30 30. shutdown_timeout = 5 31. folder = os.getcwd() 32. extcron = None 33. nocron = None Any adeas? Thanks in advance, Fernando Macedo --
[web2py] Re: Where should I put functions that are useful/common to muliple applications?
Thanks pbreit and weheh. I looked at the link give by pbreit. It says the following: applications requiring site-packages are not portable unless these modules are installed separately. What exactly does it mean they are not portable? For example, as of now my application which lives in a dropbox folder synced with pythonanywhere, works great on pythonanywhere. Would that stop working? Thanks. On Friday, August 17, 2012 8:22:43 AM UTC-4, weheh wrote: CSS belongs under static. Packages and common routines belong under modules and are imported. You could have a common static and modules and symbolically link. I have never done that, but it makes sense. I suppose you could also put the CSS just about anywhere on the file system. And modules could be put under the python package library and imported from there. I haven't tried that, but seems like it would work. On Friday, August 17, 2012 11:57:02 AM UTC+8, curiouslearn wrote: Hello, What is the recommended place in web2py folder where I should store custom functions that are useful to multiple applications? For example, suppose I have a function such as the following: *def connecttodb():* *if request.is_local:* *user=user* *passwd=passed* *host=localhost* *else:* *user=user_nonlocal* *passwd=passwd_nonlocal* *host=nonlocalhost* *con = mdb.connect(user=user,* * passwd=passwd,* * host=host)* *c = con.cursor()* *return con, c* I will need this in every application. Further, if I decide to change the host, I have to go and change the values in every application. There are other useful functions common to all applications. Can I just store them in one folder and import them, so that they work both on local and web hosts? If so, where do you recommend I save them? Thank you. --
Re: [web2py] id field? when using SQLForm.grid
Actually I have issue #547 for this. http://code.google.com/p/web2py/issues/detail?id=547 On Friday, August 17, 2012 3:22:53 PM UTC-5, Simon Carr wrote: Hi, I found the answer to this question, so if anyone else is looking for an answer to this question, here is the solution. in your model you need to just add 'id' to the to your primary field here is an example. db.define_table( 'product', Field('id_product','id'), your other fields as usual notice the 'id' which web2py then knows that this should be treated as the ID field that it is looking for. Thanks Simon On 17 August 2012 20:45, Simon Carr simon...@gmail.com javascript:wrote: Do I need an ID field in my database when using the SQLForm.grid I am reading data from a legacy MySQL database which does not have an id field. Many thanks Simon -- --
Re: [web2py] Re: Back-and-forth between DAL SQLAlchemy
Not sure what you asking. You are welcome to post sqlachemy code. On Friday, 17 August 2012 15:31:30 UTC-5, Larry Wapnitsky wrote: also, do you think I might be better off doing this in MongoDB rather than MySQL/SQLAlchemy? On 8/17/2012 3:41 PM, Massimo Di Pierro wrote: It depends on context. Web2py DAL is closer to SQL than on ORM. Assuming db.define_table('person',Field('name'),Field('email')) you have two options: 1) db.define_table('message',Field('body'),Field('recipients','list:reference person')) for row in db(db.message).select(): # one select for recipient in row.recipents: print recipient.name # one select per recipient to get name (lazy) 2) db.define_table('message',Field('body')) db.define_table('recipient',Field('message',db.message),Field('person',db.person)) for message in db(db.message).select(): for recipient in message.recipient.select() # one select/message print recipient.person.name # one select/recipient or with a single select using joins: for row in db(db.message.id==db.recipient.message)(db.recipient.person== person.id).select() print row.message.body, row.person.id On Friday, 17 August 2012 11:01:34 UTC-5, Larry Wapnitsky wrote: OK. Im getting close, but Im stuck on the following SQLAlchemy code conversion: recipients = relationship( 'Recipient', secondary = mr_link, backref = 'message', lazy = 'dynamic' ) attachments = relationship( 'Attachment', secondary = ma_link, backref = 'message', lazy = 'dynamic' ) I don't see how to adapt this in the manual. TIA, Larry On Friday, August 17, 2012 8:24:41 AM UTC-4, Larry Wapnitsky wrote: Thanks, Massimo. I'll give this a read and see if I can adapt it properly. As usual, your hard work is greatly appreciated. On 8/15/2012 6:34 PM, Massimo Di Pierro wrote: I meant this: http://web2py.com/AlterEgo/default/show/189 On Wednesday, 15 August 2012 14:22:36 UTC-5, Larry Wapnitsky wrote: I have a project in which I've just written the database functions using SQLAlchemy. It was much simpler than my original, hand-written SQL queries, especially once I got the hang of creating relationships with SA's ORM. Now, I would like to create a front-end for this using web2py, but, from experience, I know the DAL and SA's ORM are very different. What's the group's view on the best way to integrate my two projects? -- -- --
[web2py] Re: Congratulations to Bruno and Mariano
Great. Many thanks to both. On Friday, August 17, 2012 10:13:45 AM UTC-4, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
[web2py] Re: Congratulations to Bruno and Mariano
Massimo, you forget the salt. NaCl, without which there would be no USA cuisine. On Friday, August 17, 2012 3:54:38 PM UTC-4, Massimo Di Pierro wrote: I think you have a point. Bruno is Vegan. Mariano eats excellent quality Argentinian meat. We in US on the other side eat processed food mixed with hydrogenated fats and corn syrup. No good. On Friday, 17 August 2012 13:38:07 UTC-5, apps in tables wrote: besides congratulations, what do you eat ? maybe this is the reason for being smart. Ashraf On Friday, August 17, 2012 5:13:45 PM UTC+3, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
[web2py] Re: Where should I put functions that are useful/common to muliple applications?
I guess it is referring to the packing/installation of *.w2p files via the admin interface. Only files under the app's dir would be packed, therefore site-packages would have to be installed outside that mechanism. By using Dropbox you are not relying on the admin interface for the mentioned portability feature. On Friday, August 17, 2012 9:38:26 PM UTC+1, curiouslearn wrote: Thanks pbreit and weheh. I looked at the link give by pbreit. It says the following: applications requiring site-packages are not portable unless these modules are installed separately. What exactly does it mean they are not portable? For example, as of now my application which lives in a dropbox folder synced with pythonanywhere, works great on pythonanywhere. Would that stop working? Thanks. On Friday, August 17, 2012 8:22:43 AM UTC-4, weheh wrote: CSS belongs under static. Packages and common routines belong under modules and are imported. You could have a common static and modules and symbolically link. I have never done that, but it makes sense. I suppose you could also put the CSS just about anywhere on the file system. And modules could be put under the python package library and imported from there. I haven't tried that, but seems like it would work. On Friday, August 17, 2012 11:57:02 AM UTC+8, curiouslearn wrote: Hello, What is the recommended place in web2py folder where I should store custom functions that are useful to multiple applications? For example, suppose I have a function such as the following: *def connecttodb():* *if request.is_local:* *user=user* *passwd=passed* *host=localhost* *else:* *user=user_nonlocal* *passwd=passwd_nonlocal* *host=nonlocalhost* *con = mdb.connect(user=user,* * passwd=passwd,* * host=host)* *c = con.cursor()* *return con, c* I will need this in every application. Further, if I decide to change the host, I have to go and change the values in every application. There are other useful functions common to all applications. Can I just store them in one folder and import them, so that they work both on local and web hosts? If so, where do you recommend I save them? Thank you. --
[web2py] Re: Best way to insert 200k records?
if it is a one time data load and i have the proper constraints set in SQLLite, i would use raw SQL. if this was repetitive use and i wanted to use web2py validation i would use the DAL with bulk insert (making sure that i validate the data before adding to the insert queue) On Friday, August 17, 2012 12:38:56 PM UTC-7, Mike Girard wrote: 10 minutes is all right. Still, if there are two methods and they are qualitatively equal apart from speed, I'd prefer to use the faster one. So posing the question, once again, is there a compelling reason to use the DAL for bulk uploads. More specficially, what extras, if any, are being added by the DAL for inserts that a bulk insert using SQLLite directly won't add? On Friday, August 17, 2012 12:58:01 PM UTC-4, nick name wrote: On Friday, August 17, 2012 8:29:12 AM UTC-4, Mike Girard wrote: The data will be coming from a large XML file, so my script will parse that and make inserts into several different tables. It's fairly straightforward. So is it correct to say that - 1. There is no compelling reason to do this without the DAL 2. My options in the DAL are bulk_insert, looping db.query and csv import and that performance wise they're similar? 2 is correct (as long as you are going through the DAL; db.executesql would be the non-DAL way from within web2py - and of course, you could use your DB's native facilities) 1. Is correct if you are not doing this often - e.g., it might take 10 minutes as opposed to 1 minute without DAL (just assuming, not based on any actual measurement). So what? If you do this once an hour, then DAL processing and the individual record insertion (even if you use bulk_insert or csv) might make it too slow for you, and you would be better off looking at your database's native bulk loading facilities. --
[web2py] Re: Where should I put functions that are useful/common to muliple applications?
curiouslearn I agree it's a good idea to learn as much as you can about the underlying database. That said, you need to learn about sql injection and perhaps other MySQL attack vectors before making your application public. See, for example xkcd.com/327/ On Friday, August 17, 2012 12:17:48 AM UTC-4, curiouslearn wrote: Hello pbreit, Thanks, I will look into that. After posting I realized, I have the same question for css style files and js files. Where can I store those? Can I just store them in one application, and call them using URL() function? Is that the best way, or is there something better? I am new to tools and technologies related to web-development (MySQL) being one of them. For some reason I have this feeling that it is important to have some basic knowledge of SQL and to learn how to handle some database (in this case MySQL) using the standard commands it provides. Hence, for practice I decided to make my apps using raw SQL. Thanks again for your response. Hope you or someone can suggest something for css/js files. Thank you. On Friday, August 17, 2012 12:05:59 AM UTC-4, pbreit wrote: I guess site-packages: http://web2py.com/books/default/chapter/29/4?search=site-packages But why oh why aren't you using DAL? --
[web2py] Re: IS_IN_DB cannot pull the data from the table
Specify the field that you wish to appear in the dropdown box Try what the book says, 'name' is simply the name of the field you wish to appear: db.dog.owner.requires = IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one')) --
[web2py] Re: IS_IN_DB cannot pull the data from the table
But he's not getting any records at all in the list. On Friday, August 17, 2012 5:20:42 PM UTC-4, villas wrote: Specify the field that you wish to appear in the dropdown box Try what the book says, 'name' is simply the name of the field you wish to appear: db.dog.owner.requires = IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one')) --
[web2py] Re: Web2py GAE strange error type 'exceptions.IOError' [Errno 13] file not accessible: (jQuery.js)
response.include_file() outputs the files that were added to response.files (js, css). when you remove that you loose the auto output of files that were added to response.files along the way. response.include_mete() works much the same for HTML meta properties. can we see the resulting HTML in both cases? in the first case (when it fails completely) you get HTML right? but jquery.js fails to load so other things on your site might break. in the second case it sounds like jquery does load, but you are missing other files so your site breaks? or do you get no HTML to the browesr in either case? as an aside - how is threadsafe working for you on GAE? i had some problems with it myselfperhaps i have bad code. :) thanks, cfh On Thursday, August 16, 2012 1:29:00 PM UTC-7, Akash Kakkar wrote: Hi, I have tried deploying an earlier version of my app on gae and was successful, unfortunately the product release version of my app is faltering when I try to run locally on gae before deploying and was getting undefined error. In the process of debugging I made changes in my app.yaml file which is as below (deleted the skip files portion). I noticed that with this when I try to run the application I get the following error: type 'exceptions.IOError' [Errno 13] file not accessible: '/home/akash/webdev/web2py/applications/docmatorx/static/js/jquery.js' According to me the problem is with web2py_ajax.html file. which if I leave blank the application runs (though the layout.html functionality and the topbar vanishes) //original web2py_ajax.html script type=text/javascript var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; /script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} #*app.yaml* # For Google App Engine deployment, copy this file to app.yaml # and edit as required # See http://code.google.com/appengine/docs/python/config/appconfig.html # and http://web2py.com/book/default/chapter/11?search=app.yaml application: my app as registered on GAE version: 1 api_version: 1 # use this line for Python 2.5 # # runtime: python # use these lines for Python 2.7 # upload app with: appcfg.py update web2py (where 'web2py' is web2py's root directory) # runtime: python27 threadsafe: yes# true for WSGI concurrent requests (Python 2.7 only) default_expiration: 24h # for static files handlers: - url: /(?Pa.+?)/static/(?Pb.+) static_files: applications/\1/static/\2 upload: applications/(.+?)/static/(.+) secure: optional - url: /favicon.ico static_files: applications/welcome/static/favicon.ico upload: applications/welcome/static/favicon.ico - url: /robots.txt static_files: applications/welcome/static/robots.txt upload: applications/welcome/static/robots.txt - url: .* # script: gaehandler.py # CGI script: gaehandler.wsgiapp# WSGI (Python 2.7 only) secure: optional admin_console: pages: - name: Appstats url: /_ah/stats builtins: - default: on - remote_api: on - appstats: on - admin_redirect: on - deferred: on - django_wsgi: on It would be nice If someone can tell me what is going wrong or if I can get information on what files are included in the following statements response.include_meta() response.include_files() My application runs (with limited layout features probably because of not including the meta and add on files) if I edit the web2py_ajax.html file to : script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; //--/script script src={{=URL('static','js/jQuery.js')}} type=text/javascript/script script src={{=URL('static','css/calendar.css')}} type=text/javascript/script script src={{=URL('static','js/calendar.js')}} type=text/javascript/script script src={{=URL('static','css/web2py.css')}} type=text/javascript/script script src={{=URL('static','js/web2py.js')}} type=text/javascript/script Thank You for your Help. --
[web2py] mail.send transposing to and subject ; can anybody explain this?
The simple controller says this: record = get_email_record() approved_suppliers = get_approved_suppliers(record.products.id) mail.settings.server = 'logging' mail.settings.sender = 'foobar@gmail.com' mail.settings.login = False mail.send( to =['jrandomu...@example.com'], subject='Requisition Number %s for %s' %( record.requisitions.id, record.products.name, ), message = build_message(record, approved_suppliers) ) The email in the console as the to and subject fields transposed, like this. WARNING:web2py:email not sent From: foobar@gmail.com To: Requisition Number 5 for Product_0 Subject: jrandomu...@example.com This is happening on 1.99.2. I'm downloading a fresh zipball of 1.99.7 even as I type this, so I'm going to try the code on the latest stable. Still, this is strange. Does anybody know what's going on? Thanks, Cliff Kachinske --
[web2py] Re: IS_IN_DB cannot pull the data from the table
Just in case, I changed just like you suggested but I got a same result. I can pull the data from other tables on the same database but I cannot pull the data from this one I should be dreaming or getting crazy... : ( I first doubt a simple typo but I can't figure out. db.EDXTKF00.TKDIID.requires=IS_IN_DB(db,db.EDMACF00.ACDIID) = db.EDXTKF00.TKDIID.requires=IS_IN_DB(db,'EDMACF00.ACDIID') On Friday, August 17, 2012 4:20:42 PM UTC-5, villas wrote: Specify the field that you wish to appear in the dropdown box Try what the book says, 'name' is simply the name of the field you wish to appear: db.dog.owner.requires = IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one')) --
Re: [web2py] Select a table given its table name?
Thank you, Anthony. On Friday, August 17, 2012 10:37:02 PM UTC+3, Anthony wrote: db.mytable.fields is a list of the field names, and db.mytable.fields() returns a copy of that list (so if you mutate the copy, the original list doesn't change). Anthony On Friday, August 17, 2012 2:27:22 PM UTC-4, apps in tables wrote: How to get the list of the fields names? On Friday, August 17, 2012 6:37:58 PM UTC+3, rochacbruno wrote: def feed(table): return db(db[table].id0).select() --
[web2py] Re: Congratulations to Bruno and Mariano
Congratulations, guys. I appreciate all the work you do. On Friday, August 17, 2012 10:13:45 AM UTC-4, Massimo Di Pierro wrote: Congratulations to Bruno Rocha and Mariano Reingart, New members of the Python Software Foundations. http://pyfound.blogspot.com.br/2012/08/welcome-new-psf-members.html --
[web2py] Get row count for query without loading data into memory
Does this load the rows into memory? db(db.person.id 0).count() If so, is there a DAL way to get a row count for a query without loading the rows? Thanks. Mike --
Re: [web2py] Get row count for query without loading data into memory
It returns no Row. It return an int object db(db.person.id 0).count() *Translates to SELECT count(*) FROM PERSON WHERE ID )* *So the result is an integer object.* *Bruno Cezar Rocha** - @rochacbruno* rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821 www.CursoDePython.com.br | www.rochacbruno.com.br Blog: I am now a member of Python Software Foundationhttp://rochacbruno.com.br/i-am-now-a-member-of-python-software-foundation/ Get a signature like this. http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 Click here.http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 On Fri, Aug 17, 2012 at 6:54 PM, Mike Girard mikegirar...@gmail.com wrote: db(db.person.id 0).count() --
Re: [web2py] id field? when using SQLForm.grid
I have tested with the solution I posted and it works fine. Does it work for you? Simon On 17 August 2012 21:41, Omi Chiba ochib...@gmail.com wrote: Actually I have issue #547 for this. http://code.google.com/p/web2py/issues/detail?id=547 On Friday, August 17, 2012 3:22:53 PM UTC-5, Simon Carr wrote: Hi, I found the answer to this question, so if anyone else is looking for an answer to this question, here is the solution. in your model you need to just add 'id' to the to your primary field here is an example. db.define_table( 'product', Field('id_product','id'), your other fields as usual notice the 'id' which web2py then knows that this should be treated as the ID field that it is looking for. Thanks Simon On 17 August 2012 20:45, Simon Carr simon...@gmail.com wrote: Do I need an ID field in my database when using the SQLForm.grid I am reading data from a legacy MySQL database which does not have an id field. Many thanks Simon -- -- --
[web2py] Re: Get row count for query without loading data into memory
I'm not really a DAL guru, but I can't imagine DAL doing that. Every dbms I know about has something like SELECT COUNT(id) WHERE ...query On Friday, August 17, 2012 5:54:32 PM UTC-4, Mike Girard wrote: Does this load the rows into memory? db(db.person.id 0).count() If so, is there a DAL way to get a row count for a query without loading the rows? Thanks. Mike --
Re: [web2py] Select a table given its table name?
Also, you would get exceptions if table does not exists, so: def feed(table): *try*: return db(db[table].id0).select() *except* KeyError: return Sorry, table not found *Bruno Cezar Rocha** - @rochacbruno* rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821 www.CursoDePython.com.br | www.rochacbruno.com.br Blog: I am now a member of Python Software Foundationhttp://rochacbruno.com.br/i-am-now-a-member-of-python-software-foundation/ Get a signature like this. http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 Click here.http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 On Fri, Aug 17, 2012 at 6:41 PM, apps in tables ad...@aqar-riyadh.comwrote: Thank you, Anthony. On Friday, August 17, 2012 10:37:02 PM UTC+3, Anthony wrote: db.mytable.fields is a list of the field names, and db.mytable.fields() returns a copy of that list (so if you mutate the copy, the original list doesn't change). Anthony On Friday, August 17, 2012 2:27:22 PM UTC-4, apps in tables wrote: How to get the list of the fields names? On Friday, August 17, 2012 6:37:58 PM UTC+3, rochacbruno wrote: def feed(table): return db(db[table].id0).select() -- --
Re: [web2py] Select a table given its table name?
Thank you, Bruno. your code is different after getting the membership :) Congratulations Ashraf On Saturday, August 18, 2012 1:01:29 AM UTC+3, rochacbruno wrote: Also, you would get exceptions if table does not exists, so: def feed(table): *try*: return db(db[table].id0).select() *except* KeyError: return Sorry, table not found *Bruno Cezar Rocha** - @rochacbruno* rocha...@gmail.com javascript: | Mobile: +55 (11) 99210-8821 www.CursoDePython.com.br | www.rochacbruno.com.br Blog: I am now a member of Python Software Foundationhttp://rochacbruno.com.br/i-am-now-a-member-of-python-software-foundation/ Get a signature like this. http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 Click here.http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18 On Fri, Aug 17, 2012 at 6:41 PM, apps in tables ad...@aqar-riyadh.comjavascript: wrote: Thank you, Anthony. On Friday, August 17, 2012 10:37:02 PM UTC+3, Anthony wrote: db.mytable.fields is a list of the field names, and db.mytable.fields() returns a copy of that list (so if you mutate the copy, the original list doesn't change). Anthony On Friday, August 17, 2012 2:27:22 PM UTC-4, apps in tables wrote: How to get the list of the fields names? On Friday, August 17, 2012 6:37:58 PM UTC+3, rochacbruno wrote: def feed(table): return db(db[table].id0).select() -- --
[web2py] Re: Get row count for query without loading data into memory
Wow. You guys are so fast. After posting, I found out about the Toolbar and looked at the SQL myself. I feel stupid for asking. What threw me off was some code I saw of Massimo's where he used raw SQL to get a record count. I found myself wondering why. On Friday, August 17, 2012 6:00:20 PM UTC-4, Cliff Kachinske wrote: I'm not really a DAL guru, but I can't imagine DAL doing that. Every dbms I know about has something like SELECT COUNT(id) WHERE ...query On Friday, August 17, 2012 5:54:32 PM UTC-4, Mike Girard wrote: Does this load the rows into memory? db(db.person.id 0).count() If so, is there a DAL way to get a row count for a query without loading the rows? Thanks. Mike --
[web2py] Re: mail.send transposing to and subject ; can anybody explain this?
It was a bug (just a display type, mails are sent correctly, it is only the print to the logging that is misplaced), that is fixed in recent versions. On Friday, August 17, 2012 11:25:44 PM UTC+2, Cliff Kachinske wrote: The simple controller says this: record = get_email_record() approved_suppliers = get_approved_suppliers(record.products.id) mail.settings.server = 'logging' mail.settings.sender = 'fooba...@gmail.com javascript:' mail.settings.login = False mail.send( to =['jrand...@example.com javascript:'], subject='Requisition Number %s for %s' %( record.requisitions.id, record.products.name, ), message = build_message(record, approved_suppliers) ) The email in the console as the to and subject fields transposed, like this. WARNING:web2py:email not sent From: foobar@gmail.com To: Requisition Number 5 for Product_0 Subject: jrandomu...@example.com This is happening on 1.99.2. I'm downloading a fresh zipball of 1.99.7 even as I type this, so I'm going to try the code on the latest stable. Still, this is strange. Does anybody know what's going on? Thanks, Cliff Kachinske --
[web2py] How to use mysql on GAE?
I know that GAE supports mysql, ??? How do I use that instead of bigtable? --
[web2py] Re: mail.send transposing to and subject ; can anybody explain this?
Many thanks. It was mighty strange, since I've used mail.send() before without problem. On Friday, August 17, 2012 7:01:55 PM UTC-4, Niphlod wrote: It was a bug (just a display type, mails are sent correctly, it is only the print to the logging that is misplaced), that is fixed in recent versions. On Friday, August 17, 2012 11:25:44 PM UTC+2, Cliff Kachinske wrote: The simple controller says this: record = get_email_record() approved_suppliers = get_approved_suppliers(record.products.id) mail.settings.server = 'logging' mail.settings.sender = 'fooba...@gmail.com' mail.settings.login = False mail.send( to =['jrand...@example.com'], subject='Requisition Number %s for %s' %( record.requisitions.id, record.products.name, ), message = build_message(record, approved_suppliers) ) The email in the console as the to and subject fields transposed, like this. WARNING:web2py:email not sent From: foobar@gmail.com To: Requisition Number 5 for Product_0 Subject: jrandomu...@example.com This is happening on 1.99.2. I'm downloading a fresh zipball of 1.99.7 even as I type this, so I'm going to try the code on the latest stable. Still, this is strange. Does anybody know what's going on? Thanks, Cliff Kachinske --
[web2py] Re: Web2py GAE strange error type 'exceptions.IOError' [Errno 13] file not accessible: (jQuery.js)
What kind of thread problems did you have on GAE? On Friday, 17 August 2012 16:23:17 UTC-5, howesc wrote: response.include_file() outputs the files that were added to response.files (js, css). when you remove that you loose the auto output of files that were added to response.files along the way. response.include_mete() works much the same for HTML meta properties. can we see the resulting HTML in both cases? in the first case (when it fails completely) you get HTML right? but jquery.js fails to load so other things on your site might break. in the second case it sounds like jquery does load, but you are missing other files so your site breaks? or do you get no HTML to the browesr in either case? as an aside - how is threadsafe working for you on GAE? i had some problems with it myselfperhaps i have bad code. :) thanks, cfh On Thursday, August 16, 2012 1:29:00 PM UTC-7, Akash Kakkar wrote: Hi, I have tried deploying an earlier version of my app on gae and was successful, unfortunately the product release version of my app is faltering when I try to run locally on gae before deploying and was getting undefined error. In the process of debugging I made changes in my app.yaml file which is as below (deleted the skip files portion). I noticed that with this when I try to run the application I get the following error: type 'exceptions.IOError' [Errno 13] file not accessible: '/home/akash/webdev/web2py/applications/docmatorx/static/js/jquery.js' According to me the problem is with web2py_ajax.html file. which if I leave blank the application runs (though the layout.html functionality and the topbar vanishes) //original web2py_ajax.html script type=text/javascript var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; /script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} #*app.yaml* # For Google App Engine deployment, copy this file to app.yaml # and edit as required # See http://code.google.com/appengine/docs/python/config/appconfig.html # and http://web2py.com/book/default/chapter/11?search=app.yaml application: my app as registered on GAE version: 1 api_version: 1 # use this line for Python 2.5 # # runtime: python # use these lines for Python 2.7 # upload app with: appcfg.py update web2py (where 'web2py' is web2py's root directory) # runtime: python27 threadsafe: yes# true for WSGI concurrent requests (Python 2.7 only) default_expiration: 24h # for static files handlers: - url: /(?Pa.+?)/static/(?Pb.+) static_files: applications/\1/static/\2 upload: applications/(.+?)/static/(.+) secure: optional - url: /favicon.ico static_files: applications/welcome/static/favicon.ico upload: applications/welcome/static/favicon.ico - url: /robots.txt static_files: applications/welcome/static/robots.txt upload: applications/welcome/static/robots.txt - url: .* # script: gaehandler.py # CGI script: gaehandler.wsgiapp# WSGI (Python 2.7 only) secure: optional admin_console: pages: - name: Appstats url: /_ah/stats builtins: - default: on - remote_api: on - appstats: on - admin_redirect: on - deferred: on - django_wsgi: on It would be nice If someone can tell me what is going wrong or if I can get information on what files are included in the following statements response.include_meta() response.include_files() My application runs (with limited layout features probably because of not including the meta and add on files) if I edit the web2py_ajax.html file to : script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; //--/script script src={{=URL('static','js/jQuery.js')}} type=text/javascript/script script src={{=URL('static','css/calendar.css')}} type=text/javascript/script script src={{=URL('static','js/calendar.js')}} type=text/javascript/script script src={{=URL('static','css/web2py.css')}} type=text/javascript/script script src={{=URL('static','js/web2py.js')}} type=text/javascript/script Thank You for your Help. --
[web2py] Re: IS_IN_DB cannot pull the data from the table
Please open a ticket pointing to this thread. Will look at it asap. On Friday, 17 August 2012 17:33:51 UTC-5, Omi Chiba wrote: I finally figured this should be a bug on the current in trunk version (Version 2.0.0 (2012-08-15 17:30:38) dev) I can pull the data when the data in primarykey field begin with numeric numbers for example 12345 or 1ABCDE (See NG-1,2.jpg) but cannot pull the data begin with alphabet like A1234. (See OK-1,2.jpg) # MF - EDI CUSTOMER db.define_table('EDMACF00', Field('ACDIID', length=5, label=Dist Code), Field('ACNAME', length=20, label=Dist Name), Field('AC855F', length=1, label=PO ACK FLAG), Field('AC856F', length=1, label=ASN FLAG), Field('AC810F', length=1, label=INVOICE FLAG), Field('ACUPFL', length=1, label=OZ UPLOAD FLAG), Field('ACCRBY', length=20, default = auth.user.username.upper() if auth.user else None, label=Created by), Field('ACCRDT', 'datetime', default =request.now, label=Created on), Field('ACUPBY', length=20, update = auth.user.username.upper() if auth.user else None, label=Updated by), Field('ACUPDT', 'datetime', update =request.now, label=Updated on), primarykey=['ACDIID']) db.EDMACF00.ACDIID.requires=[IS_NOT_EMPTY(),IS_LENGTH(5,1),IS_UPPER()] db.EDMACF00.ACNAME.requires=[IS_NOT_EMPTY(),IS_LENGTH(20,1),IS_UPPER()] db.EDMACF00.AC855F.requires=IS_IN_SET(['','1'], zero=None) db.EDMACF00.AC856F.requires=IS_IN_SET(['','1'], zero=None) db.EDMACF00.AC810F.requires=IS_IN_SET(['','1'], zero=None) db.EDMACF00.ACUPFL.writable = db.EDMACF00.ACUPFL.readable = False db.EDMACF00.ACCRBY.writable = False db.EDMACF00.ACCRDT.writable = False db.EDMACF00.ACUPBY.writable = False db.EDMACF00.ACUPDT.writable = False # XR - CUSTOMER db.define_table('EDXTKF00', Field('TKDIID', length=5, label=Dist Code), Field('TKDICD', length=20, label=Dist Office Code), Field('TKTKSC', length=3, label=Dept), Field('TKTKCD', length=8, label=Customer Code), Field('TKDMCD', 'integer', label=Employee Code), Field('TKUPFL', length=1, label=OZ UPLOAD FLAG), Field('TKCRBY', length=20, default = auth.user.username.upper() if auth.user else None, label=Created by), Field('TKCRDT', 'datetime', default =request.now, label=Created on), Field('TKUPBY', length=20, update = auth.user.username.upper() if auth.user else None, label=Updated by), Field('TKUPDT', 'datetime', update =request.now, label=Updated on), primarykey=['TKDIID', 'TKDICD']) db.EDXTKF00.TKDIID.requires=IS_IN_DB(db,db.EDMACF00.ACDIID,'%(ACNAME)s') db.EDXTKF00.TKDICD.requires=[IS_NOT_EMPTY(),IS_LENGTH(20,1),IS_UPPER()] db.EDXTKF00.TKTKSC.requires=IS_IN_SET(['J11','J13','J14','J15','J16','J17']) db.EDXTKF00.TKTKCD.requires=[IS_NOT_EMPTY(),IS_LENGTH(8,8),IS_UPPER(),IS_IN_DB(db,db.CDMTKL00.TKTSCD)] db.EDXTKF00.TKDMCD.requires=[IS_NOT_EMPTY(),IS_INT_IN_RANGE(6,6,error_message='Invalid length'),IS_IN_DB(db,db.CDMSYL00.SYSYCD)] db.EDXTKF00.TKUPFL.writable = db.EDXTKF00.TKUPFL.readable = False db.EDXTKF00.TKCRBY.writable = False db.EDXTKF00.TKCRDT.writable = False db.EDXTKF00.TKUPBY.writable = False db.EDXTKF00.TKUPDT.writable = False On Friday, August 17, 2012 4:38:00 PM UTC-5, Omi Chiba wrote: Just in case, I changed just like you suggested but I got a same result. I can pull the data from other tables on the same database but I cannot pull the data from this one I should be dreaming or getting crazy... : ( I first doubt a simple typo but I can't figure out. db.EDXTKF00.TKDIID.requires=IS_IN_DB(db,db.EDMACF00.ACDIID) = db.EDXTKF00.TKDIID.requires=IS_IN_DB(db,'EDMACF00.ACDIID') On Friday, August 17, 2012 4:20:42 PM UTC-5, villas wrote: Specify the field that you wish to appear in the dropdown box Try what the book says, 'name' is simply the name of the field you wish to appear: db.dog.owner.requires = IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one')) --
[web2py] Major speed improvement need testers
There are two major speed improvements in trunk and I am not sure whether they should go in web2py 2.0 next week. 1) Lazy table (based on ideas from Bruno). db = DAL(, lazy_tables=True) db.define_table('person',Field('name')) the table is instantiated only when db.person is accessed. So with some care: Field(, requires=) # LAZY (good) db.table.field.requires = ... # NOT LAZY (bad) Field('other','reference table') # LAZY (good) Field('other',db.table) # NOT LAZY (bad) this may be a big speedup. 2) There is a new implementation of class Storage. This is a most accessed object within web2py and now it is 10x faster. Yet I am not sure if this breaks something. It would be great if you could try the nightly build (or trunk) and report if you experienced any problem. It would be even better if you could run some benchmarks of your code before and after the changes suggested at 1). Massimo --