Re: [Zope3-Users] local search engine

2013-10-18 Thread Christopher Lozinski
my attention is now on this problem.

First let us see if I understand the high level picture of what is going
on.

Okay, so you have a catalog that you create.

Then you have a query page. 

And some code for displaying the results. 

By local search engine, you mean it only searches inside the local site.

Okay so what is the problem?

 *TypeError: __init__() takes exactly 3 arguments (1 given)*


Where is that called from?

  File /usr/lib/python2.4/site-packages/zope/component/factory.py, line
37, in __call__
return self._callable(*args, **kw)

Let us take a look at the source code
https://github.com/zopefoundation/zope.component/blob/master/src/zope/component/factory.py

Although that is probably not hte correct release.  

So looking for how to install zope 3.3
http://old.zope.org/Products/Zope3/3.3.0b1/README.txt/

Okay, here are the downloads. 
http://old.zope.org/Products/Zope3/

Which version exactly are you using?
Am I following correctly so far?
I will wait until I hear back from you. 


Chris










___
Zope3-users mailing list
Zope3-users@zope.org
https://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] local search engine

2013-09-09 Thread Christopher Lozinski
On 9/8/13 10:19 PM, christophe petit wrote:
 but now, problem happens when I try to add it on root folder.
I will be happy to help you.   I also need to be able to add local
search engine catalogs through the ZMI.

 First let us establish the context.

You have a lot of zope.app stuff in there.  And yet I thought zope.app
was deprecated in ZTK. 
You also talk about the ZMI. Also gone from ZTK.

So what is your starting point?  ZTFY?  Are you using an older version
of Zope 3?

--  
Regards
Christopher Lozinski
 

___
Zope3-users mailing list
Zope3-users@zope.org
https://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] local search engine

2013-09-08 Thread christophe petit
Hi,

Finally, I get to make appear in ZMI my local search engine product by
setting into the following creationCatalog.py source :


--
from zope.component import adapter
from zope.app.intid.interfaces import IIntIds
from zope.app.intid import IntIds
from zope.app.catalog.interfaces import ICatalog
from zope.app.catalog.catalog import Catalog
from zope.app.catalog.text import TextIndex
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.app.container.interfaces import IObjectAddedEvent
from interfaces import ISearchz
from zope.app.component.site import LocalSiteManager
from zope.index.text.interfaces import ISearchableText

@adapter(ISearchz, IObjectAddedEvent)
def creationCatalog(site, event):
  sm = LocalSiteManager(site)
  intids = IntIds()
  sm['intids'] = intids
  sm.registerUtility(intids, IIntIds)

  catalog = Catalog()
  sm['catalog'] = catalog
  sm.registerUtility(catalog, ICatalog)

  fulltext = TextIndex(
  interface=ISearchableText,
  field_name='getSearchableText',
  field_callable=True
  )
  catalog[u'fulltext'] = fulltext
--

but now, problem happens when I try to add it on root folder.

Here's the Searchz.py source (in bold the several options that I tried to
use for making
appear, once product is added, an update item for updating the catalog) :

--
from zope.component import getUtility, queryMultiAdapter
from zope.interface import implements
from zope.publisher.browser import BrowserPage
from zope.dublincore.interfaces import IZopeDublinCore
from zope.index.text.interfaces import ISearchableText
from zope.traversing.browser import absoluteURL
from zope.app.catalog.interfaces import ICatalog
from zope.app.pagetemplate import ViewPageTemplateFile
from interfaces import ISearchz
from persistent import Persistent
from zope.app.folder import Folder
from zope.app.container.btree import BTreeContainer

*class Searchz(Persistent):
#class Searchz(**Folder):
#class Searchz(BTreeContainer):*
  implements(ISearchz)
  def update(self, query):
  catalog = getUtility(ICatalog)
  self.results = catalog.searchResults(fulltext=query)

  render = ViewPageTemplateFile ('search.pt')

  def __call__(self, query):
  self.update(query)
  return self.render()

  def getResultsInfo(self):
  for obj in self.results:
  icon = queryMultiAdapter((obj, self.request), name='zmi_icon')

  if icon is not None:
 icon = icon()

  title = None
  dc = IZopeDublinCore(obj, None)

  if dc is not None:
 title = dc.title
 text = ISearchableText(obj).getSearchableText()

  if len(text)  100:
 text = text[:97] + u'...'

  yield {'icon': icon, 'title': title, 'text': text,
 'absolute_url': absoluteURL(obj, self.request)}

class QueryPage(BrowserPage):
  template = ViewPageTemplateFile('query.pt')
  count = 0
  total = 0
  def __call__(self):
  if UPDATE_SUBMIT in self.request.form:
  d = delete_first in self.request.form
  self.count, self.total = self.context.update(delete=d)
  return self.template()
--

The only option which works is *class Searchz(Persistent): *but I can't
see the content
of a persistent object into ZMI. *Folder *and *BTreeContainer* doesn't
work...

I have to find a container which allows to create a folder with an update
item.

Could you tell me what I need to solve this ?

Thanks

ps: cc seb, j'espère avoir bien résumé :)





--
Subject: local search engine
To: zope3-users zope3-users@zope.org


Hi,

I try to implement a local search engine product with Catalog. For this, I
have followed the Indexing and searching part from Web component
Development with Zope3 book.

My issue occurs when I add the product in ZMI (A system error occurred)
with log :

ERROR SiteError https://site.com/@@contents.html
...
..
 File /usr/lib/python2.4/site-packages/zope/tales/expressions.py, line
217, in __call__
return self._eval(econtext)
  File /usr/lib/python2.4/site-packages/zope/tales/expressions.py, line
211, in _eval
return ob()
  File
/usr/lib/python2.4/site-packages/zope/app/container/browser/contents.py,
line 80, in listContentInfo
self.addObject()
  File
/usr/lib/python2.4/site-packages/zope/app/container/browser/contents.py,
line 245, in addObject
adding.action(request['type_name'], new)
  File

Re: [Zope3-Users] local search engine

2013-08-14 Thread Michael Howitz
Am 01.08.2013 um 14:10 schrieb christophe petit christophe.peti...@gmail.com:
[…]
 @adapter(ISearchz, IObjectAddedEvent)
 def creationCatalog(event):
[…]
 Could you see what's wrong at first sight ?

You define two arguments in the adapter decorator, but your function accepts 
only one.

Yours sincerely,
-- 
Michael Howitz · m...@gocept.com · software developer
gocept gmbh  co. kg · Forsterstraße 29 · 06112 Halle (Saale) · Germany
http://gocept.com · Tel +49 345 1229889-8
Python, Pyramid, Plone, Zope · consulting, development, hosting, operations



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
Zope3-users mailing list
Zope3-users@zope.org
https://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] local search engine

2013-08-01 Thread christophe petit
Hi,

I try to implement a local search engine product with Catalog. For this, I
have followed the Indexing and searching part from Web component
Development with Zope3 book.

My issue occurs when I add the product in ZMI (A system error occurred)
with log :

ERROR SiteError https://site.com/@@contents.html
...
..
 File /usr/lib/python2.4/site-packages/zope/tales/expressions.py, line
217, in __call__
return self._eval(econtext)
  File /usr/lib/python2.4/site-packages/zope/tales/expressions.py, line
211, in _eval
return ob()
  File
/usr/lib/python2.4/site-packages/zope/app/container/browser/contents.py,
line 80, in listContentInfo
self.addObject()
  File
/usr/lib/python2.4/site-packages/zope/app/container/browser/contents.py,
line 245, in addObject
adding.action(request['type_name'], new)
  File
/usr/lib/python2.4/site-packages/zope/app/container/browser/adding.py,
line 142, in action
content = factory()
  File /usr/lib/python2.4/site-packages/zope/component/factory.py, line
37, in __call__
return self._callable(*args, **kw)
*TypeError: __init__() takes exactly 3 arguments (1 given)*

Here are the different sources :

__init__.py :

--

from interfaces import ISearchz
from Searchz import Searchz, QueryPage

--

Searchz.py :

--

from zope.component import getUtility, queryMultiAdapter
from zope.interface import implements
from zope.publisher.browser import BrowserPage
from zope.dublincore.interfaces import IZopeDublinCore
from zope.index.text.interfaces import ISearchableText
from zope.traversing.browser import absoluteURL
from zope.app.catalog.interfaces import ICatalog
from zope.app.pagetemplate import ViewPageTemplateFile
from interfaces import ISearchz

class Searchz(BrowserPage):
  implements(ISearchz)
  def update(self, query):
  catalog = getUtility(ICatalog)
  self.results = catalog.searchResults(fulltext=query)

  render = ViewPageTemplateFile ('search.pt')

  def __call__(self, query):
  self.update(query)
  return self.render()

  def getResultsInfo(self):
  for obj in self.results:
  icon = queryMultiAdapter((obj, self.request), name='zmi_icon')

  if icon is not None:
 icon = icon()

  title = None
  dc = IZopeDublinCore(obj, None)

  if dc is not None:
 title = dc.title
 text = ISearchableText(obj).getSearchableText()

  if len(text)  100:
 text = text[:97] + u'...'

  yield {'icon': icon, 'title': title, 'text': text,
 'absolute_url': absoluteURL(obj, self.request)}

class QueryPage(BrowserPage):
  template = ViewPageTemplateFile('query.pt')
  count = 0
  total = 0
  def __call__(self):
  if UPDATE_SUBMIT in self.request.form:
  d = delete_first in self.request.form
  self.count, self.total = self.context.update(delete=d)
  return self.template()

--

creationCatalog.py :

from zope.component import adapter
from zope.app.intid.interfaces import IIntIds
from zope.app.intid import IntIds
from zope.app.catalog.interfaces import ICatalog
from zope.app.catalog.catalog import Catalog
from zope.app.catalog.text import TextIndex
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.app.container.interfaces import IObjectAddedEvent
from interfaces import ISearchz

@adapter(ISearchz, IObjectAddedEvent)
def creationCatalog(event):
  sm = event.object.getSiteManager()
  intids = IntIds()
  sm['intids'] = intids
  sm.registerUtility(intids, IIntIds)

  catalog = Catalog()
  sm['catalog'] = catalog
  sm.registerUtility(catalog, ICatalog)

  fulltext = TextIndex(
  interface=ISearchableText,
  field_name='getSearchableText',
  field_callable=True
  )
  catalog[u'fulltext'] = fulltext

--

interfaces.py :

--

from zope.interface import Interface
from zope.schema import Text, TextLine, Int
from zope.app.container.constraints import ItemTypePrecondition
from zope.app.container.interfaces import IContainer

class ISearchz(Interface):
def update():

update catalog

def getResultsInfo():

query for searching in catalog

def __setitem__(key, value):

add page

__setitem__.precondition = ItemTypePrecondition(ISearchz)

--

and configure.zcml :

--