Making my web2py site use a default_application other than welcome on WebFaction.

Here are the steps on webfaction.

  1. $ cd ~/your_path_to_web2py/web2py
  2. $ cp #there is no at first
  3. [edit as follows
        line was: default_application = ‘init’    # ordinarily set in base
        line now: default_application = ‘other’   # ordinarily set in base
  4. $ cd ../apache2/bin
  5. $ ./restart

#app, #default, #web2py

Fixing my "my web2py is unable to create a new application on WebFaction" problem.

Please go here to read a full discussion of the problem. Here is a summary of the steps i took to fix this problem.

  1. Made sure that memory capacity is not a problem.
    1. SSHed into my WebFaction account.
    2. $ ps -u user -o pid,rss,command
      output is: PID, Total memory in bytes, full path of process.
    3. I saw that i was over my memory limit.
    4. Upgraded to get more memory.
    5. Tested to see if that worked. IT DID NOT.
  2. I read this thread.
    1. Made sure that the web2py directory contained a directory named “deposit”.
    2. It did.
    3. Re-tested – NO GOOD.
  3. Opened a WebFaction Ticket.
    1. WebFaction Support suggested that I “…try running the web2py daemon script manually (“python2.5 web2py[.py]”) to initialize those systems”.
    2. Decided i would do that.
  4. Ran web2py from the SSH command line to initialize it.
    1. $ cd ~/path_to_troubled_web2py_instance/web2py/
    2. $ python2.5
      Up came web2py saying:
      web2py Enterprise Web Framework
      Created by Massimo Di Pierro, Copyright 2007-2011
      Version 1.92.1 (2011-02-16 15:04:40)
      Database drivers available: SQLite3, pymysql, PostgreSQL
      Starting hardcron…
      choose a password:
      please visit:
      use “kill -SIGTERM 6744” to shutdown the web2py server
    3. I let it run for a couple of minutes to initialize.
    4. $ kill -SIGTERM 6744  # The number 6744 varies. Use the number mentioned by web2py.
    5. Re-tested by by using IE8 to https login to the associated web2py admin from my windows XP desktop. SUCCESS. I was able to create the “home” app.  


Concatenating web2py HTML Helpers

Say you want to produce something like this list of links dynamically, into an HTML page, from a web2py controller:

Here is what you would put into your controller to concatenate (append) HTML Helpers:
def index():
    page_info = DIV(
                A(‘NOAA Weather’, _href=’’), BR(),
                A(‘Google Mobile’, _href=’’), BR(),
                A(‘Twitter Mobile’, _href=’’)
    return dict(page_info=page_info)
Here is what would go into your associated view:
{{extend ‘layout.html’}}
Here’s the reason. Lot’s of HTML helpers are derived from the DIV helper. According to the web2py epydocs at line 523, DIV
"Behaves like a dictionary regarding updating of attributes. 
Behaves like a list regarding inserting/appending components."

#html-helpers, #web2py

Fixed Javascript – 3

This text is bold
This text is strong
This text is big
This text is emphasized
This text is italic
This text is small
This is subscript and superscript

this is first

var money2=’Javascript: $1,000,000.00

function writeJSo2(){
var p = document.getElementById(‘joejso2’);
p.innerHTML = money2;

#javascript, #python, #remote-post

Fixed Javascript – 2

This text is bold
This text is strong
This text is big
This text is emphasized
This text is italic
This text is small
This is subscript and superscript

this is first

var money1=’Javascript: $1,000,000.00

function writeJSo1(){
var p = document.getElementById(‘joejso1’);
p.innerHTML = money1;

#javascript, #python, #remote-post

Fixed Javascript – 1

This text is bold
This text is strong
This text is big
This text is emphasized
This text is italic
This text is small
This is subscript and superscript

this is first

var money0=’Javascript: $1,000,000.00

function writeJSo0(){
var p = document.getElementById(‘joejso0’);
p.innerHTML = money0;

#javascript, #python, #remote-post

Javascript in posts on Blogger’s Home View

If you use javascript to alter a document element on a post, that post may not appear the same in the Blog Home View.

Look at the posts BELOW THIS ONE in my Blog home view at Notice that the last item in the post for Friday, February 18, 2011 at 3:25 PM says: “Javascript: $1,000,000.00”. While the last items for the posts at [3:23 PM, 3:18 PM, 1:20 PM, and 1:03 PM] read “this is first”. Note that as these posts slip farther into “Older Posts“, it will be the first post on that HTML page that says “Javascript: $1,000,000.00”.

Click on any of the “this is first” posts, to go to the post page itself. Notice that the last item on the post page does NOT read “this is first”. Instead it reads “Javascript: $1,000,000.00”. What’s going on here?

Here’s what’s going on. When you publish a post, it gets its own html page. Then that page gets rolled up into the Blog Home View, which is itself a page with one single element. All the other post pages get stripped of their , , , etc. elements and get put under a

element with, as noted, a unique id number. Look for yourself by viewing the Page Source of my Blog Home View.

Notice that there are several

elements in the Page Source. THAT’S A PROBLEM. The id attribute for should be unique. (Not the same for the class attribute.) The javascript changes just the first one it encounters. So that’s the reason for the behaviour we see.

Fixing this problem requires us to make a unique id for each paragraph to be altered by javascript, in each post.

There’s another problem that exists. There are many instances of the same javascript function named writeJSo in the Blog Home View. This is because each of the individual posts, contained that function. Initially, we’ll solve this problem in a brute force, similar manner to the above. We’ll give each instance of writeJso a unique name, and make it refer to the unique paragraph id in each post.

Note that when I wrote writeJSo immediately followed by ‘()’ parentheses, the function RAN in THIS POST, while I was using Compose with Post Options [Use
tags, Show HTML literally]. Somehow a div with an id of joejso was inserted into this post, I guess when I was editing HTML directly. VERY STRANGE. 🙂

We can see the result of these changes by inspecting the 3 posts that appear ABOVE THIS ONE in my Blog Home View. PLEASE NOTE if you were using IE when I first published these posts, you didn’t see “Javascript: $1,000,000.00” in any posts below this because I used  which IE does NOT recognize. I have since changed the element to .

#javascript, #python, #remote-post