Coder Social home page Coder Social logo

Comments (4)

mgedmin avatar mgedmin commented on May 30, 2024

"Catalog" is the usual term in ZODB-land (because a catalog contains one or more indexes). These aren't provided by ZODB itself, but there are packages that provide them on top of ZODB. E.g. one of those is repoze.catalog.

I haven't used catalogs much personally, so I cannot give recommendations.

from zodb.

jimfulton avatar jimfulton commented on May 30, 2024

Good answer. Thanks Marius.

To elaborate a bit, catalogs are objects that maintain multiple indexes on
a collection of objects. They provide for querying on one or more among
multiple indexes. When querying multiple indexes. They rely on some
low-level machinery provided by BTrees for doing set operations on results
from searching multiple indexes.

Jim

On Thu, Feb 11, 2016 at 8:13 AM, Marius Gedminas [email protected]
wrote:

"Catalog" is the usual term in ZODB-land (because a catalog contains one
or more indexes). These aren't provided by ZODB itself, but there are
packages that provide them on top of ZODB. E.g. one of those is
repoze.catalog http://docs.repoze.org/catalog/overview.html.

I haven't used catalogs much personally, so I cannot give recommendations.


Reply to this email directly or view it on GitHub
#44 (comment).

Jim Fulton
http://jimfulton.info

from zodb.

drmalex07 avatar drmalex07 commented on May 30, 2024

@jimfulton , @mgedmin Thank you for your quick answer.

I didn't know about repoze.catalog (in fact i thought that repoze had only to do with authn/authz middleware).

I played a bit with it, and it seems that Catalog objects can be persisted into a ZODB database. It also seems that the catalog doesn't own the indexed objects (and so cannot retrieve by docid), so an external mapping (i.e a DocumentMap) must be maintained side-by-side and also be persisted into the database.

Am i correct? Is the following example valid?

class User(Persistent):
     pass # Implement __cmp__, carry a `name` attribute

# Populate our containers

user_catalog = Catalog()
user_catalog['name'] = CatalogFieldIndex('name')
user_map = DocumentMap()

u1 = User('Totos')
u2 = User('Foo')

user_catalog.index_doc(1, u1)
user_map.add(u1, 1)
user_catalog.index_doc(2, u2)
user_map.add(u2, 2)

# Commit to database

db = DB(FileStorage('users.zodb'))
conn = db.open()
root = conn.root()

root['user_map'] = user_map
root['user_catalog'] = user_catalog
transaction.commit()

conn.close

My main concern lies at this warning: http://docs.repoze.org/catalog/usage.html#restrictions.
But maybe this is resolved by subclassing objects directly from object ??

from zodb.

djay avatar djay commented on May 30, 2024

You might want to look at souper. Its a single data structure that keeps
internal indexes so you can search it.
https://pypi.python.org/pypi/souper

On Fri, 12 Feb 2016 6:41 pm MichailAlexakis [email protected]
wrote:

@jimfulton https://github.com/jimfulton , @mgedmin
https://github.com/mgedmin Thank you for your quick answer.

I didn't know about repoze.catalog (in fact i thought that repoze had only
to do with authn/authz middleware).

I played a bit with it, and it seems that Catalog objects can be
persisted into a ZODB database. It also seems that the catalog doesn't own
the indexed objects (and so cannot retrieve by docid), so an external
mapping (i.e a DocumentMap) must be maintained side-by-side and also be
persisted into the database.

Am i correct? Is the following example valid?

class User(Persistent):
pass # Implement cmp, carry a name attribute

Populate our containers

user_catalog = Catalog()
user_catalog['name'] = CatalogFieldIndex('name')
user_map = DocumentMap()

u1 = User('Totos')
u2 = User('Foo')

user_catalog.index_doc(1, u1)
user_map.add(u1, 1)
user_catalog.index_doc(2, u2)
user_map.add(u2, 2)

Commit to database

db = DB(FileStorage('users.zodb'))
conn = db.open()
root = conn.root()

root['user_map'] = user_map
root['user_catalog'] = user_catalog
transaction.commit()

conn.close

My main concern lies at this warning:
http://docs.repoze.org/catalog/usage.html#restrictions.
But maybe this is resolved by subclassing objects directly from object ??


Reply to this email directly or view it on GitHub
#44 (comment).

from zodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.