flatpages

4 views
Skip to first unread message

CarlFK

unread,
Apr 29, 2008, 8:36:06 PM4/29/08
to web2py Web Framework
(is 'flatpages' a django term, or a generic term that has a django
implementation?)

I have 10 static html pages. I want to stuff them into web2py. I
will later add a "event schedule" page that will pull from an event
table (date, location, description) (the point of using web2py.)

So what do I do with the 10 static pages? (minimal effort - just
enough to get them hosted. I will worry about abstracting the headers
and other common bits into a site wide template later.)

I don't mind 10 .html files living in the file system. I would
prefer to create a 2 field table: (URL, html) - if someone browses to
the URL, they get the html. This would set the stage for splitting it
into a template and data driven content.

Carl K



mdipierro

unread,
Apr 29, 2008, 9:34:43 PM4/29/08
to web2py Web Framework
I believe 'flatpages' is a Django term but it is easy to do it in
web2py.
Say you have a page called 'test.html'

1) put it into views/default/test.html
2) edit controllers/default.py and add

def test(): return dict()

DONE

you could also simply put them into static/ but the former solution
would allow you to add serverside code later without changing the URL.

Massimo

CarlFK

unread,
Apr 29, 2008, 11:58:23 PM4/29/08
to web2py Web Framework
ok, like this path.

small problem: the files have <a href="foo.htm"> links. I really
don't want to have to dump all the .htm, even if it is a simple 3
line .replace(). I would like to initially keep the htm files
intact. Not that this is a good design, but it is where we are at
now.

Carl K

Massimo Di Pierro

unread,
Apr 30, 2008, 12:08:52 AM4/30/08
to web...@googlegroups.com
under the web2py folder make file called routes.py and in it

routes_in=( ('/$a/$c/$f\.(htm|html|HTM|HTML)':'/$a/$c/$f'), )
routes_out=()

Mind that it is \. instead of . because it is a regex.

Massimo

CarlFK

unread,
Apr 30, 2008, 9:53:43 AM4/30/08
to web2py Web Framework
almost - needed a , between the strings. that problem solved.
thanks.

now to save me some typing; is there a way to map these .html pages
to a common controller, passing the 'file name' in as a parameter, and
using that to load the corresponding .html file.

Carl K


On Apr 29, 11:08 pm, Massimo Di Pierro <mdipie...@cs.depaul.edu>
wrote:

Massimo Di Pierro

unread,
Apr 30, 2008, 11:13:35 AM4/30/08
to web...@googlegroups.com
say you want to call

http://.../app/default/grab/myview.htm

then remove the routes.py file and in default.py do

def grab():
response.view='default/'+args[1]
return dict()

Reply all
Reply to author
Forward
0 new messages