[web2py] How to override gluon functions? (need best pratice)
Hi i'm triyng to override a function inside gluon/tools.py i've created a model named 0.py with this code def myaddrow(form, a, b, c, style, _id, position=-1): if style == divs: form[0].insert(position, DIV(DIV(LABEL(a), _class='someclass'), DIV(b, _class='someclass'), DIV(c, _class='someclass'), _id=_id)) elif style == table2cols: form[0].insert(position, TR(TD(LABEL(a), _class='someclass'), TD(c, _class='someclass'))) form[0].insert(position + 1, TR(TD(b, _class='someclass'), _colspan=2, _id=_id)) elif style == ul: form[0].insert(position, LI(DIV(LABEL(a), _class='someclass'), DIV(b, _class='someclass'), DIV(c, _class='someclass'), _id=_id)) elif style == bootstrap: form[0].insert(position, DIV(LABEL(a, _class='someclass'), DIV(b, SPAN(c, _class='someclass'), _class='someclass'), _class='someclass', _id=_id)) else: form[0].insert(position, TR(TD(LABEL(a), _class='someclass'), TD(b, _class='someclass'), TD(c, _class='someclass'), _id=_id)) from gluon import tools tools.addrow = myaddrow If i print tools.__dict__ i can see that the function is the right one ... 'addrow': function myaddrow at 0x05C55770 ... but no effect on final render of the page (the classes are still w2p_fw, w2p_fc, etc...) what i'm doing wrong? Can someone please post: 1. how to override a function inside a gluon module (not in a class) 2. how to override a function inside a class of gluon (in a class) the A() TAG for example 3. how this pratice will affect performance? sorry but i'm learning python alongside web2py so i'm not an expert in this Thanks in advance. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How to override gluon functions? (need best pratice)
Hey is working now !!! maybe was the browser cache, i don't know...i've restarted all and now is working! Anyway a reply to my original questions will be appreciated. (Still need to know theright way to do it) Il giorno venerdì 17 gennaio 2014 09:38:32 UTC+1, ccadmin ha scritto: Hi i'm triyng to override a function inside gluon/tools.py i've created a model named 0.py with this code def myaddrow(form, a, b, c, style, _id, position=-1): if style == divs: form[0].insert(position, DIV(DIV(LABEL(a), _class='someclass'), DIV(b, _class='someclass'), DIV(c, _class='someclass'), _id=_id)) elif style == table2cols: form[0].insert(position, TR(TD(LABEL(a), _class='someclass'), TD(c, _class='someclass'))) form[0].insert(position + 1, TR(TD(b, _class='someclass'), _colspan=2, _id=_id)) elif style == ul: form[0].insert(position, LI(DIV(LABEL(a), _class='someclass'), DIV(b, _class='someclass'), DIV(c, _class='someclass'), _id=_id)) elif style == bootstrap: form[0].insert(position, DIV(LABEL(a, _class='someclass'), DIV(b, SPAN(c, _class='someclass'), _class='someclass'), _class='someclass', _id=_id)) else: form[0].insert(position, TR(TD(LABEL(a), _class='someclass'), TD(b, _class='someclass'), TD(c, _class='someclass'), _id=_id)) from gluon import tools tools.addrow = myaddrow If i print tools.__dict__ i can see that the function is the right one ... 'addrow': function myaddrow at 0x05C55770 ... but no effect on final render of the page (the classes are still w2p_fw, w2p_fc, etc...) what i'm doing wrong? Can someone please post: 1. how to override a function inside a gluon module (not in a class) 2. how to override a function inside a class of gluon (in a class) the A() TAG for example 3. how this pratice will affect performance? sorry but i'm learning python alongside web2py so i'm not an expert in this Thanks in advance. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] list:reference, multiple=True vs. many-to-many with intermediate table
Hi, I have a dilemma about *list:reference, multiple=True vs. many-to-many with intermediate table.* I have Projects which haveto be in several categories. Is it better to use list:reference (to list categories from the categories table) or many-to-many? Which is faster in queries? Thanks for the answers. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: How to add a column?
Il 17/01/14 00:18, 黄祥 ha scritto: very detail and clear explaination with the examples, why not put this on the book on dal chapter? best regards, stifan +1 M. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] custom one-to-many left-join python object and json object
Hey, I have a simple one-to-many relation, between questions and answers. Each question may have 0 or more answers, so any *db.answer.question* refers to a certain *db.question.id*. Now, in order to create a code for efficiently displaying the questions and their belonging answers, I wonder: how to make the sql query, and how to generate the json object of the question and answer data? My preferred result of the json object would be a list of questions with the answers as a child list. Something like this: *[* * {text: Question 1, owner: 1, id: 17},* * {text: Question 2, owner: 1, id: 18, answers:[{...},{...}] }* *]* I'm thinking of different ways: 1. I can make one left outer join query to get all data in one sql operation, and then perhaps create a subset of questions and answers using the find of db objects. Is this even possible, as I wouldn't know the syntax of the sql query, nor of how to create such a json object. 2. I can make two queries, one for all the questions, one for all the answers, and create a python object in such a way that would generate the correct json object using response.json( python_object ). This solution doesn't seem very fast to code for me, as I don't know if web2py can make this easy for me using built-in tools. 3. I can make two queries, one for all the questions, one for all the answers, and let the javascript do the sorting. I think it would be fastest to let mysql do the sorting, and perhaps it wouldn't be so difficult to do any of the other solutions if you know web2py well enough. I wouldn't like to make my app too javascript heavy. Thanks a lot if you can help me further with this :) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
On Fri, Jan 17, 2014 at 5:18 AM, Arnon Marcus a.m.mar...@gmail.com wrote: A database scema is a description of the structure of a database - it has nothing to do with requests. You are talking about a convinience-feature that could have been implemented differently - this coupling is convinient but makes no sense from a performance standpoint. I am looking for a way around that... migrate=False is here to accomplish that. BTW, I think we have a misunderstanding point here. migrate=True is usefull mainly in development environment and it's an excellent feature, avoiding you to run command from shell, in a Django style. Change your model and know the db schema will be in sync with it autmatically is a great feature. It allows you to practice baby steps in your db structure. In development environment. On the other hand, migrate=True on production servers is a really bad practice. In production machines, your database user shouldn't have access to run DDL statements. It's a security commandment, right? So, in a system running in production, migrate=True should raise a grant error when it tries to sync db schema. migrate=True is our good friend, but just for dev environment. -- Vinicius Assef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: DAL usage
On Friday, January 17, 2014 2:18:50 AM UTC-5, Arnon Marcus wrote: A database scema is a description of the structure of a database - it has nothing to do with requests. You are talking about a convinience-feature that could have been implemented differently - this coupling is convinient but makes no sense from a performance standpoint. I am looking for a way around that... If there isn't any, it only means that for this to be possible it needs to be re-implemented in a way that would make that possible. Yes, as I mentioned, the problem is not coupling the schema with the connection but the fact that the model definition includes some relatively static attributes (such as the database schema) as well as some more dynamic attributes that might change from request to request. Your approach would require a re-implementation, with the database schema held in a structure separate from the rest of the model definition. On a typical request, it's not clear how much gain that would give you -- maybe a few milliseconds (though depending on your performance needs, I suppose that could be meaningful). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
I am trying to shave-off the needless DDL model definition in each request - when you have hundreds of tables with (cumulatively) thousands of fields, the needless overhead of having to re-compile all these objects on every request starts to add-up. It has nothing to do with auto-migration - you can still have auto-migration with schema-objects defined in an imported-module : every time the module changes, it re-compiles, and then auto-migration kicks in. I am talking about the coupling of mostly-static data with highly dynamic one - all within the same execution-architecture - it's a sub-optimal design. For small projects, that usually wouldn't matter, as the overhead would be small. For bigger projects though On Fri, Jan 17, 2014 at 4:52 PM, Anthony abasta...@gmail.com wrote: On Friday, January 17, 2014 2:18:50 AM UTC-5, Arnon Marcus wrote: A database scema is a description of the structure of a database - it has nothing to do with requests. You are talking about a convinience-feature that could have been implemented differently - this coupling is convinient but makes no sense from a performance standpoint. I am looking for a way around that... If there isn't any, it only means that for this to be possible it needs to be re-implemented in a way that would make that possible. Yes, as I mentioned, the problem is not coupling the schema with the connection but the fact that the model definition includes some relatively static attributes (such as the database schema) as well as some more dynamic attributes that might change from request to request. Your approach would require a re-implementation, with the database schema held in a structure separate from the rest of the model definition. On a typical request, it's not clear how much gain that would give you -- maybe a few milliseconds (though depending on your performance needs, I suppose that could be meaningful). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/WR6RAMRQesg/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
On Friday, January 17, 2014 10:01:35 AM UTC-5, Arnon Marcus wrote: I am trying to shave-off the needless DDL model definition in each request - when you have hundreds of tables with (cumulatively) thousands of fields, Are there requests where you need to use all or most of the database tables, or do you typically need only a handful of tables in any given request? If the latter, there is certainly no need to define all the tables on every request. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
There are conditional models in web2py. Normal flow control statements can be used to reduce the number of definitions too. 2014/1/17 Anthony abasta...@gmail.com On Friday, January 17, 2014 10:01:35 AM UTC-5, Arnon Marcus wrote: I am trying to shave-off the needless DDL model definition in each request - when you have hundreds of tables with (cumulatively) thousands of fields, Are there requests where you need to use all or most of the database tables, or do you typically need only a handful of tables in any given request? If the latter, there is certainly no need to define all the tables on every request. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
I guess we can try to do conditional executions... It's quite a hassle, though, as the controllers don't do all the work - most of our queries are in fact in separate modules that the controllers use, which make it much eazier to maintain but it would make it more difficult to segregate the conditionallity of schema-definitions based on controllers.. Not sure what other criteria we could use though... -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
Why don't you put your model definitions in modules (either inside of functions or classes)? Then, when you need a particular model or set of models, just import the relevant function/class and call it with whatever arguments are needed to give you the models you want. On Friday, January 17, 2014 10:45:24 AM UTC-5, Arnon Marcus wrote: I guess we can try to do conditional executions... It's quite a hassle, though, as the controllers don't do all the work - most of our queries are in fact in separate modules that the controllers use, which make it much eazier to maintain but it would make it more difficult to segregate the conditionallity of schema-definitions based on controllers.. Not sure what other criteria we could use though... -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Reloading a component and passing variables to it
Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target= 'priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Reloading a component and passing variables to it
Hello Jim, what's in priceListProductId ? I would see this in javascript : priceListProductId = {{=request.vars.priceListProductId}} ? Richard On Fri, Jan 17, 2014 at 11:32 AM, Jim S j...@qlf.com wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target= 'priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
I agree with Anthony, if you put table definitions inside functions you get a great deal of flexibility and speedup. e.g. def define_user_tables(): define_table('user' define_table('user_data', define_table('user_image' ... then you just call: define_user_tables() wherever you need those tables... 2014/1/17 Anthony abasta...@gmail.com Why don't you put your model definitions in modules (either inside of functions or classes)? Then, when you need a particular model or set of models, just import the relevant function/class and call it with whatever arguments are needed to give you the models you want. On Friday, January 17, 2014 10:45:24 AM UTC-5, Arnon Marcus wrote: I guess we can try to do conditional executions... It's quite a hassle, though, as the controllers don't do all the work - most of our queries are in fact in separate modules that the controllers use, which make it much eazier to maintain but it would make it more difficult to segregate the conditionallity of schema-definitions based on controllers.. Not sure what other criteria we could use though... -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] I want to pre-populate a custom form with values from the db
So here's my method as-is right now: def diagnosis_lookup(): ... var=request.args(0) ... if var is not None: query=db((db.diagnosis.consumer_id==request.args(0))).select(orderby =~db.diagnosis.id) form = FORM( TABLE( TR( Diagnosis: , INPUT(_name='diag') ), ... TR(INPUT(_type='submit')) ) ) if form.accepts(request.vars, session): db.diagnosis.update( diag_text=form.vars.diag, ... consumer_id=request.args(0) ) query = db((db.diagnosis.consumer_id==request.args(0))).select( orderby=~db.diagnosis.id) return locals() What I want to do is bring back whatever is already in the row so the form will be filled out when the page first loads. Or if its a new record, for the form to be blank. so I'm under the impression that the form should look something like: Diagnosis: , INPUT(_name='diag',_value=db.diagnosis.diag_text) but I haven't found an example of how it should look. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Can I/how would I create a self-signed certificate using IIS?
Thank you for the detailed explanation, I will take time to make this work, thanks. On Thursday, January 16, 2014 3:07:32 PM UTC-6, Richard wrote: Except if you need SSL only for your own (as a developper) needs I suggest you to walk the extra miles and create your own CA and sign you SSL certificate then you then deploy CA througt GPO with AD and you will not be bother again about self-signed SSL certificate... The link here you refer too, seems to talk about what I said... Deploy self-signed root certificate or CA, not self-signed SSL certificate... What is important is that your CA be in p12 or PKCS#12 format that containt the key and the certificate... To generate certificate you can use these command : # Create key of root certificate for Certification Authority openssl genrsa -des3 -out root_certificate.key 2048 -config /etc/ssl/openssl.cnf chmod 400 root_certificate.key cp root_certificate.key /etc/ssl/private/root_certificate.key # Self-signing of the root certificate key openssl req -x509 -new -nodes -key root_certificate.key -days 3650 -out root_certificate.crt -config /etc/ssl/openssl.cnf cp root_certificate.crt /etc/ssl/certs/root_certificate.crt # In order to windows and IE to understand the root certificate it needs a .p12 file that containt key and certificate of the CA # Here we create a PEM file containing the key and the certificate for our root CA certificate cat root_certificate.key root_certificate.crt root_certificate_key_crt.pem # Then we create the .p12 file openssl pkcs12 -export -out root_certificate.p12 -in root_certificate_key_crt.pem -name SUBDOMAIN CA Certificate PKCS#12 # Create a SSL certifcate openssl genrsa -out SUBDOMAIN.key 2048 chmod 400 SUBDOMAIN.key # For self-signing certificate (uncomment the lines below if required) # openssl req -new -x509 -nodes -sha1 -days 3650 -key SUBDOMAIN.key SUBDOMAIN.crt # openssl x509 -noout -fingerprint -text SUBDOMAIN.crt SUBDOMAIN.info # For SSL signed certificate by Certification Authority you need to issue a certificate signing request from it openssl req -new -key SUBDOMAIN.key -out SUBDOMAIN.csr # NOTE : Don't use A challenge password because you will be prompted for password each time webserver reboot... # Sign other SSL key with the root certificate key # openssl x509 -req -in SUBDOMAIN.csr -CA root_certificate.crt -CAkey root_certificate.key -CAcreateserial -out SUBDOMAIN.crt -days 3650 # NOTE : This command should work but to make sure the database get update and a copy of the key with the serial number is create the command below is better after customize /etc/ssl/openssl.cnf sudo touch /etc/ssl/CA/index.txt sudo nano /etc/ssl/CA/serial # and enter 1000 openssl ca -config /etc/ssl/openssl.cnf -out SUBDOMAIN.crt -infiles SUBDOMAIN.csr # Deployment sudo mkdir /etc/ssl/CA sudo mkdir /etc/ssl/newcerts sudo mkdir /etc/ssl/crl # Then set the config required in /etc/ssl/openssl.cnf in order to the root certificate and the SSL certificate get created in place cat SUBDOMAIN.crt root_certificate.crt server.crt cat SUBDOMAIN.key root_certificate.key server.key chmod 400 server.key sudo cp server.* /etc/nginx/ssl/ You need to configure OpenSSL (/etc/ssl/openss.cnf) before most execute most command since it will reduce the typing and error in the process to create a correct valid root certificate... Ref.: https://help.ubuntu.com/community/OpenSSL https://help.ubuntu.com/10.04/serverguide/certificates-and-security.html http://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file http://www.digicert.com/ssl-certificate-installation-nginx.htm http://technet.microsoft.com/en-us/library/cc772491.aspx http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/ http://twentyeighttwelve.com/setting-up-your-own-certificate-authority-on-iis7-using-openssl-and-securing-your-web-api-with-client-certificates/ You can also buy a CA for LAN here, but it is not going to continue for very long, Goddady stop recently to emit new certificate for LAN : http://www.instantssl.com/ssl-certificate-products/ssl/ssl-certificate-intranetssl.html?ap=ce046 Ref.: http://support.godaddy.com/help/article/6935/phasing-out-intranet-names-and-ip-addresses-in-ssls Hope it helps :) Richard On Thu, Jan 16, 2014 at 2:12 PM, Keith Planer kwpl...@gmail.comjavascript: wrote: I understand this link might have some guidance for me, but the link is down: http://www.web2py.com/AlterEgo/default/show/140 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving
[web2py] Re: Need opinions/reviews about embedded jquery/javascript XHTML editor
@Simon Anthony: Thanks so much for the pointer. I had forgotten about widgets ... I've never had to design one, yet. Can that approach also be adapted to work with TinyMCE, instead? On the surface, TinyMCE looks easier to mod than ckeditor. Also, so far, I prefer the TinyMCE doc. The CKEditor website starts out looking promising with slick marketing. But their doc isn't as well organized or thoroughly presented as TinyMCE. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Reloading a component and passing variables to it
priceListProductId is an integer that is being passed into the javascript function. However, I don't know how to specify that on the web2py_component call. Trying to pass it to the 'vars' parameter but can't get the syntax right. It isn't in the request object in web2py yet. -Jim On Friday, January 17, 2014 10:43:31 AM UTC-6, Richard wrote: Hello Jim, what's in priceListProductId ? I would see this in javascript : priceListProductId = {{=request.vars.priceListProductId}} ? Richard On Fri, Jan 17, 2014 at 11:32 AM, Jim S j...@qlf.com javascript:wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target= 'priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ultramemcache
I believe gluon/contrib/memcache/memcache.py is the memcache API. Web2py does not rely on python memcache being installed on the system. We added gluon/contrib/memcache/__init__.py On Thursday, 16 January 2014 16:17:21 UTC-6, Arnon Marcus wrote: I was going to, but couldn't find it... In fact, I even ran a full text-search on the entire web2py stack, and found no import memcache anywhere (nor from memcache for that matter...) Which is extremely weird, as it actually does work with my memcached server... Hmm... I guess I must have missed it, despite my due diligence, and probably my Pycharm as well... Any pointers on where it is? On Thu, Jan 16, 2014 at 11:06 PM, Niphlod nip...@gmail.com javascript:wrote: no, you can't. But if you want to write your own and the api is compatible, just change the imports at the top and hope for the best. On Thursday, January 16, 2014 12:02:11 PM UTC+1, Arnon Marcus wrote: We are using gevent, and we want to use memcached (for now, before we upgrade web2py to a version that supports redis...) I've noticed that there is threading going on in the gluon.memcache package - would this work with gevent? This package is specifically meant for using memcached from a gevent process: https://github.com/esnme/ultramemcache Can I make the existing gluon.memcache use this instead? Has anybody tried it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/-XCTWqTUJl0/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Important New Year News: Edison Award
Do not know but they asked for the logo and it was provided. On Thursday, 16 January 2014 17:27:23 UTC-6, Michele Comitini wrote: Why didn't they put the logo instead of a random snapshot?? 2014/1/16 Tim Richardson t...@growthpath.com.au javascript: web2py is now in the nominee showcase. As I write this, web2py is on page 20 of the nominee slide show. http://www.edisonawards.com/nomineegallery.php On Saturday, 4 January 2014 15:08:38 UTC+11, Massimo Di Pierro wrote: Web2py/me have been nominated for the Edison Award. Please wish web2py (and me) good luck. :-) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Reloading a component and passing variables to it
For example, when I call the reload using this method, it works: $('#priceListProductEdit2').load( '/infocenter/pricing/priceListProduct.load?priceListProductId=' +priceListProductId ); But am having trouble getting the javascript variable passed to the URL function call. -Jim On Friday, January 17, 2014 11:20:59 AM UTC-6, Jim S wrote: priceListProductId is an integer that is being passed into the javascript function. However, I don't know how to specify that on the web2py_component call. Trying to pass it to the 'vars' parameter but can't get the syntax right. It isn't in the request object in web2py yet. -Jim On Friday, January 17, 2014 10:43:31 AM UTC-6, Richard wrote: Hello Jim, what's in priceListProductId ? I would see this in javascript : priceListProductId = {{=request.vars.priceListProductId}} ? Richard On Fri, Jan 17, 2014 at 11:32 AM, Jim S j...@qlf.com wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target='priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Can I/how would I create a self-signed certificate using IIS?
I do not think you need a CA, but if you do, there is a PKI (and CA) for web2py, I created for personal needs. It allows you to create server certificate and manage client certificates. https://code.google.com/p/simpatica/ No instructions, the code is simple as it is the interface, and there are just 2 requirements besides web2py: - pyopenssl - M2Crypto mic 2014/1/17 Keith Planer kwplan...@gmail.com Thank you for the detailed explanation, I will take time to make this work, thanks. On Thursday, January 16, 2014 3:07:32 PM UTC-6, Richard wrote: Except if you need SSL only for your own (as a developper) needs I suggest you to walk the extra miles and create your own CA and sign you SSL certificate then you then deploy CA througt GPO with AD and you will not be bother again about self-signed SSL certificate... The link here you refer too, seems to talk about what I said... Deploy self-signed root certificate or CA, not self-signed SSL certificate... What is important is that your CA be in p12 or PKCS#12 format that containt the key and the certificate... To generate certificate you can use these command : # Create key of root certificate for Certification Authority openssl genrsa -des3 -out root_certificate.key 2048 -config /etc/ssl/openssl.cnf chmod 400 root_certificate.key cp root_certificate.key /etc/ssl/private/root_certificate.key # Self-signing of the root certificate key openssl req -x509 -new -nodes -key root_certificate.key -days 3650 -out root_certificate.crt -config /etc/ssl/openssl.cnf cp root_certificate.crt /etc/ssl/certs/root_certificate.crt # In order to windows and IE to understand the root certificate it needs a .p12 file that containt key and certificate of the CA # Here we create a PEM file containing the key and the certificate for our root CA certificate cat root_certificate.key root_certificate.crt root_certificate_key_crt.pem # Then we create the .p12 file openssl pkcs12 -export -out root_certificate.p12 -in root_certificate_key_crt.pem -name SUBDOMAIN CA Certificate PKCS#12 # Create a SSL certifcate openssl genrsa -out SUBDOMAIN.key 2048 chmod 400 SUBDOMAIN.key # For self-signing certificate (uncomment the lines below if required) # openssl req -new -x509 -nodes -sha1 -days 3650 -key SUBDOMAIN.key SUBDOMAIN.crt # openssl x509 -noout -fingerprint -text SUBDOMAIN.crt SUBDOMAIN.info # For SSL signed certificate by Certification Authority you need to issue a certificate signing request from it openssl req -new -key SUBDOMAIN.key -out SUBDOMAIN.csr # NOTE : Don't use A challenge password because you will be prompted for password each time webserver reboot... # Sign other SSL key with the root certificate key # openssl x509 -req -in SUBDOMAIN.csr -CA root_certificate.crt -CAkey root_certificate.key -CAcreateserial -out SUBDOMAIN.crt -days 3650 # NOTE : This command should work but to make sure the database get update and a copy of the key with the serial number is create the command below is better after customize /etc/ssl/openssl.cnf sudo touch /etc/ssl/CA/index.txt sudo nano /etc/ssl/CA/serial # and enter 1000 openssl ca -config /etc/ssl/openssl.cnf -out SUBDOMAIN.crt -infiles SUBDOMAIN.csr # Deployment sudo mkdir /etc/ssl/CA sudo mkdir /etc/ssl/newcerts sudo mkdir /etc/ssl/crl # Then set the config required in /etc/ssl/openssl.cnf in order to the root certificate and the SSL certificate get created in place cat SUBDOMAIN.crt root_certificate.crt server.crt cat SUBDOMAIN.key root_certificate.key server.key chmod 400 server.key sudo cp server.* /etc/nginx/ssl/ You need to configure OpenSSL (/etc/ssl/openss.cnf) before most execute most command since it will reduce the typing and error in the process to create a correct valid root certificate... Ref.: https://help.ubuntu.com/community/OpenSSL https://help.ubuntu.com/10.04/serverguide/certificates-and-security.html http://serverfault.com/questions/9708/what-is-a-pem- file-and-how-does-it-differ-from-other-openssl-generated-key-file http://www.digicert.com/ssl-certificate-installation-nginx.htm http://technet.microsoft.com/en-us/library/cc772491.aspx http://datacenteroverlords.com/2012/03/01/creating-your- own-ssl-certificate-authority/ http://twentyeighttwelve.com/setting-up-your-own- certificate-authority-on-iis7-using-openssl-and-securing- your-web-api-with-client-certificates/ You can also buy a CA for LAN here, but it is not going to continue for very long, Goddady stop recently to emit new certificate for LAN : http://www.instantssl.com/ssl-certificate-products/ssl/ ssl-certificate-intranetssl.html?ap=ce046 Ref.:http://support.godaddy.com/help/article/6935/phasing- out-intranet-names-and-ip-addresses-in-ssls Hope it helps :) Richard On Thu, Jan 16, 2014 at 2:12 PM, Keith Planer kwpl...@gmail.com wrote: I understand this link might have some guidance for me, but the link is down:
[web2py] Re: I want to pre-populate a custom form with values from the db
Have you looked at SQLFORM? http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM -Jim On Friday, January 17, 2014 10:55:55 AM UTC-6, Keith Planer wrote: So here's my method as-is right now: def diagnosis_lookup(): ... var=request.args(0) ... if var is not None: query=db((db.diagnosis.consumer_id==request.args(0))).select( orderby=~db.diagnosis.id) form = FORM( TABLE( TR( Diagnosis: , INPUT(_name='diag') ), ... TR(INPUT(_type='submit')) ) ) if form.accepts(request.vars, session): db.diagnosis.update( diag_text=form.vars.diag, ... consumer_id=request.args(0) ) query = db((db.diagnosis.consumer_id==request.args(0))).select( orderby=~db.diagnosis.id) return locals() What I want to do is bring back whatever is already in the row so the form will be filled out when the page first loads. Or if its a new record, for the form to be blank. so I'm under the impression that the form should look something like: Diagnosis: , INPUT(_name='diag',_value=db.diagnosis.diag_text) but I haven't found an example of how it should look. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: DAL read and variables
push, please, i still have no idea -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:reference or many-to-many
list:reference is faster for finding referenced fields many-to-many are faster for finding referencing fields. Usually categories are nested. I assume you want tags instead of categories (it is more general). I usually use both approaches and de-normalize it. Below there is class Tag (which is a little complex but can be used out of the box) and some example of usage: class Tag(object): class Validator(object): def __call__(self,values): if isinstance(values,str): values = values.split(',') tags = [IS_SLUG.urlify(x) for x in values] tags = [x.lower() for x in tags if x] return (tags, None) def formatter(self,values): return ', '.join(values) if values else '' @staticmethod def represent(v,r=None): return SPAN(*(SPAN(t,_class='tag') for t in v)) if v else '' @staticmethod def after_insert(fields, record_id, field2): if 'tags' in fields: for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def after_update(dbset,fields,field1,field2): if 'tags' in fields: subquery = dbset._select(field1.table.id) field2._db(field2.belongs(subquery)).delete() for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def connect(field1,name=tag): db = field1._db table = db.define_table(name,Field('name'),Field(field1.name,'reference thing')) field2 = table[field1.name] field1.requires = Tag.Validator field1.widget = SQLFORM.widgets.string.widget field1.represent = Tag.represent field1.table._after_insert.append(lambda f,u: Tag.after_insert(f,u,field2)) field1.table._after_update.append(lambda f,u: Tag.after_insert(f,u,field1,field2)) @staticmethod def has_all(field1,tags,name=tag,mode=and): db = field1._db table = db[name] if isinstance(tags,str): tags = [tags] queries = [] for tag in tags: queries.append(field1.table.id.belongs(db(table.name==tag)._select(table[field1.name]))) if mode=='and': return reduce(lambda a,b:ab, queries) else: return reduce(lambda a,b:a|b, queries) @staticmethod def has_any(field1,tags,name=tag): return Tag.has_all(field1,tags,name=name,mode=or) ### example of usage db.define_table('thing', Field('name'), Field('tags','list:string')) Tag.connect(db.thing.tags) db.thing.insert(name='table', tags=['round','blue']) print db(Tag.has_all(db.thing.tags,['round'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['red'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue', 'round'])).select(db.thing.ALL) print db(Tag.has_any(db.thing.tags,['red','round'])).select(db.thing.ALL) On Friday, 17 January 2014 03:21:52 UTC-6, Najtsirk wrote: Hi, I have a dilemma about *list:reference, multiple=True vs. many-to-many with intermediate table.* I have Projects which haveto be in several categories. Is it better to use list:reference (to list categories from the categories table) or many-to-many? Which is faster in queries? Thanks for the answers. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:reference or many-to-many
P.S. the custom validator makes the tags work great with this: https://github.com/xoxco/jQuery-Tags-Input On Friday, 17 January 2014 12:12:00 UTC-6, Massimo Di Pierro wrote: list:reference is faster for finding referenced fields many-to-many are faster for finding referencing fields. Usually categories are nested. I assume you want tags instead of categories (it is more general). I usually use both approaches and de-normalize it. Below there is class Tag (which is a little complex but can be used out of the box) and some example of usage: class Tag(object): class Validator(object): def __call__(self,values): if isinstance(values,str): values = values.split(',') tags = [IS_SLUG.urlify(x) for x in values] tags = [x.lower() for x in tags if x] return (tags, None) def formatter(self,values): return ', '.join(values) if values else '' @staticmethod def represent(v,r=None): return SPAN(*(SPAN(t,_class='tag') for t in v)) if v else '' @staticmethod def after_insert(fields, record_id, field2): if 'tags' in fields: for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def after_update(dbset,fields,field1,field2): if 'tags' in fields: subquery = dbset._select(field1.table.id) field2._db(field2.belongs(subquery)).delete() for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def connect(field1,name=tag): db = field1._db table = db.define_table(name,Field('name'),Field(field1.name,'reference thing')) field2 = table[field1.name] field1.requires = Tag.Validator field1.widget = SQLFORM.widgets.string.widget field1.represent = Tag.represent field1.table._after_insert.append(lambda f,u: Tag.after_insert(f,u,field2)) field1.table._after_update.append(lambda f,u: Tag.after_insert(f,u,field1,field2)) @staticmethod def has_all(field1,tags,name=tag,mode=and): db = field1._db table = db[name] if isinstance(tags,str): tags = [tags] queries = [] for tag in tags: queries.append(field1.table.id.belongs(db(table.name ==tag)._select(table[field1.name]))) if mode=='and': return reduce(lambda a,b:ab, queries) else: return reduce(lambda a,b:a|b, queries) @staticmethod def has_any(field1,tags,name=tag): return Tag.has_all(field1,tags,name=name,mode=or) ### example of usage db.define_table('thing', Field('name'), Field('tags','list:string')) Tag.connect(db.thing.tags) db.thing.insert(name='table', tags=['round','blue']) print db(Tag.has_all(db.thing.tags,['round'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['red'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue', 'round'])).select(db.thing.ALL) print db(Tag.has_any(db.thing.tags,['red','round'])).select(db.thing.ALL) On Friday, 17 January 2014 03:21:52 UTC-6, Najtsirk wrote: Hi, I have a dilemma about *list:reference, multiple=True vs. many-to-many with intermediate table.* I have Projects which haveto be in several categories. Is it better to use list:reference (to list categories from the categories table) or many-to-many? Which is faster in queries? Thanks for the answers. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Reloading a component and passing variables to it
I don't think it possible to pass javascript variable to web2py like that, it would be a big security hole if you can... Not sure how it applies, but when I want to pass vars to component I just call or redirect to URL with the appropriate vars that I want to pass to the component from the master view/controller (the one in which there is component embeded)... Then, my component just have to pickup the vars with request.vars.var with LOAD()... This can be does also with web2py_component() in javascript as show above... But maybe you have a different requirement that I don't understand because you don't explained you use case nor showed code... Richard On Fri, Jan 17, 2014 at 12:26 PM, Jim S j...@qlf.com wrote: For example, when I call the reload using this method, it works: $('#priceListProductEdit2').load( '/infocenter/pricing/priceListProduct.load?priceListProductId=' +priceListProductId ); But am having trouble getting the javascript variable passed to the URL function call. -Jim On Friday, January 17, 2014 11:20:59 AM UTC-6, Jim S wrote: priceListProductId is an integer that is being passed into the javascript function. However, I don't know how to specify that on the web2py_component call. Trying to pass it to the 'vars' parameter but can't get the syntax right. It isn't in the request object in web2py yet. -Jim On Friday, January 17, 2014 10:43:31 AM UTC-6, Richard wrote: Hello Jim, what's in priceListProductId ? I would see this in javascript : priceListProductId = {{=request.vars.priceListProductId}} ? Richard On Fri, Jan 17, 2014 at 11:32 AM, Jim S j...@qlf.com wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/ reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/ priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target='priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Can I/how would I create a self-signed certificate using IIS?
That is really nice Michele, thanks for sharing this... Richard On Fri, Jan 17, 2014 at 12:37 PM, Michele Comitini michele.comit...@gmail.com wrote: I do not think you need a CA, but if you do, there is a PKI (and CA) for web2py, I created for personal needs. It allows you to create server certificate and manage client certificates. https://code.google.com/p/simpatica/ No instructions, the code is simple as it is the interface, and there are just 2 requirements besides web2py: - pyopenssl - M2Crypto mic 2014/1/17 Keith Planer kwplan...@gmail.com Thank you for the detailed explanation, I will take time to make this work, thanks. On Thursday, January 16, 2014 3:07:32 PM UTC-6, Richard wrote: Except if you need SSL only for your own (as a developper) needs I suggest you to walk the extra miles and create your own CA and sign you SSL certificate then you then deploy CA througt GPO with AD and you will not be bother again about self-signed SSL certificate... The link here you refer too, seems to talk about what I said... Deploy self-signed root certificate or CA, not self-signed SSL certificate... What is important is that your CA be in p12 or PKCS#12 format that containt the key and the certificate... To generate certificate you can use these command : # Create key of root certificate for Certification Authority openssl genrsa -des3 -out root_certificate.key 2048 -config /etc/ssl/openssl.cnf chmod 400 root_certificate.key cp root_certificate.key /etc/ssl/private/root_certificate.key # Self-signing of the root certificate key openssl req -x509 -new -nodes -key root_certificate.key -days 3650 -out root_certificate.crt -config /etc/ssl/openssl.cnf cp root_certificate.crt /etc/ssl/certs/root_certificate.crt # In order to windows and IE to understand the root certificate it needs a .p12 file that containt key and certificate of the CA # Here we create a PEM file containing the key and the certificate for our root CA certificate cat root_certificate.key root_certificate.crt root_certificate_key_crt.pem # Then we create the .p12 file openssl pkcs12 -export -out root_certificate.p12 -in root_certificate_key_crt.pem -name SUBDOMAIN CA Certificate PKCS#12 # Create a SSL certifcate openssl genrsa -out SUBDOMAIN.key 2048 chmod 400 SUBDOMAIN.key # For self-signing certificate (uncomment the lines below if required) # openssl req -new -x509 -nodes -sha1 -days 3650 -key SUBDOMAIN.key SUBDOMAIN.crt # openssl x509 -noout -fingerprint -text SUBDOMAIN.crt SUBDOMAIN.info # For SSL signed certificate by Certification Authority you need to issue a certificate signing request from it openssl req -new -key SUBDOMAIN.key -out SUBDOMAIN.csr # NOTE : Don't use A challenge password because you will be prompted for password each time webserver reboot... # Sign other SSL key with the root certificate key # openssl x509 -req -in SUBDOMAIN.csr -CA root_certificate.crt -CAkey root_certificate.key -CAcreateserial -out SUBDOMAIN.crt -days 3650 # NOTE : This command should work but to make sure the database get update and a copy of the key with the serial number is create the command below is better after customize /etc/ssl/openssl.cnf sudo touch /etc/ssl/CA/index.txt sudo nano /etc/ssl/CA/serial # and enter 1000 openssl ca -config /etc/ssl/openssl.cnf -out SUBDOMAIN.crt -infiles SUBDOMAIN.csr # Deployment sudo mkdir /etc/ssl/CA sudo mkdir /etc/ssl/newcerts sudo mkdir /etc/ssl/crl # Then set the config required in /etc/ssl/openssl.cnf in order to the root certificate and the SSL certificate get created in place cat SUBDOMAIN.crt root_certificate.crt server.crt cat SUBDOMAIN.key root_certificate.key server.key chmod 400 server.key sudo cp server.* /etc/nginx/ssl/ You need to configure OpenSSL (/etc/ssl/openss.cnf) before most execute most command since it will reduce the typing and error in the process to create a correct valid root certificate... Ref.: https://help.ubuntu.com/community/OpenSSL https://help.ubuntu.com/10.04/serverguide/certificates-and-security.html http://serverfault.com/questions/9708/what-is-a-pem- file-and-how-does-it-differ-from-other-openssl-generated-key-file http://www.digicert.com/ssl-certificate-installation-nginx.htm http://technet.microsoft.com/en-us/library/cc772491.aspx http://datacenteroverlords.com/2012/03/01/creating-your- own-ssl-certificate-authority/ http://twentyeighttwelve.com/setting-up-your-own- certificate-authority-on-iis7-using-openssl-and-securing- your-web-api-with-client-certificates/ You can also buy a CA for LAN here, but it is not going to continue for very long, Goddady stop recently to emit new certificate for LAN : http://www.instantssl.com/ssl-certificate-products/ssl/ ssl-certificate-intranetssl.html?ap=ce046 Ref.:http://support.godaddy.com/help/article/6935/phasing- out-intranet-names-and-ip-addresses-in-ssls Hope it helps :) Richard On Thu,
Re: [web2py] Reloading a component and passing variables to it
Thanks Richard. Something you said in there triggered something for me and I think I know what to do now. Thanks Will post the solution once I find it. -Jim On Friday, January 17, 2014 12:14:30 PM UTC-6, Richard wrote: I don't think it possible to pass javascript variable to web2py like that, it would be a big security hole if you can... Not sure how it applies, but when I want to pass vars to component I just call or redirect to URL with the appropriate vars that I want to pass to the component from the master view/controller (the one in which there is component embeded)... Then, my component just have to pickup the vars with request.vars.var with LOAD()... This can be does also with web2py_component() in javascript as show above... But maybe you have a different requirement that I don't understand because you don't explained you use case nor showed code... Richard On Fri, Jan 17, 2014 at 12:26 PM, Jim S j...@qlf.com javascript:wrote: For example, when I call the reload using this method, it works: $('#priceListProductEdit2').load( '/infocenter/pricing/priceListProduct.load?priceListProductId=' +priceListProductId ); But am having trouble getting the javascript variable passed to the URL function call. -Jim On Friday, January 17, 2014 11:20:59 AM UTC-6, Jim S wrote: priceListProductId is an integer that is being passed into the javascript function. However, I don't know how to specify that on the web2py_component call. Trying to pass it to the 'vars' parameter but can't get the syntax right. It isn't in the request object in web2py yet. -Jim On Friday, January 17, 2014 10:43:31 AM UTC-6, Richard wrote: Hello Jim, what's in priceListProductId ? I would see this in javascript : priceListProductId = {{=request.vars.priceListProductId}} ? Richard On Fri, Jan 17, 2014 at 11:32 AM, Jim S j...@qlf.com wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/ reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/ priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target='priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Reloading a component and passing variables to it
Remember, everything inside {{...}} is rendered on the server before delivery to the browser, so you can't include JS in there. Instead, should be: web2py_component({{=URL('pricing', 'priceListProduct.load')}} + ?priceListProductId= + priceListProductId, target='priceListProductEdit') You have to add the query string entirely in JS, so you can't use the web2py URL() function for that part. Anthony On Friday, January 17, 2014 11:32:55 AM UTC-5, Jim S wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target= 'priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:reference or many-to-many
Thanks, Massimo. On Friday, 17 January 2014 19:12:00 UTC+1, Massimo Di Pierro wrote: list:reference is faster for finding referenced fields many-to-many are faster for finding referencing fields. Usually categories are nested. I assume you want tags instead of categories (it is more general). I usually use both approaches and de-normalize it. Below there is class Tag (which is a little complex but can be used out of the box) and some example of usage: class Tag(object): class Validator(object): def __call__(self,values): if isinstance(values,str): values = values.split(',') tags = [IS_SLUG.urlify(x) for x in values] tags = [x.lower() for x in tags if x] return (tags, None) def formatter(self,values): return ', '.join(values) if values else '' @staticmethod def represent(v,r=None): return SPAN(*(SPAN(t,_class='tag') for t in v)) if v else '' @staticmethod def after_insert(fields, record_id, field2): if 'tags' in fields: for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def after_update(dbset,fields,field1,field2): if 'tags' in fields: subquery = dbset._select(field1.table.id) field2._db(field2.belongs(subquery)).delete() for tag in fields.tags: d = {'name':tag, field2.name:record_id} field2.table.insert(**d) @staticmethod def connect(field1,name=tag): db = field1._db table = db.define_table(name,Field('name'),Field(field1.name,'reference thing')) field2 = table[field1.name] field1.requires = Tag.Validator field1.widget = SQLFORM.widgets.string.widget field1.represent = Tag.represent field1.table._after_insert.append(lambda f,u: Tag.after_insert(f,u,field2)) field1.table._after_update.append(lambda f,u: Tag.after_insert(f,u,field1,field2)) @staticmethod def has_all(field1,tags,name=tag,mode=and): db = field1._db table = db[name] if isinstance(tags,str): tags = [tags] queries = [] for tag in tags: queries.append(field1.table.id.belongs(db(table.name ==tag)._select(table[field1.name]))) if mode=='and': return reduce(lambda a,b:ab, queries) else: return reduce(lambda a,b:a|b, queries) @staticmethod def has_any(field1,tags,name=tag): return Tag.has_all(field1,tags,name=name,mode=or) ### example of usage db.define_table('thing', Field('name'), Field('tags','list:string')) Tag.connect(db.thing.tags) db.thing.insert(name='table', tags=['round','blue']) print db(Tag.has_all(db.thing.tags,['round'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['red'])).select(db.thing.ALL) print db(Tag.has_all(db.thing.tags,['blue', 'round'])).select(db.thing.ALL) print db(Tag.has_any(db.thing.tags,['red','round'])).select(db.thing.ALL) On Friday, 17 January 2014 03:21:52 UTC-6, Najtsirk wrote: Hi, I have a dilemma about *list:reference, multiple=True vs. many-to-many with intermediate table.* I have Projects which haveto be in several categories. Is it better to use list:reference (to list categories from the categories table) or many-to-many? Which is faster in queries? Thanks for the answers. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Reloading a component and passing variables to it
Of course that is the answer Anthony! For some reason I just wasn't able to come up with it today. Thanks for laying things out clearly, as you always do. Very much appreciated. All the best -Jim On Friday, January 17, 2014 1:02:27 PM UTC-6, Anthony wrote: Remember, everything inside {{...}} is rendered on the server before delivery to the browser, so you can't include JS in there. Instead, should be: web2py_component({{=URL('pricing', 'priceListProduct.load')}} + ?priceListProductId= + priceListProductId, target='priceListProductEdit') You have to add the query string entirely in JS, so you can't use the web2py URL() function for that part. Anthony On Friday, January 17, 2014 11:32:55 AM UTC-5, Jim S wrote: Trying to reload a component, passing new parameters to it. I have the following code based on this discussion: https://groups.google.com/forum/#!searchin/web2py/reload$20component/web2py/jZeJT0WFgV4/x4eeOpAFxh8J script type=text/javascript function priceListProductSiteEdit( priceListProductId ) { //alert(priceListProductId); //$('#priceListProductEdit2').load('/infocenter/pricing/priceListProduct.load?priceListProductId=' + priceListProductId); web2py_component({{=URL('pricing', 'priceListProduct.load', vars={'priceListProductId': + priceListProductId + })}}, target= 'priceListProductEdit'); } /script But, when my controller function is called, the value passed to the priceListProductId variable is + priceListProductId + not the value that is passed to the javascript function. I'm having a total brain-fart trying to figure out how to pass this properly. Can someone help please? -Jim -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
That's a good idea, thanks. On Fri, Jan 17, 2014 at 6:52 PM, Michele Comitini michele.comit...@gmail.com wrote: I agree with Anthony, if you put table definitions inside functions you get a great deal of flexibility and speedup. e.g. def define_user_tables(): define_table('user' define_table('user_data', define_table('user_image' ... then you just call: define_user_tables() wherever you need those tables... 2014/1/17 Anthony abasta...@gmail.com Why don't you put your model definitions in modules (either inside of functions or classes)? Then, when you need a particular model or set of models, just import the relevant function/class and call it with whatever arguments are needed to give you the models you want. On Friday, January 17, 2014 10:45:24 AM UTC-5, Arnon Marcus wrote: I guess we can try to do conditional executions... It's quite a hassle, though, as the controllers don't do all the work - most of our queries are in fact in separate modules that the controllers use, which make it much eazier to maintain but it would make it more difficult to segregate the conditionallity of schema-definitions based on controllers.. Not sure what other criteria we could use though... -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/WR6RAMRQesg/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: ultramemcache
Oh... I didn't think of that - now it makes sense. Is that a different api? I mean, is the code there different then the one in PYPi (pip)? On Fri, Jan 17, 2014 at 7:22 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I believe gluon/contrib/memcache/memcache.py is the memcache API. Web2py does not rely on python memcache being installed on the system. We added gluon/contrib/memcache/__init__.py On Thursday, 16 January 2014 16:17:21 UTC-6, Arnon Marcus wrote: I was going to, but couldn't find it... In fact, I even ran a full text-search on the entire web2py stack, and found no import memcache anywhere (nor from memcache for that matter...) Which is extremely weird, as it actually does work with my memcached server... Hmm... I guess I must have missed it, despite my due diligence, and probably my Pycharm as well... Any pointers on where it is? On Thu, Jan 16, 2014 at 11:06 PM, Niphlod nip...@gmail.com wrote: no, you can't. But if you want to write your own and the api is compatible, just change the imports at the top and hope for the best. On Thursday, January 16, 2014 12:02:11 PM UTC+1, Arnon Marcus wrote: We are using gevent, and we want to use memcached (for now, before we upgrade web2py to a version that supports redis...) I've noticed that there is threading going on in the gluon.memcache package - would this work with gevent? This package is specifically meant for using memcached from a gevent process: https://github.com/esnme/ultramemcache Can I make the existing gluon.memcache use this instead? Has anybody tried it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/web2py/-XCTWqTUJl0/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/-XCTWqTUJl0/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] DAL read and variables
My attempts to help inline below. 2014/1/14 DAL read and variables trendhhcfreelan...@googlemail.com Hi guys, this question is about tree things at once. The first on is as follow: I have this code: [code] in the models (not so importantthis part works fine): dba = DAL('mysql://web2py:test@localhost/testdb') dba.define_table('person', Field('name', requires=IS_NOT_EMPTY()), Field('email', requires=IS_NOT_EMPTY())) in the controller: def index(): a = 'Hallo Besucher. Wie geht es ihnen?' b = 'Hier kann man Daten eingeben. ', URL('eingeben') c = 'Hier kann man daten ausgeben' b = A('Hier kann man Daten eingeben. ', _href=URL('eingeben')) return dict( Welcome=a, eingabe=b, showdata=c) def eingeben(): form = SQLFORM(dba.person) form.add_button('records', URL('ausgabe')) if form.process().accepted: session.flash = 'form accepted' redirect(URL('ausgabe')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form) def ausgabe(): a = 4 records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name ),headers='fieldname:capitalize') return dict(records=records) # I think I do not fully understand what is the problem but I try ;-) def ausgabe(): a = 4 records = SQLTABLE(dba(dba.person._id== a).select(dba.person.name ),headers='fieldname:capitalize') newvariable = records[0].name return dict(records=records) [/code] 1. in def index(), you see this: b = 'Hier kann man Daten eingeben. ', URL('eingeben') but this does not work fine, i want to get a link with the text Hier kann man Daten eingeben. and a link to eingeben 2. in def ausgabe(), you see this: variable = 4 records = SQLTABLE(dba(dba.person._id== variable).select( dba.person.name),headers='fieldname:capitalize') it should work like this, the variable in the first line should be used in the dba.person._id==variable 3. def ausgabe(): a = 4 records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name ),headers='fieldname:capitalize') return dict(records=records) ok, lets assume, the first line in the data bank is 1 marc t...@gmail.com the code on the top leeds to the following output: Name marc is there some way to get a variable like newvariable = 'marc' I hope you can help me, i spent hours in trying, but i didn't found anything that helped me. the handbook doesnt cover such basic stuff , or i didn't found it :( Thank you very much, Darren -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: DAL read and variables
I did not follow you right, but I'll try to help you where I did understand. In 1. where you say i want to get a link with the text Hier kann man Daten eingeben. and a link to eingeben. You could use the A() helper . As the following: A(Hier kann man Daten eingeben.,_href=URL('eingeben')) It will generates to you this: a href=/YOUR_APPLICATION/YOUR_CONTROLLER/eingeben data-w2p_disable_with= defaultHier kann man Daten eingeben./a Ok? For 2. and 3. I did not understand your doubt. If you want to put 'marc' result in a variable, just do this: newvariable = records[0].name Got it? And above I did assume that there is only one record on results. On Tuesday, January 14, 2014 7:33:58 PM UTC-3, DAL read and variables wrote: Hi guys, this question is about tree things at once. The first on is as follow: I have this code: [code] in the models (not so importantthis part works fine): dba = DAL('mysql://web2py:test@localhost/testdb') dba.define_table('person', Field('name', requires=IS_NOT_EMPTY()), Field('email', requires=IS_NOT_EMPTY())) in the controller: def index(): a = 'Hallo Besucher. Wie geht es ihnen?' b = 'Hier kann man Daten eingeben. ', URL('eingeben') c = 'Hier kann man daten ausgeben' return dict( Welcome=a, eingabe=b, showdata=c) def eingeben(): form = SQLFORM(dba.person) form.add_button('records', URL('ausgabe')) if form.process().accepted: session.flash = 'form accepted' redirect(URL('ausgabe')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form) def ausgabe(): a = 4 records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name ),headers='fieldname:capitalize') return dict(records=records) [/code] 1. in def index(), you see this: b = 'Hier kann man Daten eingeben. ', URL('eingeben') but this does not work fine, i want to get a link with the text Hier kann man Daten eingeben. and a link to eingeben 2. in def ausgabe(), you see this: variable = 4 records = SQLTABLE(dba(dba.person._id== variable).select( dba.person.name),headers='fieldname:capitalize') it should work like this, the variable in the first line should be used in the dba.person._id==variable 3. def ausgabe(): a = 4 records = SQLTABLE(dba(dba.person._id== 1).select(dba.person.name ),headers='fieldname:capitalize') return dict(records=records) ok, lets assume, the first line in the data bank is 1 marc te...@gmail.comjavascript: the code on the top leeds to the following output: Name marc is there some way to get a variable like newvariable = 'marc' I hope you can help me, i spent hours in trying, but i didn't found anything that helped me. the handbook doesnt cover such basic stuff , or i didn't found it :( Thank you very much, Darren -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom one-to-many left-join python object and json object
I could kind of find a solution to this. If I create a dictionary from the rows they are easy to manipulate as I want. Although the json data is not exactly as I asked for, this solution was easier to create: db_questions = db( db.question.owner==auth.user.id).select( limitby=(0,5) ) questions_dict = db_questions.as_dict() # find answers to selected questions query = db.self_enquiry_a.id == 0 for question_id in questions_dict.keys(): # build query query |= db.answer.question == int(question_id) # add answers key to questions_dict questions_dict[question_id][answers] = [] db_answers = db( query ).select() # created desired dict struct for answer in db_answers.as_list(): question_id = answer['question'] questions_dict[question_id][answers].append(answer) json_questions=XML(response.json(questions_dict)) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] call a function inside the same view
Hello, New to this so please bare with me. I am trying to call show_form() inside my tracker_form view below is my functions inside default.py. how do I call show_form() with my sql inside tracker_form view so I can see my results as soon as I submit the form? The view is: tracker_form 1 2 3 4 5 6 7 8 9 10 {{extend 'layout.html'}} h4centerTracking/center/h4 {{=form}} {{=BEAUTIFY(request.vars)}} h4a href = http://127.0.0.1:8000/WnD/default/show_form;Show Records/a -- this is a link to show_form() /h4 def index(): return dict() def tracker_form(): record = db.content(request.args(0)) show_record = request.args(0) form = SQLFORM(db.content, record) if form.process().accepted: response.flash = 'Submitted Successfully!' response.view = 'http://127.0.0.1:8000/WnD/default/show_form' #show_form function here! elif form.errors: response.flash = 'Form is not correct' else: response.flash = 'Please fill out the damn form' return dict(form=form) def show_form(results): #rows = db().select(db.content.ALL) return dict(grid=SQLFORM.grid(db.content)) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Migrating field from string to integer type
Hi folks, I'm wondering whether it's safe to just change the data type of a field from 'string' to 'integer' if all of the field values are integer strings (i.e., strings that could be converted properly with python's int(string)). Will the data be safe in such a conversion or do I need to use an intermediate temporary field to hold the data, then perform the migration, and then move the data back. Thanks, Ian -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
is conditional models is same like response.models_to_run()? because i searched in this form related with conditional models, yet the experts in that discussions talk about put the models into modules and import it when needed. ref: https://groups.google.com/forum/#!topic/web2py/b65mya4wamg another thing is, how about the performance according to put the models into modules and response.models_to_run()? which is better? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Can not run web2py_no_console.exe. Version 2.8.2 on win 7 x 64
On Sunday, December 15, 2013 10:00:19 AM UTC-7, Rob Paire wrote: Hello all, I am having same problem running on Windows server 2003 32bit. When I launch web2py.exe the following dialog error appears: *Title: Error Entry Point Not Found* *Description: The procedure entry point wcscpy_s could not be located in the dynamic link library msvcrt.dll* Clicking OK returns control to the web2py executable which fails with the following console message: C:\web2pyweb2py Traceback (most recent call last): File string, line 6, in module File __main__.py, line 128, in module File __main__web2py__.py, line 18, in module File /home/mdipierro/make_web2py/web2py/gluon/__init__.py, line 15, in modu le File /home/mdipierro/make_web2py/web2py/gluon/globals.py, line 19, in modul e File /home/mdipierro/make_web2py/web2py/gluon/xmlrpc.py, line 10, in module File SimpleXMLRPCServer.py, line 102, in module File xmlrpclib.py, line 144, in module File httplib.py, line 79, in module File mimetools.py, line 6, in module File tempfile.py, line 35, in module File random.py, line 879, in module File random.py, line 97, in __init__ File random.py, line 111, in seed WindowsError: [Error -2146893795] Provider DLL failed to initialize correctly I reverted back to 2.7.4 for the time being. Same problem here. I guess that *msvcrt.dll* thing is because the web2py282 windows builder is running on a different Windows platform than before. Now I have to roll back. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: DAL usage
On Friday, January 17, 2014 7:18:00 PM UTC-5, 黄祥 wrote: is conditional models is same like response.models_to_run()? because i searched in this form related with conditional models, Yes, conditional models generally refers to use of models_to_run. Note, there is a default models_to_run that runs models in folders named the same as the current controller and (optionally) function. You can change that by specifying a custom models_to_run. another thing is, how about the performance according to put the models into modules and response.models_to_run()? which is better? Assuming you use models_to_run to define the exact same set of models as you import from modules, then performance should be similar, with a slight edge to the import method (using models_to_run requires putting models in model files, which must be read in and executed on each request, whereas module files do not need to be read on every request, only on the first import). If you need very fine-grained control over exactly which models are defined when, importing from modules exactly when/where needed might be simpler than trying to conditionally define models_to_run (which must be done within the model files, before you get to the controller code). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Need opinions/reviews about embedded jquery/javascript XHTML editor
Update: having now hacked on CKEditor and TinyMCE, I think I'm shifted over to TinyMCE. Seems a lot simpler to deal with and more organized. I can't vouch for the total functionality of the package, but it seems to do most of what I need. The doc and examples are clear, well organized, and effective. No marketing fluff. On Saturday, January 18, 2014 1:12:17 AM UTC+8, weheh wrote: @Simon Anthony: Thanks so much for the pointer. I had forgotten about widgets ... I've never had to design one, yet. Can that approach also be adapted to work with TinyMCE, instead? On the surface, TinyMCE looks easier to mod than ckeditor. Also, so far, I prefer the TinyMCE doc. The CKEditor website starts out looking promising with slick marketing. But their doc isn't as well organized or thoroughly presented as TinyMCE. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.