[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
 - FSPageTemplate at /plinkit/sinList used for /plinkit/interestsideas/headlines
 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_: PythonExpr here.toPortalTime(obj['date'])
 - Names:
 {'container': PloneSite instance at b5c87740,
 'context': PloneFolder instance at b2d87d40,
 'default': Products.PageTemplates.TALES.Default instance at 0xb69758cc,
 'here': PloneFolder instance at b2d87d40,
 'loop': SafeMapping instance at b2b685d0,
 'modules': Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0xb696ed8c,
 'nothing': None,
 'options': {'args': ()},
 'repeat': SafeMapping instance at b2b685d0,
 'request': HTTPRequest, URL="" href="http://demo.plinkit.org/interestsideas/headlines/sinList">http://demo.plinkit.org/interestsideas/headlines/sinList,
 'root': Application instance at b5c87710,
 'template': FSPageTemplate at /plinkit/sinList used for /plinkit/interestsideas/headlines,
 '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
 - FSPythonScript at /plinkit/toPortalTime used for /plinkit/interestsideas/headlines
 - 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
 - FSPythonScript at /plinkit/toLocalizedTime used for /plinkit/interestsideas/headlines
 - 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: 

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 rss version=0.91
channel
titleLibraryLookup reminders/title
linkhttp://www.amazon.com/link
descriptionRemind me when books on my Amazon wishlist become
available at the library/description
%s
/channel
/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
title%s/title
link%s/link
description%s/description
/item\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:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en-US
  lang=en-US
  metal:use-macro=here/main_template/macros/master
  i18n:domain=plone

  metal:block fill-slot=base
tal:block tal:define=dummy python:request.set('disable_border',
1)
   tal:replace=nothing
Disable the tabs
/tal:block
  /metal:block

  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=mTitle or id/h1
/div

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
dta 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
ddspan tal:condition=python: verbose and
obj.get('description') or nothing tal:replace=structure
obj/description/nbsp;
/dd
/dl

!-- Navigation --
div metal:use-macro=here/batch_macros/macros/navigation /
/tal:block
p tal:condition=not: results
i18n:translate=description_no_items_in_feed
   There are currently no items in this feed.
/p
/div
/html




-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

[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 )