Re: [Zope] Context in a view doesn't see marker interface

2008-06-24 Thread Eric Steele

On Jun 20, 2008, at 6:27 AM, Chris Withers wrote:


Eric Steele wrote:
If I include something along the lines of tal:replace="structure context" /> in my view template, someObject  
renders in the browser. The problem is that none of what's in there  
appears to recognize the interface that my view provides.


It's not at all clear what you mean here or what the problem is that  
you're trying to describe.


How about a concrete, minimal example?

> (I also had some success creating a page template on the fly,  
injecting
> the current content object's template code into it along with  
whatever
> else I wanted to display, but that just feels icky and runs afoul  
of the


"feels icky" is an understatement. How about woefully inefficient,  
not to mention insane? You could probably make it a bit worse by  
getting the template code from the request if you really tried  
hard ;-)


Oh, come now. That's just silly...

But really, the only reason I mentioned it was in hopes of goading  
someone into taking action against it. :-P


Ok, a better example... I'm going to start with Plone since that's  
what this is eventually geared towards.


My hoped-for goal is this...If I view the front page of the site  
normally (http://localhost:8080/site/front-page), I'll see it rendered  
with normally. If I view it through my browser view (http://localhost:8080/site/front-page/@@viewletmanagertest 
), it'll render the same bit of content (front-page), but using the  
render method of the viewletmanagers I've adapted to the  
IViewletManagerTestView that my view provides.


So in a stripped down example...

I'd define my interface, view and new viewletmanager:

class IViewletManagerTestView(Interface):
pass

class ViewletManagerTestView(BrowserView):
implements(IViewletManagerTestView)
template = ViewPageTemplateFile('viewletmanagertest.pt')

def __init__(self, context, request):
self.context = context
self.request = request

def __call__(self):
return self.template(self.context, self.request)

class OverridingViewletManager(ViewletManagerBase):
implements(IViewletManager)
def render(self):
return "It worked!"

Register my adapters locally:

  
factory="myapp.browser.viewletmanagertest.OverridingViewletManager"

 for_="zope.interface.Interface
   zope.publisher.interfaces.browser.IBrowserRequest

myapp.browser.viewletmanagertest.IViewletManagerTestView"

 provides="plone.app.layout.viewlets.interfaces.IPortalFooter"/>

and create a template that shows
1) a call to a viewletmanager to make sure the adaptation is working  
at all

2) the content object that the view is called on

Footer:


Content object in context:


So now when I call that view (http://localhost:8080/site/front-page/@@viewletmanagertest 
), I should see Footer: It worked! and then the content object  
rendered with "It worked" in place of the portalfooter viewletmanager.  
Instead, I just see the Footer: It worked! and then the content object  
rendered normally.


The adaptation is working for the view, otherwise that first "it  
worked!" wouldn't show up. The problem lies in calling the content  
object through that  bit.  
If I place the page template's code directly into my view template,  
everything works perfectly.


I hope that's at least somewhat of a better explanation of what I'm  
after.


Eric
___
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] Re: help debugging a "can't pickle" error deep within a catalog reindex

2008-06-24 Thread Rob Miller

Rob Miller wrote:

hi,

i'm trying to perform a ZCatalog.refreshCatalog() on a catalog with over 
29,000 indexed objects.  it churns for a good long time, and eventually 
fails with a long set of tracebacks, of which i've included a sample at 
the end of this message.


i think i understand the gist of the issue... it's trying to write an 
object (probably a CatalogBrain) to the database, but this object's 
__dict__ contains a value that is of type instancemethod, which isn't 
allowed for persistent objects.


the problem is that i can't figure out which specific objects are 
causing the problem.  i've used pdb.post_mortem to get a debug prompt 
way down in the traceback, but the code goes in and out of C modules, so 
i'm missing a lot of what's happening.  and when i interactively peek at 
the objects that are being indexed when the error happens, there doesn't 
seem to be anything wrong, and i can index the objects w/ no problem.  
i've even tried dropping the subtransaction threshold down to 1, so it 
will try to commit a savepoint after every object, but none of the 
objects being indexed seemed to have any problems.


okay, after leaving this for a few days, i came back to it and managed to work 
it out.  for posterity's sake, what ended up working was that i added an 
explicit transaction.commit() after every object reindex, wrapped in a try: 
except, like so:


--- src/Zope/lib/python/Products/ZCatalog/ZCatalog.py   2007-10-29 
06:09:30.0 -0700
+++ lib/zope/lib/python/Products/ZCatalog/ZCatalog.py   2008-06-24 
10:47:49.0 -0700

@@ -294,6 +294,11 @@
 if obj is not None:
 try:
 self.catalog_object(obj, p, pghandler=pghandler)
+try:
+transaction.commit()
+except:
+import sys, pdb
+pdb.post_mortem(sys.exc_info()[2])
 except ConflictError:
 raise
 except:

this made the reindex take a ridiculously long time, and it leaves the catalog 
in an inconsistent state (i.e. it should only be done on a copy of the 
database, one that you can throw away), but it did in the end reveal to me 
which record was causing the problem.


the problematic record ended up being a ghosted catalog entry that happened to 
share the same name as a view.  when the catalog tried to look up the object 
by its path (via unrestrictedTraverse), the view object was returned.


thanks for the help!

-r

___
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] question about cataloging Page Templates

2008-06-24 Thread Erik Myllymaki
In Page Templates that use macros, how would you ensure that the entire 
rendered page is cataloged and returned by a search?


For instance, this template:


 

tomatoes

 


is returned when you search for "tomatoes" but is not returned when you 
search on a word that is in the "main" macro in "template1" Page Template.






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


Re: [Zope] Re: how to unindex an non existing (deleted)object

2008-06-24 Thread robert rottermann

Daniel Nouri schrieb:

robert rottermann writes:

  

Sometimes a catalog query returns brains that point to non existing objects.

how can I remove such brains from the index programmatically  without
using the portal_catalag/advanced/update tab?



  brain.aq_parent._catalog.uncatalogObject(brain.getPath())


Daniel

  

brilliant, exactly what I needed
thanks
robert
___
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] Re: how to unindex an non existing (deleted)object

2008-06-24 Thread Daniel Nouri
robert rottermann writes:

> Sometimes a catalog query returns brains that point to non existing objects.
>
> how can I remove such brains from the index programmatically  without
> using the portal_catalag/advanced/update tab?

  brain.aq_parent._catalog.uncatalogObject(brain.getPath())


Daniel

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


Re: [Zope] how to unindex an non existing (deleted)object

2008-06-24 Thread robert rottermann

Martijn Jacobs schrieb:

robert rottermann wrote:

Hi there,

Sometimes a catalog query returns brains that point to non existing 
objects.


how can I remove such brains from the index programmatically  without 
using the portal_catalag/advanced/update tab?


thanks
robert
If you want to call the update catalog functionality yourself : A 
Zcatalog has a method refreshCatalog which you can use (take a look at 
ZCatalog.py).


If you want to remove the brain you could call the 
_catalog.uncatalogObject method.However, when you have brains which 
point to non-existent objects you should reindex the catalog, as 
something went wrong while (un)indexing these objects.



Martijn.



thanks very much.
robert
___
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 )


Re: [Zope] how to unindex an non existing (deleted)object

2008-06-24 Thread Martijn Jacobs

robert rottermann wrote:

Hi there,

Sometimes a catalog query returns brains that point to non existing 
objects.


how can I remove such brains from the index programmatically  without 
using the portal_catalag/advanced/update tab?


thanks
robert
If you want to call the update catalog functionality yourself : A 
Zcatalog has a method refreshCatalog which you can use (take a look at 
ZCatalog.py).


If you want to remove the brain you could call the 
_catalog.uncatalogObject method.However, when you have brains which 
point to non-existent objects you should reindex the catalog, as 
something went wrong while (un)indexing these objects.



Martijn.

--
Martijn Jacobs
Four Digits, Internet Solutions

a: Willemsplein 15-1 6811 KB Arnhem NL 
kvk: 09162137 | btw: 8161.22.234.B01

e-mail: [EMAIL PROTECTED] | web: http://www.fourdigits.nl
tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117 


___
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] how to unindex an non existing (deleted)object

2008-06-24 Thread robert rottermann

Hi there,

Sometimes a catalog query returns brains that point to non existing objects.

how can I remove such brains from the index programmatically  without using the 
portal_catalag/advanced/update tab?


thanks
robert
___
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 )


Re: [Zope] Retrieve Zope data

2008-06-24 Thread Andreas Jung



--On 24. Juni 2008 13:43:30 +0530 Charith Paranaliyanage 
<[EMAIL PROTECTED]> wrote:



Hi,

Can someone help me on this,
I need to import objects and interfaces in Zope to another program. Say I
have created some objects in Zope and then I need to retrieve them from
other application running separately but within the same machine.

How can I do this? Let me know if such applications and resources if
available.






If you setup Zope using ZEO, you can access the running ZEO Server
using "zopctl run " (the top-level object of Zope
is exposed as 'app').

-aj



pgpCSzueLZXha.pgp
Description: PGP signature
___
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] Retrieve Zope data

2008-06-24 Thread Charith Paranaliyanage
Hi,

Can someone help me on this,
I need to import objects and interfaces in Zope to another program. Say I
have created some objects in Zope and then I need to retrieve them from
other application running separately but within the same machine.

How can I do this? Let me know if such applications and resources if
available.
I am using Python language and I am a novice to Zope. So I don't have
understanding about which protocols to be used.

Regards,
Charith
___
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 )