473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

IndexedCatalog and ZEO

Hello,

I'm trying to use IndexedCatalog
[http://www.async.com.br/projects/IndexedCatalog/] in my CherryPy
[http://www.cherrypy.org] application.
As Zodb support access just from one Python thread, I must either use just
one CherryPy thread (slow), or use ZEO. However, if I understand it good,
when I use
from ZEO import ClientStorage

then ZEO is internally using FileStorage, so no IndexedCatalog is used.

Anyone knews, how to use IndexedCatalog with ZEO, or do I have to "patch"
ZEO for myself (or run this one thread)?

Thanks,
--
Lukas "Almad" Linhart

[:: http://www.almad.net/ ::]
[:: Humans are too complicated to be described with words. ::]
[:: PGP/GNUPg key: http://www.almad.net/download/pubkey.asc ::]
Jul 18 '05 #1
4 1132
Almad wrote:
Hello,

I'm trying to use IndexedCatalog
[http://www.async.com.br/projects/IndexedCatalog/] in my CherryPy
[http://www.cherrypy.org] application.
As Zodb support access just from one Python thread, I must either use just
one CherryPy thread (slow), or use ZEO. However, if I understand it good,
when I use
from ZEO import ClientStorage

then ZEO is internally using FileStorage, so no IndexedCatalog is used.


If you're using IndexedCatalog's Shelf class, just pass it a host/port
tuple instead of a path:

from IndexedCatalog.Shelf import Shelf
shelf = Shelf(('localhost', 1234), [Class1, Class2])
Jul 18 '05 #2
> I'm trying to use IndexedCatalog
[http://www.async.com.br/projects/IndexedCatalog/] in my CherryPy
[http://www.cherrypy.org] application.
As Zodb support access just from one Python thread, I must either use just
one CherryPy thread (slow), or use ZEO. However, if I understand it good,
when I use
from ZEO import ClientStorage

then ZEO is internally using FileStorage, so no IndexedCatalog is used.

Anyone knews, how to use IndexedCatalog with ZEO, or do I have to "patch"
ZEO for myself (or run this one thread)?


I'm not sure that I fully understand your problem - the usage of
IndexedCatalog is IMHO unrelated to threading issues of zodb. And it's not
true that zodb supports only one thread. I use it in a multi-threaded
environment - as does zope.

But it is necessary to use a separate connection object per thread. I've
written myself a transaction service alike to the java transaction api that
creates a connection for every call made to my server. In conjunction with
proxy-objects that keep a unique key for each object, I can happily access
zodb concurrently.

The basic idea is like this:

# open a zodb file storage and store a global reference
db = ....

def get_root():
# the module threadlocal is from the cookbook
conn = threadlocal.get("connection", None)
if conn is None:
conn = db.open()
threadlocal["connection"] = conn
return conn.root()

class Data(PersistenObject):
""" my data-object. It has a property id that identifies it uniquely """
...

class DataProxy(object):
def __init__(self, id):
self.id = id

def _g_data(self):
return get_root()[self.id]

data = property(_g_data)

def __getattr__(self, name):
return getattr(self.data, name)

The magic is in the get_root()-function that fetches a thread-local
connection and returns the root-object in my zodb. In my real application,
the data-object is cached as long as I'm in one transaction, so multiple
attribute accesses are faster.

I have to add that I have no expirience with zeo - so maybe that can also
solve your problems, but that will result in a local loop network access
that also slows down your application.

Regarding the usage of IndexedCatalog: It seems you can use it in
conjunction with zeo as it has no idea of whatever storage is needed - all
it does is indexing zodb objects - which you get from zeo as well. Of
course that means that you have to keep a catalog for every thread/process
that accesses the objects. Alternatively, you maybe can make the
IndexedCatalog a zodb-stored object itself, but I'm not sure about that.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #3
Leif K-Brooks wrote:
from IndexedCatalog.Shelf import Shelf
shelf = Shelf(('localhost', 1234), [Class1, Class2])


Thanks, that is what I was searching for.

--
Lukas "Almad" Linhart

[:: http://www.almad.net/ ::]
[:: Humans are too complicated to be described with words. ::]
[:: PGP/GNUPg key: http://www.almad.net/download/pubkey.asc ::]
Jul 18 '05 #4
Leif K-Brooks wrote:
from IndexedCatalog.Shelf import Shelf
shelf = Shelf(('localhost', 1234), [Class1, Class2])


Is it also possible to connect via socket instead of port? I've tried to
pass '/tmp/zeosocket' instead of ('localhost', 1234), but it isn't
successfull. Is is any way to do that?

Thank You,
--
Lukas "Almad" Linhart

[:: http://www.almad.net/ ::]
[:: Humans are too complicated to be described with words. ::]
[:: PGP/GNUPg key: http://www.almad.net/download/pubkey.asc ::]
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John D. | last post by:
Does anyone know if there is an "in-ram" dictionary based database for Python. I can see some applications where this can really be powerful in applications requiring 10,000 records or less. ...
8
by: Marc | last post by:
Hi all, Having never used a database before and immersing myself in reading stuff about databases over the last two days I have come to this conclusion, I still don't know which one I need. I've...
5
by: Leif K-Brooks | last post by:
I'm writing a relatively simple multi-user public Web application with Python. It's a rewrite of a similar application which used PHP+MySQL (not particularly clean code, either). My opinions on...
18
by: Ville Vainio | last post by:
For quick-and-dirty stuff, it's often convenient to flatten a sequence (which perl does, surprise surprise, by default): ]]] -> One such implementation is at ...
2
by: Almad | last post by:
Hello, is ZCatalog available for standalone zodb? As far as I read tutorial, the relation to zope is obvious. I knew there is IndexedCatalog, but its not developed any more...and without...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.