views:

40

answers:

1

Hi,

I'm building a small web app with Python on GAE.

I have an HTML form with a where users enter a list of items (one item per line). When the form is submitted I want to read each line and store separate entries in the datastore for each item (i.e. line).

I want to do something similar to f.readline() for files, but on the form submission. It's entirely possible that this is incredibly easy. I'm a complete noob so any help you be greatly appreciated.

+1  A: 

Sounds like you want (have?) a text area control in your form, like the one I'm typing into now. Something like this?

<textarea name="items"></textarea>

When handling the POST request for the form, you will be able to get the value of the text area like so.

itemList = self.request.get("items")

It will post back the entire text with newline characters (with the escape code \n). The text can be split into a list of lines.

items = itemList.split("\n")

Aaaand you have a list of lines.

tarn
items = itemList.split("\n") <-- Yes, that's what I was looking for! Thanks!
August Flanagan