[web2py] Re: Few general questions
honestly i don't know what user.html looks like (i don't think i have one in any of my applications.but i have not used the new wizard yet). remember that URL items are passed as arguments, and so if you have none then request.args(0) will be None. that HTML file assume that there is at least 1 argument passed to the function, you are now trying to re-use that file as in include/extend for a function/view that does not require arguments and so it's None. you could edit it to check for None before doing the replace if you really need to have that included. good luck! cfh
[web2py] Re: Few general questions
Thank you! The sample table is populated by "db_wizard_populate.py" module. For those who had similar issue: comment all the lines in the above file on deployment. Your pointed me to the line that causes the view error: in user.html- the default one, there is a line with {{=T(request.args(0).replace('_',' ').capitalize()}} . My question is what does the line do and why args(0) is None when rendering through index.html? On Feb 7, 7:04 pm, howesc wrote: > about the sample entries: you must have some code (probably in one of your > models files) that adds sample entries when an empty database is detected. > not sure though without looking at the application. > > your view error is provided in the traceback (though perhaps cryptic). > something in index.html or one of the files it includes or extends is trying > to access the 'replace' attribute of a variable that is None. you may have > the proper include/extend syntax but are not setting a required variable in > the controller. > > cfh
[web2py] Re: Few general questions
about the sample entries: you must have some code (probably in one of your models files) that adds sample entries when an empty database is detected. not sure though without looking at the application. your view error is provided in the traceback (though perhaps cryptic). something in index.html or one of the files it includes or extends is trying to access the 'replace' attribute of a variable that is None. you may have the proper include/extend syntax but are not setting a required variable in the controller. cfh
[web2py] Re: Few general questions
Thanks! I'd be glad to get help about the last two issues I described. On Feb 4, 7:43 pm, Kenneth Lundström wrote: > The model files will be executed in alfabetical order. So there is a > difference. > > Kenneth > > - Ursprungsmeddelande - > > > > > > > > > Thanks for your reply. Regarding the first answer: does it mean that > > every model from my app will be called on every page refresh? Do the > > names of the model files have any effect? I.e. if I rename db.py to > > mydb.py, or change "0.py" to something else - what will happen behind > > the scene? > > > Regarding my third question: the tree structure is something that I > > did understand. The problem is an error which makes me think that I do > > something wrong. While trying to perform the described above, I the > > following traceback: > > > Traceback (most recent call last): > > File "C:\Users\viu\Desktop\web2py\gluon\restricted.py", line 188, in > > restricted > > exec ccode in environment > > File "C:\Users\viu\Desktop\web2py\applications\Registrar/views > > \default/index.html", line 99, in > > AttributeError: 'NoneType' object has no attribute 'replace'. > > > I have index.html with "include 'default/user.html'". user.html > > doesn't have extend. > > > Regarding my last question, I will try to clarify: I found out that > > after uploading the app to GAE, the example records are being added to > > my app at GAE. I.e. I have: "Sacemoso Mamaduco Dacotata > > papapato@exam" in my online app. I have already cleared my GAE > > datastore once. > > > Thanks again. > > > On Feb 4, 6:10 am, Massimo Di Pierro > > wrote: > > > On Feb 3, 8:27 pm, devGS wrote: > > > > > Hi, I have a few general questions, answers for which I didn't find > > > > in the book: > > > > 1. How does the model work in web2py's MVC? What is the workflow? > > > > When does the code from those files called? The only relevant > > > > information I found was the sequence diagram from the book. > > > > yes this is an important omission. > > > at every http request, all models are executed in the same > > > environment. Then environment is copied. The requested controller is > > > executed and the called function is called. The output dict() is added > > > to the copied environment and passed to the view. The output is > > > returned to the visitor. > > > > > 2. How does the following form of passing arguments in Python work: > > > > cache.ram.clear(regex='...')? I come from Java, as I understand regex > > > > is some kind of an optional value to be passed? > > > > regex is any regular expression. All keys in the cache matching the > > > regular expression are deleted from the cache. > > > > > 3. How do the layouts work (layout as a pattern that is being used in > > > > the views)? I tried to do the following, which sometimes works and > > > > sometimes not, providing errors: remove the {{extend 'layout.html'}} > > > > from some view, i.e. "myview.html" and add {{include "myview.html"}} > > > > into a second view. Mainly, it works, but when I try to remove > > > > {{extend 'layout.html'}} from "default/user.html" and add {{include > > > > 'default/user.html'}} into "index.html", it fails. Why, and how to do > > > > it properly? > > > > Think of a tree. Each node is an HTML file. You move up by calling > > > extend. You move down by calling include. The parent should have a > > > simple {{include}} not {{include "child.html"}} where the extending > > > child is to be inserted. This is in the book in some detail. > > > > > 4. I understood that in order to manipulate my database from GAE, I > > > > need to index my tables. Where can I find information about indexing > > > > and what is it? > > > > You only need this for speed. You have to do this in sql > > > > db.executesql("") > > > > > 5. While uploading my app into GAE, I find the example entries inside > > > > my online GAE app. Why is that and how to prevent it? > > > > I am not sure I understand this question.
Re: [web2py] Re: Few general questions
The model files will be executed in alfabetical order. So there is a difference. Kenneth - Ursprungsmeddelande - > Thanks for your reply. Regarding the first answer: does it mean that > every model from my app will be called on every page refresh? Do the > names of the model files have any effect? I.e. if I rename db.py to > mydb.py, or change "0.py" to something else - what will happen behind > the scene? > > Regarding my third question: the tree structure is something that I > did understand. The problem is an error which makes me think that I do > something wrong. While trying to perform the described above, I the > following traceback: > > Traceback (most recent call last): > File "C:\Users\viu\Desktop\web2py\gluon\restricted.py", line 188, in > restricted > exec ccode in environment > File "C:\Users\viu\Desktop\web2py\applications\Registrar/views > \default/index.html", line 99, in > AttributeError: 'NoneType' object has no attribute 'replace'. > > I have index.html with "include 'default/user.html'". user.html > doesn't have extend. > > > Regarding my last question, I will try to clarify: I found out that > after uploading the app to GAE, the example records are being added to > my app at GAE. I.e. I have: "Sacemoso Mamaduco Dacotata > papapato@exam" in my online app. I have already cleared my GAE > datastore once. > > Thanks again. > > On Feb 4, 6:10 am, Massimo Di Pierro > wrote: > > On Feb 3, 8:27 pm, devGS wrote: > > > > > Hi, I have a few general questions, answers for which I didn't find > > > in the book: > > > 1. How does the model work in web2py's MVC? What is the workflow? > > > When does the code from those files called? The only relevant > > > information I found was the sequence diagram from the book. > > > > yes this is an important omission. > > at every http request, all models are executed in the same > > environment. Then environment is copied. The requested controller is > > executed and the called function is called. The output dict() is added > > to the copied environment and passed to the view. The output is > > returned to the visitor. > > > > > 2. How does the following form of passing arguments in Python work: > > > cache.ram.clear(regex='...')? I come from Java, as I understand regex > > > is some kind of an optional value to be passed? > > > > regex is any regular expression. All keys in the cache matching the > > regular expression are deleted from the cache. > > > > > 3. How do the layouts work (layout as a pattern that is being used in > > > the views)? I tried to do the following, which sometimes works and > > > sometimes not, providing errors: remove the {{extend 'layout.html'}} > > > from some view, i.e. "myview.html" and add {{include "myview.html"}} > > > into a second view. Mainly, it works, but when I try to remove > > > {{extend 'layout.html'}} from "default/user.html" and add {{include > > > 'default/user.html'}} into "index.html", it fails. Why, and how to do > > > it properly? > > > > Think of a tree. Each node is an HTML file. You move up by calling > > extend. You move down by calling include. The parent should have a > > simple {{include}} not {{include "child.html"}} where the extending > > child is to be inserted. This is in the book in some detail. > > > > > 4. I understood that in order to manipulate my database from GAE, I > > > need to index my tables. Where can I find information about indexing > > > and what is it? > > > > You only need this for speed. You have to do this in sql > > > > db.executesql("") > > > > > 5. While uploading my app into GAE, I find the example entries inside > > > my online GAE app. Why is that and how to prevent it? > > > > I am not sure I understand this question.
[web2py] Re: Few general questions
Thanks for your reply. Regarding the first answer: does it mean that every model from my app will be called on every page refresh? Do the names of the model files have any effect? I.e. if I rename db.py to mydb.py, or change "0.py" to something else - what will happen behind the scene? Regarding my third question: the tree structure is something that I did understand. The problem is an error which makes me think that I do something wrong. While trying to perform the described above, I the following traceback: Traceback (most recent call last): File "C:\Users\viu\Desktop\web2py\gluon\restricted.py", line 188, in restricted exec ccode in environment File "C:\Users\viu\Desktop\web2py\applications\Registrar/views \default/index.html", line 99, in AttributeError: 'NoneType' object has no attribute 'replace'. I have index.html with "include 'default/user.html'". user.html doesn't have extend. Regarding my last question, I will try to clarify: I found out that after uploading the app to GAE, the example records are being added to my app at GAE. I.e. I have: "Sacemoso Mamaduco Dacotata papapato@exam" in my online app. I have already cleared my GAE datastore once. Thanks again. On Feb 4, 6:10 am, Massimo Di Pierro wrote: > On Feb 3, 8:27 pm, devGS wrote: > > > Hi, I have a few general questions, answers for which I didn't find in > > the book: > > 1. How does the model work in web2py's MVC? What is the workflow? When > > does the code from those files called? The only relevant information I > > found was the sequence diagram from the book. > > yes this is an important omission. > at every http request, all models are executed in the same > environment. Then environment is copied. The requested controller is > executed and the called function is called. The output dict() is added > to the copied environment and passed to the view. The output is > returned to the visitor. > > > 2. How does the following form of passing arguments in Python work: > > cache.ram.clear(regex='...')? I come from Java, as I understand regex > > is some kind of an optional value to be passed? > > regex is any regular expression. All keys in the cache matching the > regular expression are deleted from the cache. > > > 3. How do the layouts work (layout as a pattern that is being used in > > the views)? I tried to do the following, which sometimes works and > > sometimes not, providing errors: remove the {{extend 'layout.html'}} > > from some view, i.e. "myview.html" and add {{include "myview.html"}} > > into a second view. Mainly, it works, but when I try to remove > > {{extend 'layout.html'}} from "default/user.html" and add {{include > > 'default/user.html'}} into "index.html", it fails. Why, and how to do > > it properly? > > Think of a tree. Each node is an HTML file. You move up by calling > extend. You move down by calling include. The parent should have a > simple {{include}} not {{include "child.html"}} where the extending > child is to be inserted. This is in the book in some detail. > > > 4. I understood that in order to manipulate my database from GAE, I > > need to index my tables. Where can I find information about indexing > > and what is it? > > You only need this for speed. You have to do this in sql > > db.executesql("") > > > 5. While uploading my app into GAE, I find the example entries inside > > my online GAE app. Why is that and how to prevent it? > > I am not sure I understand this question.
[web2py] Re: Few general questions
On Feb 3, 8:27 pm, devGS wrote: > Hi, I have a few general questions, answers for which I didn't find in > the book: > 1. How does the model work in web2py's MVC? What is the workflow? When > does the code from those files called? The only relevant information I > found was the sequence diagram from the book. yes this is an important omission. at every http request, all models are executed in the same environment. Then environment is copied. The requested controller is executed and the called function is called. The output dict() is added to the copied environment and passed to the view. The output is returned to the visitor. > 2. How does the following form of passing arguments in Python work: > cache.ram.clear(regex='...')? I come from Java, as I understand regex > is some kind of an optional value to be passed? regex is any regular expression. All keys in the cache matching the regular expression are deleted from the cache. > 3. How do the layouts work (layout as a pattern that is being used in > the views)? I tried to do the following, which sometimes works and > sometimes not, providing errors: remove the {{extend 'layout.html'}} > from some view, i.e. "myview.html" and add {{include "myview.html"}} > into a second view. Mainly, it works, but when I try to remove > {{extend 'layout.html'}} from "default/user.html" and add {{include > 'default/user.html'}} into "index.html", it fails. Why, and how to do > it properly? Think of a tree. Each node is an HTML file. You move up by calling extend. You move down by calling include. The parent should have a simple {{include}} not {{include "child.html"}} where the extending child is to be inserted. This is in the book in some detail. > 4. I understood that in order to manipulate my database from GAE, I > need to index my tables. Where can I find information about indexing > and what is it? You only need this for speed. You have to do this in sql db.executesql("") > 5. While uploading my app into GAE, I find the example entries inside > my online GAE app. Why is that and how to prevent it? I am not sure I understand this question.