RE: [Zope] RSS feed: post-processing?

2005-04-05 Thread MILLER Eva
Hi,

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
want:

import amazon, re, urllib2

wishes = amazon.searchByWishlist('BNQ1T3SLPJS7');

def rss( items ):
 return """

LibraryLookup reminders
http://www.amazon.com
Remind me when books on my Amazon wishlist become
available at the library
%s

 """ % 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 += """

%s
%s
%s
\n  """ %  ( wish.ProductName, wish.URL, wish.Authors.Author )

output = rss ( items )

name = 'libraryReminders.xml'

f = open(name,'w')
f.write(output)
f.close()

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:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en-US"
  lang="en-US"
  metal:use-macro="here/main_template/macros/master"
  i18n:domain="plone">

  

Disable the tabs

  

  


Title or id








  
 

    

    



   There are currently no items in this feed.







-Original Message-
From: Chris Withers [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 04, 2005 6:12 AM
To: MILLER Eva
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 
script...

cheers,

Chris

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
this
> 
> 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:  
>
http://demo.plinkit.org/interestsideas/goodreads/sinList?synmap=Hardcove
> rFiction
> 
> The ISBNs are all in the URLs for the book titles
> ("isbn=Some10digitNumberHere"). How would I look for a piece of text
in
> 
> that shape, i.e., isbn=5893193390, then, if it's there, copy and paste
> that piece of information into the LibraryLookup javascript I have.
The
> 
> 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
catalog.
> 
> I've been staring at the template that formats the RSS feed to figure
> 

[Zope] CMFSin time errors

2005-04-05 Thread MILLER Eva
Title: CMFSin time errors






Hi,


I'm getting some errors with certain feeds, but not others, in CMFSin. The errors seem to have something to do with the portaltime and localized time. Someone suggested changing the permissions for anonymous to fix this. Doing that made all my feeds malfunction, so that's not the right answer.

I know CMFSin is old and it seems to be getting flaky. But I really need an aggregator for my project, and it doesn't seem like there's anything much better out there right now.

Here's what happens when I use a feed from National Public Radio (http://www.npr.org/rss/rss.php?topicId=3). I know the feed is working. CMFSin's debug panel shows the results of the feed very plainly. The problem is in the display of the feed (which is either Zope or Plone's fault, though I can't tell which right now):

Traceback (innermost last):
  Module ZPublisher.Publish, line 101, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Shared.DC.Scripts.Bindings, line 306, in __call__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 191, in _exec
  Module Products.CMFCore.FSPageTemplate, line 124, in pt_render
  Module Products.PageTemplates.PageTemplate, line 96, in pt_render
   - 
  Module TAL.TALInterpreter, line 190, in __call__
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 671, in do_useMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 702, in do_defineSlot
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 650, in do_defineMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 694, in do_defineSlot
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 613, in do_loop_tal
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 637, in do_condition
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 484, in do_insertText_tal
  Module Products.PageTemplates.TALES, line 227, in evaluateText
  Module Products.PageTemplates.TALES, line 221, in evaluate
   - Line 35, Column 92
   - _expression_: 
   - Names:
  {'container': ,
   'context': ,
   'default': ,
   'here': ,
   'loop': ,
   'modules': ,
   'nothing': None,
   'options': {'args': ()},
   'repeat': ,
   'request': http://demo.plinkit.org/interestsideas/headlines/sinList>,
   'root': ,
   'template': ,
   'traverse_subpath': [],
   'user': Anonymous User}
  Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
   - __traceback_info__: here.toPortalTime(obj['date'])
  Module Python _expression_ "here.toPortalTime(obj['date'])", line 1, in <_expression_>
  Module Products.CMFCore.FSPythonScript, line 104, in __call__
  Module Shared.DC.Scripts.Bindings, line 306, in __call__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 160, in _exec
  Module None, line 5, in toPortalTime
   - 
   - Line 5
  Module Products.CMFCore.FSPythonScript, line 104, in __call__
  Module Shared.DC.Scripts.Bindings, line 306, in __call__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 160, in _exec
  Module None, line 4, in toLocalizedTime
   - 
   - Line 4
  Module Products.CMFPlone.PloneUtilities, line 118, in localized_time
  Module DateTime.DateTime, line 522, in __init__
  Module DateTime.DateTime, line 745, in _parse_args
  Module DateTime.DateTime, line 1032, in _parse
SyntaxError: Tue, 05 Apr 2005 14:21:06 EDT


Thanks,

Eva Miller, 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 )


[Zope] RSS feed: post-processing?

2005-04-01 Thread MILLER Eva
Title: RSS feed: post-processing?






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 this  

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:  

http://demo.plinkit.org/interestsideas/goodreads/sinList?synmap=HardcoverFiction


The ISBNs are all in the URLs for the book titles  

("isbn=Some10digitNumberHere"). How would I look for a piece of text in  

that shape, i.e., isbn=5893193390, then, if it's there, copy and paste  

that piece of information into the LibraryLookup _javascript_ I have. The  

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


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 )