[web2py] Unable to edit record in admin because of postgres fkey violation
I'm trying to edit a record in admin but am getting an fkey violation. This kind of makes sense since I guess the admin is user=0. But if I'm logged in as user.id=1 should I be able to avoid the restriction? IntegrityError: insert or update on table item violates foreign key constraint item_modified_by_fkey DETAIL: Key (modified_by)=(0) is not present in table auth_user.
[web2py] how to ignore keyword in web2py
i have to use group as column name in web2py. i am using mysql as a db. in mysql we can do it using `group` in python we can do it using group_ d=db.test.insert(name=exacturl,group=) How to ignore keyword in web2py.
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
That is not the problem. There is no user with id==0. The problem is that modified_by seems to default to 0 instead of auth.user_id. Are you sure you are logged in? Massimo On Jun 21, 1:51 am, pbreit pbreitenb...@gmail.com wrote: I'm trying to edit a record in admin but am getting an fkey violation. This kind of makes sense since I guess the admin is user=0. But if I'm logged in as user.id=1 should I be able to avoid the restriction? IntegrityError: insert or update on table item violates foreign key constraint item_modified_by_fkey DETAIL: Key (modified_by)=(0) is not present in table auth_user.
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
Yeah, I'm pretty sure I'm logged in. It shows welcome at the top and if I click on state I can see auth_user.id=5.
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
I switch between SSL and non-SSL for /user and not-/user. I wonder if that could be a problem?
[web2py] common fields shared by different tables
what's the best way to define a minimal list of fields that I want to repluicate in some tables? I thought to define a table but as I need it only to be used inside other tables I don't need it's really created in my db... and I don't want it... is it possible? thanks a lot Manuele
[web2py] Re: common fields shared by different tables
Like this? http://web2py.com/book/default/chapter/06?search=signature On Jun 21, 8:42 am, Manuele Pesenti manuele.pese...@gmail.com wrote: what's the best way to define a minimal list of fields that I want to repluicate in some tables? I thought to define a table but as I need it only to be used inside other tables I don't need it's really created in my db... and I don't want it... is it possible? thanks a lot Manuele
[web2py] Re: how to ignore keyword in web2py
Please let me know is it possible or not? On Tue, Jun 21, 2011 at 11:32 AM, sagar browse2sa...@gmail.com wrote: i have to use group as column name in web2py. i am using mysql as a db. in mysql we can do it using `group` in python we can do it using group_ d=db.test.insert(name=exacturl,group=) How to ignore keyword in web2py.
[web2py] how to implement two different login processes?
My app to date has had one controller, default.py I had multiple login methods (LinkedIn and email address) for different sets of users. This caused a problem: when a user wasn't logged in, my app defaulted to prompt for a LinkedIn OAuth-style login. So I decided to pull the code for the two sets of user a part into init/default.py and a new file, init/id.py both now implement their own function user() Trouble is, when I call init/id/id which are decorated:@auth.requires_login() the user() function in init/ default.py is called rather than the one in init/id.py Where am I going wrong?
Re: [web2py] Re: common fields shared by different tables
On 21/06/2011 10:14, apple wrote: Like this? http://web2py.com/book/default/chapter/06?search=signature yes... I was looking exacly this inside the gluon code :) M. On Jun 21, 8:42 am, Manuele Pesentimanuele.pese...@gmail.com wrote: what's the best way to define a minimal list of fields that I want to repluicate in some tables? I thought to define a table but as I need it only to be used inside other tables I don't need it's really created in my db... and I don't want it... is it possible? thanks a lot Manuele
[web2py] Re: Speed of rendering html data (10,000+ rows)
Ref. to issue 307 in google code. http://code.google.com/p/web2py/issues/detail?id=307sort=-id As suggested by Caleb, I prepared the HTML myself (in the controller). Then returned the generated html to the View and rendered it there. == My finding:--- == Still it takes long time to load the page (using either of the following 2 ways). 1) Without XML helper, it displays html code as it is (i.e. tablethMyName/thetc.) Takes long time to display the page. 2) With XML, it displays properely formatted table. Takes long time to display the page. Whether anybody else had a similar situation like the same? Any suggestions/comments highly appreciated. ---Vineet On Jun 15, 9:00 pm, VP vtp2...@gmail.com wrote: for i in custdata: mystr2 = ''.join([mystr2, 'trtd' , str(i[0]) , '/td']) ... lst = [ jn(['trtd' , str(i[0]) , '/td', 'td' , str(i[1]) , '/td', 'td' , str(i[2]) , '/td', .. more omitted..]) for i in res] mystr=jn(lst) -- The performance boost is amazing.. It took ONLY 0.078 seconds -- This makes sense because a crude analysis shows that the first approach is O(n^3) while the second one is O(n). (I think)
[web2py] Re: how to implement two different login processes?
after some digging I've found that creating Auth(db) is where the controller can be set (and is, of course, default by default :) I'm calling auth=Auth(db) in my db.py file Am I heading in the right direction to change the call to Auth() depending upon if the user is logging in via /init/default/user or init/id/user ? Or should I keep each different authentication type in default.py and configure in some way ? Guidance sort. On Jun 21, 10:01 am, Carl m...@carlroach.com wrote: My app to date has had one controller, default.py I had multiple login methods (LinkedIn and email address) for different sets of users. This caused a problem: when a user wasn't logged in, my app defaulted to prompt for a LinkedIn OAuth-style login. So I decided to pull the code for the two sets of user a part into init/default.py and a new file, init/id.py both now implement their own function user() Trouble is, when I call init/id/id which are decorated:@auth.requires_login() the user() function in init/ default.py is called rather than the one in init/id.py Where am I going wrong?
Re: [web2py] Re: how to implement two different login processes?
if you are using RPX(janrain) you can have both methods at the same login page: http://web2pyslices.com/main/slices/take_slice/124 -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Tue, Jun 21, 2011 at 6:36 AM, Carl m...@carlroach.com wrote: after some digging I've found that creating Auth(db) is where the controller can be set (and is, of course, default by default :) I'm calling auth=Auth(db) in my db.py file Am I heading in the right direction to change the call to Auth() depending upon if the user is logging in via /init/default/user or init/id/user ? Or should I keep each different authentication type in default.py and configure in some way ? Guidance sort. On Jun 21, 10:01 am, Carl m...@carlroach.com wrote: My app to date has had one controller, default.py I had multiple login methods (LinkedIn and email address) for different sets of users. This caused a problem: when a user wasn't logged in, my app defaulted to prompt for a LinkedIn OAuth-style login. So I decided to pull the code for the two sets of user a part into init/default.py and a new file, init/id.py both now implement their own function user() Trouble is, when I call init/id/id which are decorated:@auth.requires_login() the user() function in init/ default.py is called rather than the one in init/id.py Where am I going wrong?
Re: [web2py] Re: how to implement two different login processes?
thanks Bruno. My UI requirements are not to give a choice to visiting users so I specifically require the options on different pages. One page won't be indexed by search engines and will be by-invitation only. I'm using the LinkedIn API to access user data from LinkedIn's servers so JanRain isn't a solution for me for this product either. On 21 June 2011 10:51, Bruno Rocha rochacbr...@gmail.com wrote: if you are using RPX(janrain) you can have both methods at the same login page: http://web2pyslices.com/main/slices/take_slice/124 -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Tue, Jun 21, 2011 at 6:36 AM, Carl m...@carlroach.com wrote: after some digging I've found that creating Auth(db) is where the controller can be set (and is, of course, default by default :) I'm calling auth=Auth(db) in my db.py file Am I heading in the right direction to change the call to Auth() depending upon if the user is logging in via /init/default/user or init/id/user ? Or should I keep each different authentication type in default.py and configure in some way ? Guidance sort. On Jun 21, 10:01 am, Carl m...@carlroach.com wrote: My app to date has had one controller, default.py I had multiple login methods (LinkedIn and email address) for different sets of users. This caused a problem: when a user wasn't logged in, my app defaulted to prompt for a LinkedIn OAuth-style login. So I decided to pull the code for the two sets of user a part into init/default.py and a new file, init/id.py both now implement their own function user() Trouble is, when I call init/id/id which are decorated:@auth.requires_login() the user() function in init/ default.py is called rather than the one in init/id.py Where am I going wrong?
[web2py] tests in sys.path or custom_import?
I have 2 modules a.py and b.py inside applications/app/tests directory and am trying to import b.py from a.py. I find it not easy as I am calling a.py using web2py shell, which disallows the usage of __file__ (otherwise I could append the tests directory to sys.path). python web2py.py -S app -R applications/app/tests/a.py
[web2py] Re: mongoDBAdapter test ......
Hi Joe, That report is generated because the types dictionary for that key doesn't have a value that encodes a template for the field.length to be written into. If you look at the types at the top of the class, you'll notice that some types do have a template value and some do not. Unfortunately, you shouldn't have even got that far. If you look closely at the MongoDBAdapter and compare it to the CouchDB adapter, you'll notice that the Mongo adapter is barely implemented, and in fact, needs it's own specialization of the create_table method similar to the couchdb adapter in order to function correctly, i.e. all that SQL or DML stuff should not be happening for Mongo, because it doesn't speak that dialect. When I ran the couchdb adapter, it died in similar ways though I'm not sure why, but I suspect that, again, there's a missing method that should be marked not implemented which causes it to fail. Unfortunately, it's difficult to find these issues without a rigorous test suite and also, the design goals are difficult to interpret because the schemaless DBs simply don't require a lot of the munging that the relational ones do WRT to schema changes. FWIW, I've been using auth as a test for these schemaless DB classes. It would not be difficult to use that as an acid test (no pun intended) and automate that such that if the app survives initialization with auth turned on, you're at least through the C in CRUD in terms of verifying that the functionality works. I'm also a little concerned with the way these adapters are treating UUIDs in terms of translating from legacy IDs back and forth under the covers. We use UUIDs as ID fields even when we run PostgreSQL. Part of the value proposition of the schemaless DBs is to eliminate the problem of merging disparate relational database data into a single global entity, i.e the data silo problem of the last 20 years or so. UUIDs are a hard-stop requirement for that, and I'm not sure that this kind of code is a good idea WRT preserving that kind of functionality. See this article for more info: http://en.wikipedia.org/wiki/U-form Regards, David On May 5, 10:41 pm, joseph simpson jjs0...@gmail.com wrote: #!/usr/bin/python import sys import time sys.path.append('/Users/pcode/Desktop/mongodb_test/web2py') from gluon.dal import DAL, Field db = DAL('mongodb://127.0.0.1:5984/db') #mongodb test set #start with simple data types #then inser into mongodb db.define_table('m_test', Field('name','text'), Field('number','integer')) # # The above code produces the following error # Traceback (most recent call last): File ./test_mdb_1.py, line 7, in module db = DAL('mongodb://127.0.0.1:5984/db') File /Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py, line 3724, in __init__ raise RuntimeError, Failure to connect, tried %d times:\n%s % (attempts, error) RuntimeError: Failure to connect, tried 5 times: 'MongoDBAdapter' object has no attribute '_uri' # ### Make the following changes # Line number 3342 FROM: m = re.compile('^(?Phost[^\:/]+)(\:(?Pport[0-9]+))?/(?Pdb.+) $').match(self._uri[10:]) TO: m = re.compile('^(?Phost[^\:/]+)(\:(?Pport[0-9]+))?/(?Pdb.+) $').match(self.uri[10:]) Line number 3344 FROM: raise SyntaxError, Invalid URI string in DAL: %s % self._uri TO: raise SyntaxError, Invalid URI string in DAL: %s % self.uri # ### Execute code again # ### New error listed below # Traceback (most recent call last): File ./test_mdb_1.py, line 7, in module db = DAL('mongodb://127.0.0.1:5984/db') File /Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py, line 3724, in __init__ raise RuntimeError, Failure to connect, tried %d times:\n%s % (attempts, error) RuntimeError: Failure to connect, tried 5 times: port must be an instance of int # # Make the following change # Line 3351 FROM: port = m.group('port') or 27017 TO: port = 27017 ### ## # Now the code connects to the server but the error below is reported ### ### Traceback (most recent call last): File ./test_mdb_1.py, line 14, in module Field('number','integer')) File /Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py, line 4032, in define_table polymodel=polymodel) File
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
If you switch from SSL to non-SSL you may pick up a different session. I cannot say for sure. Byt print the auth.user_id value when you do the insert that causes trouble. On Jun 21, 2:16 am, pbreit pbreitenb...@gmail.com wrote: I switch between SSL and non-SSL for /user and not-/user. I wonder if that could be a problem?
[web2py] Re: how to ignore keyword in web2py
this is not supported at the moment but it is in our plans. On Jun 21, 3:23 am, sagar nigade browse2sa...@gmail.com wrote: Please let me know is it possible or not? On Tue, Jun 21, 2011 at 11:32 AM, sagar browse2sa...@gmail.com wrote: i have to use group as column name in web2py. i am using mysql as a db. in mysql we can do it using `group` in python we can do it using group_ d=db.test.insert(name=exacturl,group=) How to ignore keyword in web2py.
[web2py] Re: tests in sys.path or custom_import?
which web2py version? The latest version should allow __file__ in shell executed files. On Jun 21, 6:04 am, amit in4tu...@gmail.com wrote: I have 2 modules a.py and b.py inside applications/app/tests directory and am trying to import b.py from a.py. I find it not easy as I am calling a.py using web2py shell, which disallows the usage of __file__ (otherwise I could append the tests directory to sys.path). python web2py.py -S app -R applications/app/tests/a.py
Re: Re : Re: Re : Re: Re : Re: [web2py] Re: Email invitation
Thank you. So I will make a 30 dollar donation to the project. But it still does not work. This is what I get when I enter an email address to invite someone : Traceback (most recent call last): File gluon/restricted.py, line 181, in restricted File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 16, in module File gluon/globals.py, line 133, in lambda File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 6, in invitation File gluon/dal.py, line 4048, in __getattr__ File gluon/dal.py, line 4042, in __getitem__ KeyError: 'invitation' And this is what I get when I try to register using any address : Traceback (most recent call last): File gluon/restricted.py, line 181, in restricted File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/default.py, line 50, in module File gluon/globals.py, line 133, in lambda File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/default.py, line 30, in user File gluon/tools.py, line 1042, in __call__ File gluon/tools.py, line 1657, in register File gluon/sqlhtml.py, line 1031, in accepts File gluon/html.py, line 1732, in accepts File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/models/db.py, line 51, in lambda File gluon/dal.py, line 4048, in __getattr__ File gluon/dal.py, line 4042, in __getitem__ KeyError: 'invitation' What's the problem ? Thank you very much. Dwayne On 21 juin, 05:31, Massimo Di Pierro massimo.dipie...@gmail.com wrote: My mistake, should have been form.errors.update({'email':'not allowed'}) By adding the error message it prevent the user from registering (because he does not have a valid token). You do not need to pay me for help in this list but I will not refuse a donation. ;-) Massimo On Jun 20, 8:16 pm, Dwayne dwaynebl...@gmail.com wrote: Dear Massimo, Thank you very much. I'll send you the 30 dollars if it works :) I have a problem. I cannot compile : auth.settings.register_onvalidation.append(lambda form: db.invitation(token=form.vars.email) or form.errors.update({'email','not allowed'})) Why do I need : form.errors.update({'email','not allowed'}) ? Thank you very much ! Dwayne On 20 juin, 02:09, Massimo Di Pierro massimo.dipie...@gmail.com wrote: OK try this: definvitation(): form = SQLFORM.factory(Field('email',requires=IS_EMAIL())) if form.accepts(request): db.invitation.insert(token = form.vars.email) MESSAGE = 'click %s to register' url = URL('user/register',host=request.env.http_host) mail.send(to=form.vars.email, message=MESSAGE % url) redirect('success_invitation')) return dict(message=('Invitationto be sent'), form=form,address=form.vars.email) auth.settings.register_onvalidation.append(lambda form: db.invitation(token=form.vars.email) or form.errors.update({'email','not allowed'})) auth.settings.register_onaccept.append(lambda form: db(db.invitation.token==form.vars.email).delete()) On Jun 4, 9:28 am, Dwayne Blind dwaynebl...@gmail.com wrote: Can somebody please help me ? I would really want this to work. I customized db.auth_user, as described in the book, to add a 'token' field. I just added : Field('token', writable=False, readable=False, default=''). Then, in the controllers, I modified default.py : def user(): db.auth_user.insert(token=request.args(1)) return dict(form=auth()) Then in the models, I modified db.py : def my_auth_processing(form): if db(db.auth_user.token!='') (db.invitation.token==db.auth_user.token): return True else : return False auth.settings.register_onvalidation.append(lambda form: my_auth_processing(form)) But unfortunately no one is prevented from registering... So this does not work. Dwayne On 2 juin, 02:31, pbreit pbreitenb...@gmail.com wrote: Oops. For registration, you use this:http://web2py.com/book/default/chapter/08?search=register_onvalidatio...le texte des messages précédents - - Afficher le texte des messages précédents -- Masquer le texte des messages précédents - - Afficher le texte des messages précédents -
[web2py] Re: Gigya - Janrain alternative
Good morning, I realized I made a mistake in my previous post. I mistakenly added zeros to my numbers. I just realized Lanoba quoted me a free account at 250 unique registrations per month (not 2500) and that there first paid package includes 500 (not 5000). Sorry for the confusion. But in any case, it is still interesting for running tests in a dev environment and for adding to small websites. Regards, On Jun 20, 4:07 pm, Bruno Rocha rochacbr...@gmail.com wrote: Thanks for sharing, very nice, I will test it. On Mon, Jun 20, 2011 at 4:28 PM, TekNullOG a...@alexdavis.ca wrote: Hey guys, I found a new alternative. I've played around with their Free account. They have very similar services to Gigya and Janrain but offer their complete product for free to sites with less than 2500 monthly registrations (that's what sold me). I called to see if they support SSL encrypted pages and they said it was offered in their first paid package which is 49$/month and the limit is then increased to 5000 monthly registrations. The website ishttp://lanoba.com I hope this helps you guys. Let me know if you have questions. I've played around with most solutions out there. Cheers On May 13, 2:23 pm, Bruno Rocha rochacbr...@gmail.com wrote: Forget about it! This is really cool, I love the widgets but they are crazy! Gigya service cost for more than 1000 unique visitors/authentications per month is $15,000 per year
[web2py] Re: Social network plug-in
'friendship' is an Ajax callback defined later on. [OFF TOPIC] Finally a concise definition of friendship that I can hope to understand at some point in the future ;)
[web2py] virtualfields error
Hi, What changes have there with virtual fields in the last days (in trunk)? I can not run something that was working correctly. this worked: class ElementoIncidencia(object): def altura_es_par(self): return not bool(self.elementos_incidencia.altura % 2) tb_elementos_incidencias.virtualfields.append(ElementoIncidencia()) Error: ... TypeError: 'ElementoIncidencia' object is not callable I also tried with: tb_elementos_incidencias.virtualfields.append(ElementoIncidencia) Error: ... AttributeError: 'dictproxy' object has no attribute 'update' Jose
[web2py] Re: Speed of rendering html data (10,000+ rows)
If you really need to return 10,000 records to the browser, you should be returning json and then rending with some sort of data grid.
[web2py] Re: how to implement two different login processes?
I've found a simple solution... in db.py; change auth=Auth(db) to auth=Auth(db, controller=request.controller) with this small addition, auth will be initialised by whatever controller the user used to access the website. On Jun 21, 11:10 am, Carl Roach m...@carlroach.com wrote: thanks Bruno. My UI requirements are not to give a choice to visiting users so I specifically require the options on different pages. One page won't be indexed by search engines and will be by-invitation only. I'm using the LinkedIn API to access user data from LinkedIn's servers so JanRain isn't a solution for me for this product either. On 21 June 2011 10:51, Bruno Rocha rochacbr...@gmail.com wrote: if you are using RPX(janrain) you can have both methods at the same login page: http://web2pyslices.com/main/slices/take_slice/124 -- Bruno Rocha [ About me:http://zerp.ly/rochacbruno] On Tue, Jun 21, 2011 at 6:36 AM, Carl m...@carlroach.com wrote: after some digging I've found that creating Auth(db) is where the controller can be set (and is, of course, default by default :) I'm calling auth=Auth(db) in my db.py file Am I heading in the right direction to change the call to Auth() depending upon if the user is logging in via /init/default/user or init/id/user ? Or should I keep each different authentication type in default.py and configure in some way ? Guidance sort. On Jun 21, 10:01 am, Carl m...@carlroach.com wrote: My app to date has had one controller, default.py I had multiple login methods (LinkedIn and email address) for different sets of users. This caused a problem: when a user wasn't logged in, my app defaulted to prompt for a LinkedIn OAuth-style login. So I decided to pull the code for the two sets of user a part into init/default.py and a new file, init/id.py both now implement their own function user() Trouble is, when I call init/id/id which are decorated:@auth.requires_login() the user() function in init/ default.py is called rather than the one in init/id.py Where am I going wrong?
[web2py] Re: list: reference multiselect
What? No takers on this question? ;-) Could use some help here.
[web2py] Re: list: reference multiselect
Question is, which is the preferred method these days? Hmm, preferred by whom... it's difficult for one to answer for all. FWIW I guess I'm happy with the plugin wiki (jQueryUI?) multi-select.
Re: [web2py] Re: Speed of rendering html data (10,000+ rows)
why you need to return 10k records in one go ? -- Sebastian E. Ovide
[web2py] new cool library to handle websockets
http://socket.io/index.html#announcement
[web2py] Re: Speed of rendering html data (10,000+ rows)
@Sebastian, @pbreit, I understand what you mean to say. If I get you rightly, I should fetch only a limited no. of rows through pagination. It makes sense for most of the situations. But for some cases, rendering all the records on single page is required. e.g. consider a big automobile workshop. A report for spare parts price list (with 12,000 parts) is to be viewed. For the customer, using pagination clicking next, next,... is unsuitable. After rendering the total parts on single page, he/she may apply a desired filter and analyze the data. On Jun 21, 9:50 pm, Sebastian E. Ovide sebastian.ov...@gmail.com wrote: why you need to return 10k records in one go ? -- Sebastian E. Ovide
[web2py] Re: For Massimo: which version of book to buy?
How about we all write letters of recommendation to your Department Chair - just kidding :)
[web2py] Re: For Massimo: which version of book to buy?
LOL. Perhaps one day I will ask you something like that. Actually my department is very open-minded, both colleagues and administration. We have been offering CS intro sequence in python for log time. We had one of the first programs in security in the US certified as center of excellence by the NSA. We had one of the first degrees in video game programming. Allmost all out CS courses are available online (although not free). Massimo On Jun 21, 12:32 pm, mikech mp.ch...@gmail.com wrote: How about we all write letters of recommendation to your Department Chair - just kidding :)
[web2py] Re: Speed of rendering html data (10,000+ rows)
We used YUI DataTables at my last company and they worked really well but we only got up to around 1000 records on a page (with very quick paging, filtering and sorting). I've been wanting to hook them up to Web2py but haven't needed it so far. http://developer.yahoo.com/yui/datatable/
[web2py] Re: Speed of rendering html data (10,000+ rows)
Have you tried pasring the data using your 0.078 second method into a json format and using jQuery to parse it?
[web2py] 404 access denied problem with janrain on cube2py
I uncommented and edited the janrain code on a freshly installed version of cube2py with the latest web2py on ubuntu lucid. All four of the logins work; however, all 3 but google fail after they get back to cube2py as follows: If I try to go here: http://davidwatson.local/cube2py/plugin_wiki/page/home I get 404 not found. If I try to go here: http://davidwatson.local/cube2py/plugin_wiki/ I get forwarded here: http://davidwatson.local/cube2py/default/user/not_authorized with: Insufficient privileges Not authorized ACCESS DENIED What's interesting is that in each of the 3 failing cases, the logout and profile buttons show up and work, meaning that web2py clearly realizes a successful login, which makes me wonder if the problem is in cube2py. Any ideas? Thanks, David
[web2py] Re: Speed of rendering html data (10,000+ rows)
Maybe check out DataTables new virtual scrolling feature: http://datatables.net/blog/Introducing_Scroller_-_Virtual_Scrolling_for_DataTables. I think jQgrid may have a similar feature as well. Anthony On Tuesday, June 21, 2011 1:26:50 PM UTC-4, Vineet wrote: @Sebastian, @pbreit, I understand what you mean to say. If I get you rightly, I should fetch only a limited no. of rows through pagination. It makes sense for most of the situations. But for some cases, rendering all the records on single page is required. e.g. consider a big automobile workshop. A report for spare parts price list (with 12,000 parts) is to be viewed. For the customer, using pagination clicking next, next,... is unsuitable. After rendering the total parts on single page, he/she may apply a desired filter and analyze the data. On Jun 21, 9:50 pm, Sebastian E. Ovide sebasti...@gmail.com wrote: why you need to return 10k records in one go ? -- Sebastian E. Ovide
[web2py] what is globals() ?
Hi All, I see globals() everywhere and even if intuitively I guess what it is, I'd like to find more info about it... thanks -- Sebastian E. Ovide
Re: [web2py] what is globals() ?
On Jun 21, 2011, at 12:43 PM, Sebastian E. Ovide wrote: I see globals() everywhere and even if intuitively I guess what it is, I'd like to find more info about it... http://docs.python.org/library/functions.html#globals http://diveintopython.org/html_processing/locals_and_globals.html
[web2py] Re: 404 access denied problem with janrain on cube2py
I assume you created your own janrain account. Did you register the domain davidwatson.local with janrain? BTW davidwatson.local is not a valid domain name. On Jun 21, 1:30 pm, David Watson davidthewat...@gmail.com wrote: I uncommented and edited the janrain code on a freshly installed version of cube2py with the latest web2py on ubuntu lucid. All four of the logins work; however, all 3 but google fail after they get back to cube2py as follows: If I try to go here: http://davidwatson.local/cube2py/plugin_wiki/page/home I get 404 not found. If I try to go here: http://davidwatson.local/cube2py/plugin_wiki/ I get forwarded here: http://davidwatson.local/cube2py/default/user/not_authorized with: Insufficient privileges Not authorized ACCESS DENIED What's interesting is that in each of the 3 failing cases, the logout and profile buttons show up and work, meaning that web2py clearly realizes a successful login, which makes me wonder if the problem is in cube2py. Any ideas? Thanks, David
[web2py] Re: what is globals() ?
Those globals() are gone in web2py 1.96.X. Your legacy code that passes globals() around still works but that is was not a good design decision. On Jun 21, 2:43 pm, Sebastian E. Ovide sebastian.ov...@gmail.com wrote: Hi All, I see globals() everywhere and even if intuitively I guess what it is, I'd like to find more info about it... thanks -- Sebastian E. Ovide
[web2py] Renaming the admin application
A note I forgot to add to my previous message, I've renamed the admin application and I've found that the name is hardcoded in a lot of places... ¿shouldn't it be easier to change? To fix the applications I've changed the admin application name on the following files: ./app/controllers/appadmin.py ./app/models/menu.py ./app/views/default/index.html To change the links on the error messages I've added the following to my 'web2py/applications/__init__.py' file: # Adjust the default admin route for error_message_ticket admin_app_base_url = '/my_admin' from gluon import rewrite rewrite.thread.routes.error_message_ticket = 'htmlbodyh1Internal error/h1Ticket issued: a href=' + admin_app_base_url + '/default/ticket/%(ticket)s target=_blank%(ticket)s/a/body!-- this is junk text else IE does not display the page: ' + ('x'*512) + ' //--/html' But I don't like the solution, as I'm unsure if the __init__.py file will be overwritten on upgrades and feel that this should be adjusted on a different file. Is there a better solution? Where will you put a global setting? Would you accept a patch to simplify the renaming of the admin application? Greetings, Sergio. -- Sergio Talens-Oliag s...@iti.upv.es http://www.iti.upv.es/ Key fingerprint = FF77 A16B 9D09 FC7B 6656 CFAD 261D E19A 578A 36F2
[web2py] A couple of small bugs with cas_auth.py
I've started to use web2py for a new project and I've found a couple of small bugs on the gluon/contrib/login_methods/cas_auth.py file: 1. I'm serving the aplication using HTTPS, but the __init__ function hardcodes 'http' as scheme; to fix it I've changed the following: @@ -57,7 +57,11 @@ self.casusername = casusername http_host=current.request.env.http_x_forwarded_for if not http_host: http_host=current.request.env.http_host -self.cas_my_url='http://%s%s'%( http_host, current.request.env.path_info ) +if current.request.env.wsgi_url_scheme in [ 'https', 'HTTPS' ]: +scheme = 'https' +else: +scheme = 'http' +self.cas_my_url='%s://%s%s'%( scheme, http_host, current.request.env.path_info ) def login_url( self, next = / ): current.session.token=self._CAS_login() return next 2. I've developed a new login form (multi_cas_login_form) that allows the users to authenticate using the standard web2py authentication or use a remote CAS server from a list of configured servers; it works OK now, but while developing it I tested a chained authentication by mistake (a test application used the application configured to use the multi_cas_login_form as its CAS provider while I was logged using a remote CAS server, and the login failed). One of the problems was related to a simple typo: the _CAS_login function uses the ExpatError exception without importing it, to fix it I just moved the imports and qualified the exception: @@ -95,9 +99,9 @@ a,b,c = data[1].split( ':' )+[None,None] return dict(user=a,email=b,username=c) return None +import xml.dom.minidom as dom +import xml.parsers.expat as expat try: -import xml.dom.minidom as dom -import xml.parsers.expat as expat dxml=dom.parseString(data) envelop = dxml.getElementsByTagName(cas:authenticationSuccess) if len(envelop)0: @@ -113,7 +117,7 @@ res[key]=[res[key]] res[key].append(value) return res -except ExpatError: pass +except expat.ExpatError: pass return None # fallback Once the typo was fixed I found a real problem related to the XML processing: if there is a field without a value on the recived file, the line: value = x.childNodes[0].nodeValue.encode('utf8') fails because there are no elements on childNodes. My fix was also simple: @@ -103,7 +107,7 @@ if len(envelop)0: res = dict() for x in envelop[0].childNodes: -if x.nodeName.startswith('cas:'): +if x.nodeName.startswith('cas:') and len(x.childNodes): key = x.nodeName[4:].encode('utf8') value = x.childNodes[0].nodeValue.encode('utf8') if not key in res: The problem was related to the standard way of generating a local user with CASAuth; the default mapping does not include the 'first_name' and 'last_name' sent by the _CAS_login and that leaves the 'last_name' empty on the database (the 'first_name' is filled by the program using the 'username' or the 'email') and when I called the nested authentication the _CAS_login received the XML 'last_name' with an empty value. For that bug I fixed my application by adding a full mapping to the CASAuth objects (I set the 'username' and copy the 'email', 'first_name' and 'last_name' from the remote CAS server), but I believe that the fix is still valid anyway. I'm attaching a full patch to this message with the described changes. Greetings, Sergio. -- Sergio Talens-Oliag s...@iti.upv.es http://www.iti.upv.es/ Key fingerprint = FF77 A16B 9D09 FC7B 6656 CFAD 261D E19A 578A 36F2 --- web2py.orig/gluon/contrib/login_methods/cas_auth.py 2011-06-07 22:07:48.0 +0200 +++ web2py/gluon/contrib/login_methods/cas_auth.py 2011-06-21 19:09:12.549477656 +0200 @@ -57,7 +57,11 @@ self.casusername = casusername http_host=current.request.env.http_x_forwarded_for if not http_host: http_host=current.request.env.http_host -self.cas_my_url='http://%s%s'%( http_host, current.request.env.path_info ) +if current.request.env.wsgi_url_scheme in [ 'https', 'HTTPS' ]: +scheme = 'https' +else: +scheme = 'http' +self.cas_my_url='%s://%s%s'%( scheme, http_host, current.request.env.path_info ) def login_url( self, next = / ):
[web2py] Re: A couple of small bugs with cas_auth.py
Uploading your fix to trunk. Please check everything is ok. Thank you. Massimo On Jun 21, 12:52 pm, Sergio Talens-Oliag s...@iti.upv.es wrote: I've started to use web2py for a new project and I've found a couple of small bugs on the gluon/contrib/login_methods/cas_auth.py file: 1. I'm serving the aplication using HTTPS, but the __init__ function hardcodes 'http' as scheme; to fix it I've changed the following: @@ -57,7 +57,11 @@ self.casusername = casusername http_host=current.request.env.http_x_forwarded_for if not http_host: http_host=current.request.env.http_host - self.cas_my_url='http://%s%s'%( http_host, current.request.env.path_info ) + if current.request.env.wsgi_url_scheme in [ 'https', 'HTTPS' ]: + scheme = 'https' + else: + scheme = 'http' + self.cas_my_url='%s://%s%s'%( scheme, http_host, current.request.env.path_info ) def login_url( self, next = / ): current.session.token=self._CAS_login() return next 2. I've developed a new login form (multi_cas_login_form) that allows the users to authenticate using the standard web2py authentication or use a remote CAS server from a list of configured servers; it works OK now, but while developing it I tested a chained authentication by mistake (a test application used the application configured to use the multi_cas_login_form as its CAS provider while I was logged using a remote CAS server, and the login failed). One of the problems was related to a simple typo: the _CAS_login function uses the ExpatError exception without importing it, to fix it I just moved the imports and qualified the exception: @@ -95,9 +99,9 @@ a,b,c = data[1].split( ':' )+[None,None] return dict(user=a,email=b,username=c) return None + import xml.dom.minidom as dom + import xml.parsers.expat as expat try: - import xml.dom.minidom as dom - import xml.parsers.expat as expat dxml=dom.parseString(data) envelop = dxml.getElementsByTagName(cas:authenticationSuccess) if len(envelop)0: @@ -113,7 +117,7 @@ res[key]=[res[key]] res[key].append(value) return res - except ExpatError: pass + except expat.ExpatError: pass return None # fallback Once the typo was fixed I found a real problem related to the XML processing: if there is a field without a value on the recived file, the line: value = x.childNodes[0].nodeValue.encode('utf8') fails because there are no elements on childNodes. My fix was also simple: @@ -103,7 +107,7 @@ if len(envelop)0: res = dict() for x in envelop[0].childNodes: - if x.nodeName.startswith('cas:'): + if x.nodeName.startswith('cas:') and len(x.childNodes): key = x.nodeName[4:].encode('utf8') value = x.childNodes[0].nodeValue.encode('utf8') if not key in res: The problem was related to the standard way of generating a local user with CASAuth; the default mapping does not include the 'first_name' and 'last_name' sent by the _CAS_login and that leaves the 'last_name' empty on the database (the 'first_name' is filled by the program using the 'username' or the 'email') and when I called the nested authentication the _CAS_login received the XML 'last_name' with an empty value. For that bug I fixed my application by adding a full mapping to the CASAuth objects (I set the 'username' and copy the 'email', 'first_name' and 'last_name' from the remote CAS server), but I believe that the fix is still valid anyway. I'm attaching a full patch to this message with the described changes. Greetings, Sergio. -- Sergio Talens-Oliag s...@iti.upv.es http://www.iti.upv.es/ Key fingerprint = FF77 A16B 9D09 FC7B 6656 CFAD 261D E19A 578A 36F2 cas_auth.py.patch 1KViewDownload
Re: [web2py] Re: Validator: one of several fields must be non-empty
I found that all(empties) does the same of reduce(lambda x, y: x and y, empties)... And I write this for the case when we want only one field to be filled for a group of fields passed to the validator : class ONLY_ONE_CAN_BE_FILLED(object): Class representing a validator requiring at least one non-empty field in a set. def __init__( self, others, error_message='Enter a value in at least one field' ): self.others = others self.error_message = error_message def __call__(self, value): okay = (value, None) error = (value, self.error_message) values = [] values.append(value) values.extend(self.others) empties = [] for v in values: unused_v, empty = is_empty(v) empties.append(empty) if empties.count(False) == 1: return okay else: return error Here how to use it : requires=ONLY_ONE_CAN_BE_FILLED([request.vars.FIELD1,request.vars.FIELD2],error_message='Select only one field') It's a bit counter intuitive to count the False, but since we only have is_empty()... Richard On Fri, Jun 10, 2011 at 3:42 AM, David Marko dma...@tiscali.cz wrote: This(or some modofication) could be part of web2py core, I think its quite general purpose validator ... David
Re: [web2py] Re: Speed of rendering html data (10,000+ rows)
Or print it. I have had to do massive amounts of data in html and pdf format. BR, Jason Brower On 06/21/2011 08:26 PM, Vineet wrote: @Sebastian, @pbreit, I understand what you mean to say. If I get you rightly, I should fetch only a limited no. of rows through pagination. It makes sense for most of the situations. But for some cases, rendering all the records on single page is required. e.g. consider a big automobile workshop. A report for spare parts price list (with12,000 parts) is to be viewed. For the customer, using pagination clicking next, next,... is unsuitable. After rendering the total parts on single page, he/she may apply a desired filter and analyze the data. On Jun 21, 9:50 pm, Sebastian E. Ovidesebastian.ov...@gmail.com wrote: why you need to return 10k records in one go ? -- Sebastian E. Ovide
Re: [web2py] Re: Speed of rendering html data (10,000+ rows)
It can paginate data? _ *Gilson Filho* *Web Developer http://gilsondev.com*
Re: [web2py] Re: IS_IN_DB ability to sort selections? BOOK MISSING ORDERBY USAGE
Yes you are right I made a few search in the book and there is not write no where that you can use orderby= for IS_IN_DB validator... More chance to make it appears in the book with a proper email title... Richard On Wed, May 11, 2011 at 1:51 PM, Ross Peoples ross.peop...@gmail.comwrote: On Sunday, December 28, 2008 3:43:55 AM UTC-5, mdipierro wrote: in trunk now... IS_IN_DB(orderby=) I realize that this thread is like 2.5 years old, but this should be in the book. I was looking for this functionality and found it here.
[web2py] lost dropbox with IS_IN_DB multiple validators
Hello, I would like to know if the problem I face coming from the validator that I write or is a IS_IN_DB behavior in case of multiple validators?? Here my validator : class ONLY_ONE_CAN_BE_FILLED(object): Class representing a validator requiring at least one non-empty field in a set. def __init__( self, others, error_message='Enter a value in at least one field' ): self.others = others self.error_message = error_message def __call__(self, value): okay = (value, None) error = (value, self.error_message) values = [] values.append(value) values.extend(self.others) empties = [] for v in values: unused_v, empty = is_empty(v) empties.append(empty) if empties.count(False) == 1: return okay else: return error But when i use it like this I lost my dropbox for the FK field1 : db.table.field1.requires =\ [IS_NULL_OR(IS_IN_DB(db,'othertable.id','%(fieldrepresent)s',orderby=(' fieldrepresent'))), ONLY_ONE_CAN_BE_FILLED([request.vars.field2],error_message='Select a volume or an folder')] I remember I read something about IS_IN_DB and [IS_IN_DB]... Can I have the dropbox and the multiple validators at the same time?? Thanks Richard
Re: [web2py] lost dropbox with IS_IN_DB multiple validators
When you need to use additional validators with IS_IN_DB but still want the dropbox, you can add the additional validators to the IS_IN_DB validator via its '_and' argument -- see http://web2py.com/book/default/chapter/07#Database-Validators. However, I'm not sure if that works when IS_IN_DB is inside an IS_NULL_OR validator. (Actually, IS_NULL_OR has been deprecated in favor of IS_EMPTY_OR.) Anthony On Tuesday, June 21, 2011 5:16:12 PM UTC-4, Richard wrote: Hello, I would like to know if the problem I face coming from the validator that I write or is a IS_IN_DB behavior in case of multiple validators?? Here my validator : class ONLY_ONE_CAN_BE_FILLED(object): Class representing a validator requiring at least one non-empty field in a set. def __init__( self, others, error_message='Enter a value in at least one field' ): self.others = others self.error_message = error_message def __call__(self, value): okay = (value, None) error = (value, self.error_message) values = [] values.append(value) values.extend(self.others) empties = [] for v in values: unused_v, empty = is_empty(v) empties.append(empty) if empties.count(False) == 1: return okay else: return error But when i use it like this I lost my dropbox for the FK field1 : db.table.field1.requires =\ [IS_NULL_OR(IS_IN_DB(db,'othertable.id ','%(fieldrepresent)s',orderby=('fieldrepresent'))), ONLY_ONE_CAN_BE_FILLED([request.vars.field2],error_message='Select a volume or an folder')] I remember I read something about IS_IN_DB and [IS_IN_DB]... Can I have the dropbox and the multiple validators at the same time?? Thanks Richard
[web2py] Re: Renaming the admin application
Not the answer you're looking for but if it's not absolutely critical to change the name, I strongly suggest not changing it.
[web2py] Re: Renaming the admin application
El Tue, Jun 21, 2011 at 02:41:05PM -0700, pbreit va escriure: Not the answer you're looking for but if it's not absolutely critical to change the name, I strongly suggest not changing it. The problem is that I'm publishing the application on an https server that gives access to more applications that are not handled by web2py, that's why I've changed the name. Anyway, my problem is fixed for now, I just wanted to know if there was a proper web2py way of doing it. Thanks anyway. Greetings, Sergio. -- Sergio Talens-Oliag s...@iti.upv.es http://www.iti.upv.es/ Key fingerprint = FF77 A16B 9D09 FC7B 6656 CFAD 261D E19A 578A 36F2
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
The error shows that there was an auth.user.id but no auth.user_id Can you think of any reason why auth.user_id would not be getting set?
[web2py] routes for crud
Anyone have suggestions for the following routes: I want: sr = controller sr/1 = view record 1 sr/1/update = update sr/1/delete = delete sr/1/clone = clone sr/1/etc = other actions So I am thinking of the following route: Map sr/id/action --- sr/action/id routes_in = ( (r'/sr/(?Pid\d+)(?Pany.*)', r'/init/sr\gany/ \gid'), (r'/sr', r'/init/sr'), ) It seems that my: (r'/sr/(?Pid\d+)(?Pany.*)', r'/init/sr\gany/ \gid') is not working.
[web2py] Re: Auth over SSL
Where should I put session.secure()? And is it session.secure() or session._secure=True?
[web2py] Re: virtualfields error
Hi, My virtual fields were also affected by trunk, change set # 82b607e03f09. Can somebody please fix this?. Thanks, Carlos
[web2py] Re: Auth over SSL
Note, as far as I can tell, setting session.secure() doesn't restrict web2py from sending the cookie to the browser (i.e., web2py will send the cookie even if the connection isn't secure) -- it only tells the browser not to send the cookie back unless over a secure connection. Anthony On Tuesday, June 21, 2011 8:30:58 PM UTC-4, Anthony wrote: On Tuesday, June 21, 2011 7:13:34 PM UTC-4, pbreit wrote: Where should I put session.secure()? And is it session.secure() or session._secure=True? session.secure() simply does session._secure=True, so they are equivalent (though the former seems cleaner). It simply results in the 'Secure' attribute of the session cookie being turned on, which doesn't happen until after the controller is run, right before the response is returned to the server. So, you can probably set it anywhere it makes sense, perhaps in a model. Note, once the cookie is set to Secure, the browser will only send it back over an HTTPS connection -- if the user goes to a non-HTTPS part of the site, the cookie won't come back, and web2py may generate a new session and (non) secure cookie (unless nothing is written to the session on the non-HTTPS part of the site). Anthony
[web2py] Re: Auth over SSL
On Tuesday, June 21, 2011 7:13:34 PM UTC-4, pbreit wrote: Where should I put session.secure()? And is it session.secure() or session._secure=True? session.secure() simply does session._secure=True, so they are equivalent (though the former seems cleaner). It simply results in the 'Secure' attribute of the session cookie being turned on, which doesn't happen until after the controller is run, right before the response is returned to the server. So, you can probably set it anywhere it makes sense, perhaps in a model. Note, once the cookie is set to Secure, the browser will only send it back over an HTTPS connection -- if the user goes to a non-HTTPS part of the site, the cookie won't come back, and web2py may generate a new session and (non) secure cookie (unless nothing is written to the session on the non-HTTPS part of the site). Anthony
[web2py] Re: Renaming the admin application
Another option might be to leave the name 'admin' and use routes.py to rewrite incoming and outgoing URLs to 'admin' using a different name. Anthony On Tuesday, June 21, 2011 2:11:46 PM UTC-4, Sergio Talens-Oliag wrote: A note I forgot to add to my previous message, I've renamed the admin application and I've found that the name is hardcoded in a lot of places... ¿shouldn't it be easier to change? To fix the applications I've changed the admin application name on the following files: ./app/controllers/appadmin.py ./app/models/menu.py ./app/views/default/index.html To change the links on the error messages I've added the following to my 'web2py/applications/__init__.py' file: # Adjust the default admin route for error_message_ticket admin_app_base_url = '/my_admin' from gluon import rewrite rewrite.thread.routes.error_message_ticket = 'htmlbodyh1Internal error/h1Ticket issued: a href=' + admin_app_base_url + '/default/ticket/%(ticket)s target=_blank%(ticket)s/a/body!-- this is junk text else IE does not display the page: ' + ('x'*512) + ' //--/html' But I don't like the solution, as I'm unsure if the __init__.py file will be overwritten on upgrades and feel that this should be adjusted on a different file. Is there a better solution? Where will you put a global setting? Would you accept a patch to simplify the renaming of the admin application? Greetings, Sergio. -- Sergio Talens-Oliag s...@iti.upv.es http://www.iti.upv.es/ Key fingerprint = FF77 A16B 9D09 FC7B 6656 CFAD 261D E19A 578A 36F2
[web2py] Re: Unable to edit record in admin because of postgres fkey violation
No. It is very strange. Is it possible it gets overwritten somewhere? On Jun 21, 6:05 pm, pbreit pbreitenb...@gmail.com wrote: The error shows that there was an auth.user.id but no auth.user_id Can you think of any reason why auth.user_id would not be getting set?
[web2py] Re: virtualfields error
I reverted the change until this is better understood. Massimo On Jun 21, 7:14 pm, Carlos carlosgali...@gmail.com wrote: Hi, My virtual fields were also affected by trunk, change set # 82b607e03f09. Can somebody please fix this?. Thanks, Carlos
[web2py] Re: Auth over SSL
True. On Jun 21, 7:35 pm, Anthony abasta...@gmail.com wrote: Note, as far as I can tell, setting session.secure() doesn't restrict web2py from sending the cookie to the browser (i.e., web2py will send the cookie even if the connection isn't secure) -- it only tells the browser not to send the cookie back unless over a secure connection. Anthony On Tuesday, June 21, 2011 8:30:58 PM UTC-4, Anthony wrote: On Tuesday, June 21, 2011 7:13:34 PM UTC-4, pbreit wrote: Where should I put session.secure()? And is it session.secure() or session._secure=True? session.secure() simply does session._secure=True, so they are equivalent (though the former seems cleaner). It simply results in the 'Secure' attribute of the session cookie being turned on, which doesn't happen until after the controller is run, right before the response is returned to the server. So, you can probably set it anywhere it makes sense, perhaps in a model. Note, once the cookie is set to Secure, the browser will only send it back over an HTTPS connection -- if the user goes to a non-HTTPS part of the site, the cookie won't come back, and web2py may generate a new session and (non) secure cookie (unless nothing is written to the session on the non-HTTPS part of the site). Anthony
[web2py] Re: virtualfields error
Hi Massimo, Thanks for reverting this change. I see (in the new change that broke virtual fields) that you are comparing against types.InstanceType. I believe that does not work with new style classes (which is what I use for virtual fields)?. Anyways, thanks for reverting this. Carlos
Re: [web2py] lost dropbox with IS_IN_DB multiple validators
Great thanks Anthony, I will try that tomorrow first time and I will report back. Richard On Tue, Jun 21, 2011 at 5:35 PM, Anthony abasta...@gmail.com wrote: When you need to use additional validators with IS_IN_DB but still want the dropbox, you can add the additional validators to the IS_IN_DB validator via its '_and' argument -- see http://web2py.com/book/default/chapter/07#Database-Validators. However, I'm not sure if that works when IS_IN_DB is inside an IS_NULL_OR validator. (Actually, IS_NULL_OR has been deprecated in favor of IS_EMPTY_OR.) Anthony On Tuesday, June 21, 2011 5:16:12 PM UTC-4, Richard wrote: Hello, I would like to know if the problem I face coming from the validator that I write or is a IS_IN_DB behavior in case of multiple validators?? Here my validator : class ONLY_ONE_CAN_BE_FILLED(object)**: Class representing a validator requiring at least one non-empty field in a set. def __init__( self, others, error_message='Enter a value in at least one field' ): self.others = others self.error_message = error_message def __call__(self, value): okay = (value, None) error = (value, self.error_message) values = [] values.append(value) values.extend(self.others) empties = [] for v in values: unused_v, empty = is_empty(v) empties.append(empty) if empties.count(False) == 1: return okay else: return error But when i use it like this I lost my dropbox for the FK field1 : db.table.field1.requires =\ [IS_NULL_OR(IS_IN_DB(db,'other**table.id http://othertable.id ','%(fieldrepresent)s'**,orderby=('fieldrepresent'))), ONLY_ONE_CAN_BE_FILLED([**request.vars.field2],error_**message='Select a volume or an folder')] I remember I read something about IS_IN_DB and [IS_IN_DB]... Can I have the dropbox and the multiple validators at the same time?? Thanks Richard
[web2py] mySQL DB dumped to xml format -- import using DAL ?
Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] WebRTC
May interrested some of you : http://www.webrtc.org/home Richard
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] Re: new cool library to handle websockets
I'll have to see if my Socket.IO port of comet_messaging.py still works with the new version. --Greg On Jun 21, 12:08 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: http://socket.io/index.html#announcement
[web2py] Re: new cool library to handle websockets
Please tell us more On Jun 21, 8:40 pm, Gregory Hellings greg.helli...@gmail.com wrote: I'll have to see if my Socket.IO port of comet_messaging.py still works with the new version. --Greg On Jun 21, 12:08 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: http://socket.io/index.html#announcement
Re: [web2py] Re: new cool library to handle websockets
Massimo beat me too it. Interested as well On Jun 21, 2011 9:49 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Please tell us more On Jun 21, 8:40 pm, Gregory Hellings greg.helli...@gmail.com wrote: I'll have to see if my Socket.IO port of comet_messaging.py still works with the new version. --Greg On Jun 21, 12:08 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: http://socket.io/index.html#announcement
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
The easiest way is make a web2py model that matches these fields: db.define_table('bitmap', Field('bitmap_id','id'), Field('filename'), Field('kdb_id','integer'), Field('isDeleted','integer')) # 0 or 1 parse the XML into CSV (excel may be able to do it) and import the CSV. On Jun 21, 8:21 pm, mart msenecal...@gmail.com wrote: also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
sounds good, will do that then. Thanks, Mart :) On Jun 21, 9:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The easiest way is make a web2py model that matches these fields: db.define_table('bitmap', Field('bitmap_id','id'), Field('filename'), Field('kdb_id','integer'), Field('isDeleted','integer')) # 0 or 1 parse the XML into CSV (excel may be able to do it) and import the CSV. On Jun 21, 8:21 pm, mart msenecal...@gmail.com wrote: also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
last question... Do I really need to bother with PRIMARY KEY , KEY, CONSTRAINT, ENGINE and UNIQUE KEY ? thanks, Mart :) On Jun 21, 9:55 pm, mart msenecal...@gmail.com wrote: sounds good, will do that then. Thanks, Mart :) On Jun 21, 9:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The easiest way is make a web2py model that matches these fields: db.define_table('bitmap', Field('bitmap_id','id'), Field('filename'), Field('kdb_id','integer'), Field('isDeleted','integer')) # 0 or 1 parse the XML into CSV (excel may be able to do it) and import the CSV. On Jun 21, 8:21 pm, mart msenecal...@gmail.com wrote: also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] validators with DAL (stand alone)?
Hi, can validators such as IS_IN_DB(db,'table.id') be used outside of the web context (dal stand alone) ? Maybe there is a key word or something ? :) thanks again, Mart :)
Re: [web2py] validators with DAL (stand alone)?
Validators are evaluated when using DAL standalone, only if you use these two methods: db.validate_and_inset(...) instead of .insert() and just in trunk.. db.validate_and_update(..) instead of .update() I am working now on a new patch for Rows.validade_and_update_record(...) BTW: You can always make your own logic using validators in this way: *In [7]:* IS_NOT_EMPTY()([]) *Out[7]: *([], lazyT 'enter a value') * * *In [8]:* IS_NOT_EMPTY()([1,2,3]) *Out[8]: *([1, 2, 3], None) Returns a tuple with 2 values, the first will be the passed arg, the second will be None if it passes, and will be a T('error message') when it is invalidated. -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Tue, Jun 21, 2011 at 11:16 PM, mart msenecal...@gmail.com wrote: Hi, can validators such as IS_IN_DB(db,'table.id') be used outside of the web context (dal stand alone) ? Maybe there is a key word or something ? :) thanks again, Mart :)
Re: [web2py] validators with DAL (stand alone)?
Some more examples: *IS IN SET* In [29]: IS_IN_SET([1,2,3])(1) Out[29]: ('1', None) In [30]: IS_IN_SET([0,2,3])(1) Out[30]: ('1', lazyT 'value not allowed') *IS NOT IN DB* In [60]: IS_NOT_IN_DB(db,'auth_user.id')('3') Out[60]: ('3', None) ## NOTE that logic is inverse # my_id = 5 if IS_NOT_IN_DB(db,'table.id')(my_id)[1]: # if returns true, the value is already in db print sorry cant duplicate the record id else: #if returns false, means that the value is not in db db.table.insert(...) -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ]
[web2py] response.download reload model
Hi all, The model will be reloaded one time the each request? In my application, it's reload one time more when using the download image? It's correct? How i can do for the model reload only one time? Thanks.
[web2py] response.download reload model
Hi all, The model will be reloaded one time on each request? In my application, it's reload one time more when using the download image? It's correct? How i can do for the model reload only one time? Thanks.
[web2py] Re: validators with DAL (stand alone)?
awesome! thanks for the info! i'll use validate_and_insert validate_and_update (i think that should do it), and I look forward to seeing your Rows.validade_and_update_record()! :) thanks, Mart On Jun 21, 11:08 pm, Bruno Rocha rochacbr...@gmail.com wrote: Some more examples: *IS IN SET* In [29]: IS_IN_SET([1,2,3])(1) Out[29]: ('1', None) In [30]: IS_IN_SET([0,2,3])(1) Out[30]: ('1', lazyT 'value not allowed') *IS NOT IN DB* In [60]: IS_NOT_IN_DB(db,'auth_user.id')('3') Out[60]: ('3', None) ## NOTE that logic is inverse # my_id = 5 if IS_NOT_IN_DB(db,'table.id')(my_id)[1]: # if returns true, the value is already in db print sorry cant duplicate the record id else: #if returns false, means that the value is not in db db.table.insert(...) -- Bruno Rocha [ About me:http://zerp.ly/rochacbruno]
[web2py] duplicate of Field ID
Hi again (all or nothing it seems tonight :) ) so, I am building a model (to be used with DAL stand alone) based on some XML dump of a mySQL DB, and they have things like tableName_id instead of just 'id' unless I am doing it wrong, how do I use the value of a Field located in the same table? in this case, i would like to do something db.define_table('compiler', Field('compiler_id','integer',requires='compiler.id'),blabla) suggestions? thanks, Mart :)
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
no. On Jun 21, 9:00 pm, mart msenecal...@gmail.com wrote: last question... Do I really need to bother with PRIMARY KEY , KEY, CONSTRAINT, ENGINE and UNIQUE KEY ? thanks, Mart :) On Jun 21, 9:55 pm, mart msenecal...@gmail.com wrote: sounds good, will do that then. Thanks, Mart :) On Jun 21, 9:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The easiest way is make a web2py model that matches these fields: db.define_table('bitmap', Field('bitmap_id','id'), Field('filename'), Field('kdb_id','integer'), Field('isDeleted','integer')) # 0 or 1 parse the XML into CSV (excel may be able to do it) and import the CSV. On Jun 21, 8:21 pm, mart msenecal...@gmail.com wrote: also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] Re: mySQL DB dumped to xml format -- import using DAL ?
Excellent! thanks :) On Jun 21, 11:30 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: no. On Jun 21, 9:00 pm, mart msenecal...@gmail.com wrote: last question... Do I really need to bother with PRIMARY KEY , KEY, CONSTRAINT, ENGINE and UNIQUE KEY ? thanks, Mart :) On Jun 21, 9:55 pm, mart msenecal...@gmail.com wrote: sounds good, will do that then. Thanks, Mart :) On Jun 21, 9:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The easiest way is make a web2py model that matches these fields: db.define_table('bitmap', Field('bitmap_id','id'), Field('filename'), Field('kdb_id','integer'), Field('isDeleted','integer')) # 0 or 1 parse the XML into CSV (excel may be able to do it) and import the CSV. On Jun 21, 8:21 pm, mart msenecal...@gmail.com wrote: also, I found that they gave me the equivalent data in a .sql file would that be understood by DAL? thanks again, Mart :) On Jun 21, 9:14 pm, mart msenecal...@gmail.com wrote: Hi, let's say someone gave me a dump of a mySQL DB in xml format... something that looks like this: pma:structure_schemas pma:database name=test collation=latin1_swedish_ci charset=latin1 pma:table name=bitmap CREATE TABLE `bitmap` ( `bitmap_id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, `kdb_id` int(11) NOT NULL, `isDeleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bitmap_id`), KEY `kdb_id` (`kdb_id`), CONSTRAINT `bitmap_ibfk_1` FOREIGN KEY (`kdb_id`) REFERENCES `kdb` (`kdb_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1; /pma:table what would be the best way to migrate this to an SQLite DB, something that web2py could use? I know that DAL can export to xml, but does it also import from xml as well? Perhaps, this can be converted to CSV? As usual, any help is much appreciated, thanks, Mart :)
[web2py] Re: response.download reload model
Yes, all of the model files are run on every request, and when you download an image via the download function, that will generate another request. If you don't need to apply access controls to the image downloads, you can upload them into the 'static' folder instead of the 'uploads' folder and then server them directly from the 'static' folder, which will not generate a new request or run the models (I believe that's a faster way to serve the images anyway). If you've got lots of model code and don't want to run it all on every request, there are various strategies for dealing with that, such as moving some of the code to modules or controllers, or using the new conditional models functionality. Anthony On Tuesday, June 21, 2011 11:12:29 PM UTC-4, toan75 wrote: Hi all, The model will be reloaded one time on each request? In my application, it's reload one time more when using the download image? It's correct? How i can do for the model reload only one time? Thanks.
[web2py] Re: tests in sys.path or custom_import?
Massimo, thanks for your answer. I upgraded just yesterday to 1.96.x. I am getting the following: cat applications/app/tests/a.py print __file__ Traceback (most recent call last): File web2py.py, line 19, in module gluon.widget.start(cron=True) File /home/.../web2py/gluon/widget.py, line 808, in start import_models=options.import_models, startfile=options.run) File /home/.../web2py/gluon/shell.py, line 200, in run execfile(startfile, _env) File applications/app/tests/a.py, line 1, in module print __file__ NameError: global name '__file__' is not defined On Jun 21, 10:11 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: which web2py version? The latest version should allow __file__ in shell executed files. On Jun 21, 6:04 am, amit in4tu...@gmail.com wrote: I have 2 modules a.py and b.py inside applications/app/tests directory and am trying to import b.py from a.py. I find it not easy as I am calling a.py using web2py shell, which disallows the usage of __file__ (otherwise I could append the tests directory to sys.path). python web2py.py -S app -R applications/app/tests/a.py
Re: [web2py] Re: how to ignore keyword in web2py
ok. Thanks for your reply Massimo On Tue, Jun 21, 2011 at 7:40 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: this is not supported at the moment but it is in our plans. On Jun 21, 3:23 am, sagar nigade browse2sa...@gmail.com wrote: Please let me know is it possible or not? On Tue, Jun 21, 2011 at 11:32 AM, sagar browse2sa...@gmail.com wrote: i have to use group as column name in web2py. i am using mysql as a db. in mysql we can do it using `group` in python we can do it using group_ d=db.test.insert(name=exacturl,group=) How to ignore keyword in web2py.
[web2py] Tr.lời: Re: response.download reload model
Thank Anthony. It was clear to me. I find it takes longer to create the many data table (db.define_table). It will work if I put the define_table to modules? You have an example?
[web2py] Re: Tr.lời: Re: response.download reload model
On Wednesday, June 22, 2011 12:28:39 AM UTC-4, toan75 wrote: Thank Anthony. It was clear to me. I find it takes longer to create the many data table (db.define_table). It will work if I put the define_table to modules? You have an example? Others may have suggestions, but there are at least a couple possibilities. You could create a function or class in a module that takes your db object as an argument and creates some tables, and then call that function/class from a model (conditionally, only when needed) or from a controller. Alternatively, you could use the new 'current' object. Do 'from gluon import current' (which is a thread local storage object), and then add something like current.app.db = db. Then you can import 'current' into your module and the module will have access to current.app.db. For an example, you can see how Auth, Crud, and Mail are implemented in /gluon/tools.py. They make use of both methods above -- they reference the 'current' object to access the 'request' object (via current.request), but the 'db' object is passed to them as an argument. Anthony