On 10/13/06, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Jon Rosebaugh wrote:
> > On 10/12/06, [EMAIL PROTECTED]
> > <[EMAIL PROTECTED]> wrote:
> > > Hi, I'm new to python and I am trying to implement a website which
> > > parses newsgroups for cooking recipes.
> >
> > My recommendation would be to write a separate script (not directly
> > using Pylons) that parses the newsgroups and adds the recipes to the
> > database. You could then have this script running in a cronjob, and
> > the Pylons app could handle reading the recipes from the database.
>
> Ok, that is a solution for me.
>
> I'd like to use the pylons framework for this task, especially the
> model, in order to avoid code duplication (that is the reason
> why I implemented the task by a controller).
>
> So, how do I have to proceed ?

Figure out how to make a script that (a) imports the model from your
pylons app (usually 'import myapp.models' should work) and (b)
connects to the database (I suggest using paste.deploy.appconfig to
parse the ini file and get the connection info)

Once you have that, you just have to loop over the newsgroup postings,
parse them, and store the parsed recipes in the database. The task of
determining which newsgroup postings should be parsed each run is
something you'll have to figure out for yourself.

You should be able to just put that in a cronjob, then.

My script (which was actually sending emails based on a table in the
db) works like this:

filename = "/Users/jon/code/myapp/development.ini"
app_conf = appconfig('config:'+filename)
meta.connect(app_conf['dsn'])
emaillist = objectstore.query(Email).select(limit=5)
for email in emaillist:
    # actually send the email
    # then mark the email as sent in the DB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to