Re: [Zope3-Users] Reportlab threadsafe solution?

2006-09-26 Thread JPenny
One way is to use another tool.  If you look at it just right, lpr is a 
general
purpose job scheduler.  It checks a lock resource, and allows only one job
to acquire the lock, etc.

The best cookbook I can find to this idea is:
http://www.faqs.org/docs/Linux-mini/Fax-Server.html

Your main problem then becomes how to efficiently detect that the 
spooled job is finished.

jim penny

[EMAIL PROTECTED] wrote on 09/26/2006 09:14:11 AM:

 Hi
 
 I need to produce PDFs with reportlab.
 
 reportlab is not threadsafe. 
 
(http://two.pairlist.net/pipermail/reportlab-users/2006-June/005037.html)
 
 I think I need a way to queue or generate a lockfile on requests for 
 PDFs so that only one-at-a-time is generated.
 
 I'm hoping that there is a utility for this already, but search in the 
 source for queue or serialize or lock gets me a lot of stuff that does 
 not seem to relate to what I want.
 
 This looks like it would be a relatively simple utility.  Has this been 
 done yet?  Any hints?
 
 -Jim Washington
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users

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


Re: [Zope3-Users] Autocreated content objects

2006-09-26 Thread John Maddison

On 9/25/06, Stephan Richter [EMAIL PROTECTED] wrote:

On Monday 25 September 2006 03:21, John Maddison wrote:
 Is it possible/wise to auto-create content objects in the ZODB? Say I'm
 creating a blog application and have a container type(BlogContainer) and
 want an instance called blog in the root of the ZODB. Is it possible to
 programatically specify this, or is my only option to create it through the
 ZMI? I thought that perhaps an event was generated when the root object was
 created that I could hook into, but it seems not. Perhaps I'm looking at
 this the wrong way - would fixtures like this be better implemented as
 utilities with z3c.traverser redirecting to appropriate views?

It is very much a goal of Zope 3 to allow Python-based content adding; in
fact, I am never adding content via ZMI these days. The closest I get to the
ZMI is the Sample Data generator that creates a full application for me. By
the way, much thanks to SchoolTool, Roger and Juergen who have developed this
concept. We also use the configurator to configure complex content objects.


Hm...a few thoughts on this: firstly,. if you're using this in a
production application, the module name seems a bit misleading :).
Secondly, I'd've expected the context that gets passed t the plugin
would be either the sample object itself or the root object, but it
seems to be none - how can I get the root object? Finally, it seems to
make the problem a bit more indirect, but still there - how could I
automatically create  a SampleManager on startup?  With the new event
(I gather that would work - I guess I'm askign what the best
practice would be, if in fact I'm not trying to do something silly to
begin with)?


So to answer your specific question: There is an event fired when the database
is opened with the root. See zope.app.appsetup.bootstrap, line 193. Hoever, I
agree that an created and add event should be created for the root folder in
the same function. Could you file a bug report, or even better provide a fix
with test? :-)


Fred already did it :)

Also, thank you  to everyone for your quick and varied answers - zope3
is generally fairly well documented at the code level, and it's great
to know it's easy to find answers to more architecture-y questions,
too.
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re[2]: [Zope3-Users] filter possibilities

2006-09-26 Thread Ivan Horvath
thank you Chris,

at least you've answered ...

but yesterday i've spent all my day to figure out how the hurry.query works 
without success - may be that was the reason if i was a little bit ironic - 
sorry for that

unfortunatelly i don't know too much about zope, but i would like to learn its 
capabilities
i really don't know how to raise my question in a different way, i think i was 
specific enough

i'm still waiting for a hint ...

*** REPLY SEPARATOR  ***

On 26/09/2006 at 11:00 Chris Withers wrote:

Ivan Horvath wrote:
 Is there anybody out there?

Plenty.

 why haven't i received any answer?

Because no one understood the question, or maybe no one knew the answer,
or just maybe nobody had time or nobody felt like it...

 i thought this list is to raise question if i don't know something,

Sure :-)

 and i need some help to continue my work with Zope3

That's okay, but this is a volunteer list, if you need stuff to be done
and you're not getting answers, hire a Zope 3 consultant...

Chris

--
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk


Best regards,
Ivan Horvath
Chief Programmer

 Alcatel ISD
 PMS 2000 Product Team

 H-1116, Budapest
 Kondorfa u. 10.
 Tel.: +36 1 209 9546
 Fax.: +36 1 209 9599
 Mobil: +36 30 257 0235
 VOIP: +49 511 676 478010
 [EMAIL PROTECTED]

Anyone who has never made a mistake has never tried anything new.

/Albert Einstein/

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


Re: [Zope3-Users] Autocreated content objects

2006-09-26 Thread Fred Drake

On 9/26/06, John Maddison [EMAIL PROTECTED] wrote:

Right, that's basically what I want to run, but I can't seem to figure
out how to have that run at ZODB creation time.  Should I be listening
for the event that Fred added (thanks!) and run that in the
subscriber?


There are a couple of ways to go about this with the current codebase:

1) Listen for the IDatabaseOpenedEvent, and make sure you get there
before the default subscriber does.  Add your root before the default
root is created.

2) Listen for the IDatabaseOpenedWithRootEvent, and be willing to
replace the application root.  You need to be sure that you're
replacing it with an object that will support all the things you
expect, since the default is an actual ISite implementation.  (Not
sure just how important that really is, though.  Lots of code will
expect it to be, but hopefully nothing really fundamental.)

My proposed new event is what you really want, since it would only be
triggered when an application root is needed.  But I'd like some
assurance that I'm not the only one who thinks that's the right
approach before I bang out tests and code.


 -Fred

--
Fred L. Drake, Jr.fdrake at gmail.com
Every sin is the result of a collaboration. --Lucius Annaeus Seneca
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] filter possibilities

2006-09-26 Thread Rupert Redington
I'm no expert on this... In fact I often find myself struggling to get
cataloging in Zope3 to do what I want in a painless way (which is
probably why hurry exists...). Experts please correct me if I'm doing
anything objectionable...

I'm assuming that you've got an IntIds utility and a catalog,
and I'm assuming that in your catalog is a FieldIndex which uses
IZopeDublinCore...

If not the following _may_ provide a little help:
from zope.app.catalog.interfaces import ICatalog
from zope.app.catalog.catalog import Catalog
from zope.app.catalog.field import FieldIndex
from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.component.hooks import getSite
from zope.app.component.site import UtilityRegistration
from zope.app.component.interfaces.registration import ActiveStatus
from zope.component import provideUtility

# Find your site's manager and get the default tool folder
sm = getSite().getSiteManager()
smf = sm['default']
# make a catalog and put it in the folder
catalog = Catalog()
smf['My Catalog'] = catalog

# Register the new catalog so that its available for use
reg = UtilityRegistration('', ICatalog, catalog)
smf.registrationManager.addRegistration(reg)
reg.status = ActiveStatus

# Use provide utility so that the catalog is ready for use
provideUtility(catalog, ICatalog)

# Add a Field index which will catalog the creation time of objects
index = FieldIndex('created', IZopeDublinCore)
catalog['Date Created'] = index

Once your catalog has indexes and they're indexing objects then you can
start trying queries. Here's an attempt at a query to find all indexed
objects created in the last 10 days:

from zope.app.catalog.interfaces import ICatalog
from hurry.query.interfaces import IQuery
from hurry.query import Ge
import datetime

#Grab our catalog and query utilities
catalog = getUtility(ICatalog)
query = getUtility(IQuery)

# make a tuple to tell hurry which catalog and index we want to use
index = (catalog, 'Date Created')

# make a datetime object (in my timezone) to find out when
# 10 days ago was...
now = datetime.datetime.now(pytz.timezone('GB'))
then = now - datetime.timedelta(10)

results = query.searchResults(Ge(index, then))

Good Luck,

Rupert







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


Re: [Zope3-Users] Re: Reportlab threadsafe solution?

2006-09-26 Thread Chris McDonough

Why not just use a mutex (a recursive lock makes things easier too)?

lock = threading.RLock()
lock.acquire()
try:
  ...
finally:
  lock.release()



On Sep 26, 2006, at 9:19 AM, Philipp von Weitershausen wrote:


Jim Washington wrote:

Hi
I need to produce PDFs with reportlab.
reportlab is not threadsafe. (http://two.pairlist.net/pipermail/ 
reportlab-users/2006-June/005037.html)
I think I need a way to queue or generate a lockfile on requests  
for PDFs so that only one-at-a-time is generated.
I'm hoping that there is a utility for this already, but search in  
the source for queue or serialize or lock gets me a lot of stuff  
that does not seem to relate to what I want.
This looks like it would be a relatively simple utility.  Has this  
been done yet?  Any hints?


You may want to look at zc.queue: http://svn.zope.org/zc.queue/ 
trunk/src/zc/queue/queue.txt?rev=67933view=auto


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



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


[Zope3-Users] Reportlab threadsafe solution?

2006-09-26 Thread Jim Washington

Hi

I need to produce PDFs with reportlab.

reportlab is not threadsafe. 
(http://two.pairlist.net/pipermail/reportlab-users/2006-June/005037.html)


I think I need a way to queue or generate a lockfile on requests for 
PDFs so that only one-at-a-time is generated.


I'm hoping that there is a utility for this already, but search in the 
source for queue or serialize or lock gets me a lot of stuff that does 
not seem to relate to what I want.


This looks like it would be a relatively simple utility.  Has this been 
done yet?  Any hints?


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


Re: [Zope3-Users] filter possibilities

2006-09-26 Thread Martijn Faassen

Ivan Horvath wrote:

Dear All,

i have to provide some filter function in our system.
i've checked the hurry.query solution

e.g.
obj1.property = As Built Documentation
obj2.property = Planning Documentation
obj3.property = As Built Drawing

i would like to filter my objects in the following ways:
filter for substring.
when i make a filter for this property with the following expr.: As Built
i would like to get obj1, obj3 back as result

how is it possible? query.Eq or AnyOf doesn't give back anything.


You may want to look at hurry.query.Text. If you index something using a 
full text index (from zope.app.catalog.text import TextIndex) you can do 
such partial matching.


This does presume you do have the intids and catalog all set up in your 
own code. Does hurry.query.Eq work when you feed it a complete text, 
such as As Built Documentation?


It may also be that you want to reorganize your objects slightly so that 
you have *two* fields, one 'As Built' and one 'Document' or 'Drawing'. 
It could be that you're trying to put information into one field that 
really should be in multiple fields. If you do that, you can use the 
Field index and query.Eq.


Good luck!

Regards,

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


Re: [Zope3-Users] filter possibilities

2006-09-26 Thread Ivan Horvath


Best regards, Ivan 
Horvath Chief ProgrammerAlcatel ISDPMS 2000 Product 
TeamH-1116, BudapestKondorfa u. 10.Tel.: +36 1 209 
9546Fax.: +36 1 
209 9599Mobil: +36 
30 257 0235VOIP: 
+49 511 676 478010[EMAIL PROTECTED]Anyone who 
has never made a mistake has never tried anything new./Albert Einstein/ 

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


Re: [Zope3-Users] Autocreated content objects

2006-09-26 Thread John Maddison

Oops, forgot to CC the list.

On 9/27/06, John Maddison [EMAIL PROTECTED] wrote:

On 9/26/06, Fred Drake [EMAIL PROTECTED] wrote:
 On 9/26/06, John Maddison [EMAIL PROTECTED] wrote:
  Right, that's basically what I want to run, but I can't seem to figure
  out how to have that run at ZODB creation time.  Should I be listening
  for the event that Fred added (thanks!) and run that in the
  subscriber?

 There are a couple of ways to go about this with the current codebase:

 1) Listen for the IDatabaseOpenedEvent, and make sure you get there
 before the default subscriber does.  Add your root before the default
 root is created.

 2) Listen for the IDatabaseOpenedWithRootEvent, and be willing to
 replace the application root.  You need to be sure that you're
 replacing it with an object that will support all the things you
 expect, since the default is an actual ISite implementation.  (Not
 sure just how important that really is, though.  Lots of code will
 expect it to be, but hopefully nothing really fundamental.)

Ah, I think I may have misdescribed what I was trying to do - I'm not
trying to replace the root object, I'm trying to automatically create
some other objects to put inside it (without having to use the ZMI).

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