[web2py] Re: How to use a text file instead of a db?

2013-02-12 Thread Alan Etkin
> I have a file. 
> I want to read in the contents.

In what format? (how the controller will read/parse the data). Is it JSON, 
XML, HTML, MARKMIN, text, RTF, YAML, CSV, JPEG ...?

> I want to display those contents when a page is visited. 

What does it contain? Is it an image, text, multimedia, ... You ought to 
tell the browser what content you are using.
Do you want to guess automatically what's in the file (and handle the 
contents accordingly)? Will you need pagination?

If you plan to store documents as files, I think you could use the built-in 
MARKMIN engine. It is very powerful and easy to use.

-- 

--- 
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 use a text file instead of a db?

2013-02-11 Thread Rufus

And if you don't need the layout (by returning a dict), just return the 
file contents:

def showfile():
 return (open("filename.ext","r").read())



-- 

--- 
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 use a text file instead of a db?

2013-02-11 Thread Niphlod
ehm
put the file somewhere reachable by your app. Let's say you put a file 
"hello.txt" into the private/ folder.

import os
def myfunction():
filepath = os.path.join(request.folder, "private", "hello.txt")
with open(filepath) as g:
content = g.read()
return dict(content=content)



On Monday, February 11, 2013 9:54:34 PM UTC+1, rh wrote:
>
> On Mon, 11 Feb 2013 11:33:56 -0800 (PST) 
> Niphlod > wrote: 
>
> > open the file, read it and do what you need to do. your question 
> > leaves a lot of holes about what you're trying to do. 
>
> Not sure what you mean about holes, I did find an example right under 
> my nose in the admin app. 
>
> I have a file. 
> I want to read in the contents. 
> I want to display those contents when a page is visited. 
>
> What more can I say about that? 
>
> > 
> > On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote: 
> > > 
> > > I have a text file and want to generate a page using that file's 
> > > contents instead of querying a db. 
> > > 
> > > I have looked at all the web2py-appliances but could not find an 
> > > example. 
> > > 
> > > I create the text file, so I can make it any format. 
> > > 
> > > 
> > 
> > -- 
> > 
> > --- 
> > 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 
> > +unsub...@googlegroups.com . For 
> > more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
> -- 
>
>
>

-- 

--- 
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 use a text file instead of a db?

2013-02-11 Thread Derek
put it in /static and access it by name.


On Monday, February 11, 2013 1:54:34 PM UTC-7, rh wrote:
>
> On Mon, 11 Feb 2013 11:33:56 -0800 (PST) 
> Niphlod > wrote: 
>
> > open the file, read it and do what you need to do. your question 
> > leaves a lot of holes about what you're trying to do. 
>
> Not sure what you mean about holes, I did find an example right under 
> my nose in the admin app. 
>
> I have a file. 
> I want to read in the contents. 
> I want to display those contents when a page is visited. 
>
> What more can I say about that? 
>
> > 
> > On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote: 
> > > 
> > > I have a text file and want to generate a page using that file's 
> > > contents instead of querying a db. 
> > > 
> > > I have looked at all the web2py-appliances but could not find an 
> > > example. 
> > > 
> > > I create the text file, so I can make it any format. 
> > > 
> > > 
> > 
> > -- 
> > 
> > --- 
> > 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 
> > +unsub...@googlegroups.com . For 
> > more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
> -- 
>
>
>

-- 

--- 
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 use a text file instead of a db?

2013-02-11 Thread Niphlod
open the file, read it and do what you need to do. your question leaves 
a lot of holes about what you're trying to do.

On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote:
>
> I have a text file and want to generate a page using that file's contents 
> instead of querying a db. 
>
> I have looked at all the web2py-appliances but could not find an example. 
>
> I create the text file, so I can make it any format. 
>
>

-- 

--- 
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.