OK, let me see if I can do that...

I've already figured out that a python script/external method solution
is what I'm after. But how to make it work?

Anyone know about Greasemonkey in Firefox? Basically, it embeds a handy
link in Web pages that have ISBN numbers in them (unique identifier for
a book). When you configure Greasemonkey right, it checks for the book
in your local catalog and returns a link to that book in your local
library catalog. The trick is to use the same idea, but inside of Plone
with an RSS feed that displays current bestsellers or other book-related
stuff where there's an ISBN included.

Here's the sort of python script I need, to the best of my knowledge,
though the first function I can't use (it checks against an Amazon
Wishlist--I don't want anything to be dependent on Amazon or a
particular browser). Jon Udell provided it, and he's the one who wrote
the LibraryLookup bookmarklet that does something similar to what I

import amazon, re, urllib2

wishes = amazon.searchByWishlist('BNQ1T3SLPJS7');

def rss( items ):
 return """<rss version="0.91">
<title>LibraryLookup reminders</title>
<description>Remind me when books on my Amazon wishlist become
available at the library</description>
</rss> """ % items

def isAvailable ( isbn ):
 url = 'http://ksclib.keene.edu/search/i=%s' % isbn
 page = urllib2.urlopen(url).read()
 return re.search ( 'AVAILABLE', page ) is not None

items = ''

for wish in wishes:
 isbn = wish.Asin
 if (  ( re.match( '\d{7,9}[\d|X]', isbn ) is not None) and
isAvailable(isbn) ):
   items += """
</item>\n  """ %  ( wish.ProductName, wish.URL, wish.Authors.Author )

output = rss ( items )

name = 'libraryReminders.xml'

f = open(name,'w')
So, I need to simplify this script (get rid of the wishlist stuff),
create an external method for it, then figure out how to get the
template in CMFSin to call the external method. I've never done any of
this before (which probably explains why I have a hard time describing
my problem better).

The CMFSin template I need to alter looks like this, and I'm not sure
exactly where or how to call the method:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en-US"

  <metal:block fill-slot="base">
    <tal:block tal:define="dummy python:request.set('disable_border',
    Disable the tabs

  <div metal:fill-slot="main"
       tal:define="true python: 1;
                   false python: 0;
                   verbose python: 1;
                   sin here/sin_tool;
                   m request/synmap;
                   results python:sin.sin(m);
                   Batch python:modules['Products.CMFPlone'].Batch;
                   b_start python:request.get('b_start',0);

        <div class="contentHeader">
        <h1 tal:content="m">Title or id</h1>

        <tal:block tal:define="batch python:Batch(results, 15,
int(b_start), orphan=1)">

        <!-- Navigation -->
        <div metal:use-macro="here/batch_macros/macros/navigation" />

        <dl tal:repeat="obj batch">
                <dt><a href="#"  tal:attributes="href obj/link"
tal:content="structure obj/title"/>&nbsp; <span tal:condition="python:
obj.get('date') or nothing" tal:content="python: (obj['date'])"/></dt>
                <dd><span tal:condition="python: verbose and
obj.get('description') or nothing" tal:replace="structure

        <!-- Navigation -->
        <div metal:use-macro="here/batch_macros/macros/navigation" />
        <p tal:condition="not: results"
           There are currently no items in this feed.

-----Original Message-----
From: Chris Withers [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 04, 2005 6:12 AM
Cc: zope@zope.org
Subject: Re: [Zope] RSS feed: post-processing?

Sorry Eva,

You'll need to explain your problem more succintly for people to be able

to help. If you really do need to scrape the urls from the text, then a 
combination of python's xml handling and regular expressions is probably

what you're after, best done in an external method and not a python 



MILLER Eva wrote:

> Hello,
> I've been puzzling over something but can't figure out a solution. I
> have an RSS feed providing the content behind all the links on this  
> page: http://demo.plinkit.org/interestsideas/goodreads/booklists.
> There's a nice bookmarklet tool in the world called LibraryLookup that
> lets you check whether a book you find on Amazon or something is in  
> your library's catalog by scraping up the ISBN and launching an ISBN  
> catalog search. It's a javascript, really. I thought I would adapt
> to create a little add-on for the stuff the bestsellers RSS brings 
> back
> to my site. What I need to do is pluck out the ISBNs in the links on a
> page like this one:  
> rFiction
> The ISBNs are all in the URLs for the book titles
> ("isbn=Some10digitNumberHere"). How would I look for a piece of text
> that shape, i.e., isbn=5893193390, then, if it's there, copy and paste
> that piece of information into the LibraryLookup javascript I have.
> end result should be that, if there's an ISBN in a feed result, an 
> extra link
> appears for each entry that says something like "Check the catalog,"  
> which you can click to look that book up in your own library's
> I've been staring at the template that formats the RSS feed to figure
> out whether any TAL expression would work for this. I've been playing

> with a short Python script, then wondering how to call it within that

> template, but I think I have to use regular expressions to do it.
> I'm sorry to be so lost on this, but I guess I am. I'd love to do
> something cool like this for our little Plinkit libraries. Can anyone

> help? I'll take anything from a broad strategy to actual code snippets

> (I'm a terrible programmer but a good librarian).
> Thanks
> Eva the Librarian
> ----------------------------------------------------------------------
> --
> _______________________________________________
> Zope maillist  -  Zope@zope.org 
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )

Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to