Personal tools
You are here: Home Members kedai's Home KebasData and Plone
« June 2018 »
Sun Mon Tue Wed Thu Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Log in


Forgot your password?
Plug
Who - kedai (a) kedai . com . my
Where - Malaysia
What - we do zope/plone, linux solution for network, vpn, mail, etc
 
Document Actions

KebasData and Plone

by kedai last modified Dec. 16, 03 02:23 PM

i've had this idea in my head since forever. it's now time to put ideas to actions. It seems only natural to use KebasData as plone slots, so that stuff from somewhere else can be used as though it's part of the plone site.

i'll expand on the current howto. It's easy enough, methinks.

but before that, i've redone the test page for KebasData that grabs userfriendly and zope news. i haven't yet done the google example. The page is here.

Let's try and turn our Zope News to a slot for our plone site.

Note: These assumes that all these objects are at portal_skins/custom
To use folder at plone root, some modification need to be made.
The code for the KebasData instance should be something like this:

title:
url: http://www.zope.org/
pattern: <a href="(.*?)">(.*?)</a>
start pattern: newsitem_icon.gif
end pattern: div class="box"
render method: sc_zn
proxy:
refresh: 7200
request method:
 *GET POST 

Then, we create the render method. In this example, we'll be using a Script (Python) as the render method.

###id sc_zn
###parameter list: q, b
for k,v in context.match:
  print '<a href="%s">%s</a><br />' % (k,v)
return printed

We now copy any of the plone slots:

#id: zn_slot
<span metal:define-macro="znBox"
       class="box"
       summary="Links" cellpadding="0" cellspacing="0"
       i18n:domain="plone"
       >

    <div class="box">

    <h5 i18n:translate="links_title">Links</h5>
    
    <div class="body">
        <div class="content">

	<x tal:replace="structure here/zn" />
    </div>        
    </div>
    </div>
</span>

Now, we go to Plone > Properties, and put in the slots. for eg, we'll put this for the left slot:

here/zn_slot/macros/znBox

That's it. we now have Zope News slot for our plone page. Now, the challenge is what happens if zope.org is unreachable? i think putting in a try/except in the sc_zn would help. We'll see :)

This example is now part of my-zope.org (see the left slot). if nothing goes wrong, it'll be a permanent feature to my-zope.org

I hope to put up a repository for all usable KebasData recipes that can be used as plone slot. got one? mail me the kebasdata instance pattern/url, the render method and the slots source and i'll put it up. I'll start with the zope news.

Zope News Problem

Posted by sdownie at Dec. 15, 03 10:48 PM

When I set up a KebasData instance following your Zope News example, I get this error message when I try to initialize:
-----
Kebas Data not initialized. Message returned by target server: Moved Temporarily (2003-12-15 09:12)
-----
I've tried both http://www.zope.org and http://zope.org, but each time I get the same result.

Plone Error for Zope News

Posted by sdownie at Dec. 15, 03 11:13 PM

Ultimately, if I apply your instructions to a stock installation of Plone 1.0.5 (Win 2K Pro), here is the error message I see when I try to visit the home Plone page.
-----

AttributeError

Sorry, a site error occurred.

Traceback (innermost last):

Module ZPublisher.Publish, line 150, in publish_module Module Products.Localizer, line 58, in new_publish Module ZPublisher.Publish, line 114, in publish Module Zope.App.startup, line 182, in zpublisher_exception_hook Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Products.CMFCore.PortalContent, line 117, in __call__ Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec Module Products.CMFCore.FSPageTemplate, line 169, in _exec Module Products.PageTemplates.ZopePageTemplate, line 228, in _exec Module Products.CMFCore.FSPageTemplate, line 141, in pt_render Module Products.PageTemplates.PageTemplate, line 95, in pt_render Module TAL.TALInterpreter, line 200, in __call__ Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 703, in do_useMacro Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 682, in do_defineMacro Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 669, in do_condition Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 636, in do_loop_tal Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 414, in do_optTag_tal Module TAL.TALInterpreter, line 399, in do_optTag Module TAL.TALInterpreter, line 394, in no_tag Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 669, in do_condition Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 414, in do_optTag_tal Module TAL.TALInterpreter, line 399, in do_optTag Module TAL.TALInterpreter, line 394, in no_tag Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 703, in do_useMacro Module TAL.TALInterpreter, line 244, in interpret Module TAL.TALInterpreter, line 592, in do_insertStructure_tal Module Products.PageTemplates.TALES, line 217, in evaluate URL: /Plone/zn_slot Line 15, Column 1 Expression: standard:here/zn Names: {'container': , 'default': , 'here': , 'loop': , 'modules': , 'nothing': None, 'options': {'args': ()}, 'repeat': , 'request': , 'root': , 'template': , 'traverse_subpath': [], 'user': admin} Module Products.PageTemplates.Expressions, line 206, in __call__ Module Products.PageTemplates.Expressions, line 194, in _eval Module Products.PageTemplates.Expressions, line 150, in _eval __traceback_info__: here Module Products.PageTemplates.Expressions, line 360, in restrictedTraverse __traceback_info__: {'path': ['zn'], 'TraversalRequestNameStack': []} AttributeError: zn (Also, an error occurred while attempting to render the standard error message.)

i think i see the problem

Posted by Anonymous User at Dec. 16, 03 02:18 PM

i put all these stuff in the portal_skins/custom folder

i didn't test this setup at the plone root folder

Almost there!

Posted by sdownie at Dec. 16, 03 10:56 PM

Putting these files in the custom folder helped. Here are the problems I've encountered with this example so far.

  • The name of the KebasData instance is not specified. I named mine "zopenews".
  • Zope.org returns a "temporarily moved" error when you try to connect to it through Kebas. I changed the URL to "http://www.plone.org".
  • You need to make sure that "q, b" is entered in the Parameter List box on the Script editing page. Putting "q, b" in with the rest of the Python code doesn't work. This may be obvious to Python veterans, but it was something a Python newbie such as myself had to figure out.
  • The "zn_slot" code doesn't work. The line
    < x tal:replace="structure here/zn" /> is wrong because you haven't defined any "zn" to date. When I replaced "zn" with "zopenews" and clicked the Test tab, this is what I got back in the section where the Kebas data should be:
    -----
    ...
        <div class="body">
            <div class="content">

    <KebasData instance at 01A6A440> </div> ...

  • When I create the Plone slot and view the front page, the "Links" slot is empty.

At this point, I can see the links that Kebas has captured when I click the View tab in my "zopenews" KebasData instance. But those links are not being relayed to Plone.

Any ideas?

Thanks!

okie .. here's where i think the problem is ..

Posted by kedai at Dec. 17, 03 12:19 AM

my bad. i assumed that zn is the kebas instance id. i'll be more explicit next time. same thing with the parameter list.

if you have a temporary moved, it's because apache redirects from http://www.zope.org to http://www.zope.org/
notice the last /

it's the natural behavior by most web servers, iirc. if the last path is a directory, the web server will give a 302 and puts the last /.

so, in the url, make sure the last / is there.

now, the slot. if the kebas id is zn, it should then work ;). in your case, the method is not called, causing zope to blurt out the instance stuff. if i'm right, you might be using a kebasdata version that doesn't have the __call__ method. iirc, version 0.8.1 should have that. if not, i'll put out a 0.8.2 up.

to work around this, use <x tal:replace="structure python:here.zn.view()" /> instead of the one listed above. also, replace zn with your keasdata id.

hth

It works!

Posted by sdownie at Dec. 17, 03 03:33 AM

This line fixed my problem:
<x tal:replace="structure python:here.zn.view()" />

The slash at the end of the www.zope.org URL didn't make any difference. I can't contact Zope either way. I can contact the Plone site, so I'm using that as my example. If you are running Apache in front of your Zope installation, that might be a configuration issue on your end.

I have a request. It would be cool if you could route the links captured by Kebas into another Plone slot. For example, if I clicked a link in my Plone News slot (which was created by Kebas), the output from that link would end up in the center slot. That would allow me to manipulate external content while maintaining my basic Plone navigation. I'm sure it wouldn't be easy to do, but you were asking for requests!
:-)

Thanks!

if i understood what you're saying ...

Posted by kedai at Dec. 17, 03 08:15 PM

it surely can be done.. but the legal implication is unknown.

Trying to make the UserFriendly example into a Plone slot

Posted by sdownie at Dec. 15, 03 11:58 PM

I haven't had any luck with trying to turn your UserFriendly example into a Plone slot.
I created a folder named "demo" inside my Plone folder. Inside "demo," I added a userfriendly Kebas instance, following your instructions. The userfriendly Kebas piece successfully grabs the strip from the external site. I have two items in my "demo" folder: userfriendly (the Kebas instance) and userfriendly_method (the DTML method you suggest). [I tried using your Python script as the userfriendly_method, but Zope rejected the Python script.]
In the Plone > portal_skins > custom folder, I created a "userfriendly_slot" DTML Document. That document contains the following code:

<dtml-var standard_html_header>
<dtml-var "userfriendly.view()">
<dtml-var standard_html_footer>

When I try to view that DTML Document, I get the following Zope error:
NameError

Sorry, a site error occurred.

Traceback (innermost last):

Module ZPublisher.Publish, line 150, in publish_module Module Products.Localizer, line 58, in new_publish Module ZPublisher.Publish, line 114, in publish Module Zope.App.startup, line 182, in zpublisher_exception_hook Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module OFS.DTMLDocument, line 131, in __call__ Module DocumentTemplate.DT_String, line 474, in __call__ Module DocumentTemplate.DT_Util, line 201, in eval __traceback_info__: userfriendly Module , line 2, in f NameError: global name userfriendly is not defined (Also, an error occurred while attempting to render the standard error message.)


Why is "userfriendly" not globally defined?
Thanks!

Google Example Problems

Posted by sdownie at Dec. 18, 03 05:34 AM

I'm going through the Google example again, but there are some problems.

  • You forgot to include the Google URL that you think Kebas should use. I assume that is "http://www.google.com".
  • If you intend to use the Google home page, the pattern (from what I can tell of the current Google home page) should be about <b>(.?)</b>|<p>(.?) - <a href="/search
  • When I try to initialize the Kebas instance (with "http://www.google.com" as the url), I get this error:
    Kebas Data not initialized. No match found. Check your regex pattern ,URL or proxy setting (2003-12-17 15:53)

  • If I reduce the pattern string to <a href="/search, Kebas will initialize. If I then click the View tab, Zope will display "Not Found".
  • If, at this point, I view the "srch" method, Plone will return this error:
    Error Type 
    KeyError
    Error Value 
    srcid
    

  • If I test the "t" Python script, I get this error:
    Error Type 
    NameError
    Error Value 
    global name srcid is not defined
    

  • What do I need to do to get Google running?

    Thanks!

google trouble

Posted by kedai at Dec. 18, 03 09:33 AM

google changed a lot since the first howto :P

i haven't yet worked on a working example for current google setup. the only thing that needs looking into is the pattern itself.


Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: