Re: [Zope3-Users] Re: Autocreated content objects

2006-09-28 Thread Martijn Faassen

Fred Drake wrote:

On 9/26/06, Baiju M <[EMAIL PROTECTED]> wrote:

If this is a _bug fix_ and not a _feature_, can we port it to 3.3 also.
Of cource in 3.3.1 release only.


I think so.  I've got to get some sleep now, but feel free to go ahead
and backport it if like.


If this is really a bugfix, someone had better backport it. :)

Regards,

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


Re: [Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread Fred Drake

On 9/26/06, Baiju M <[EMAIL PROTECTED]> wrote:

If this is a _bug fix_ and not a _feature_, can we port it to 3.3 also.
Of cource in 3.3.1 release only.


I think so.  I've got to get some sleep now, but feel free to go ahead
and backport it if like.


 -Fred

--
Fred L. Drake, Jr.
"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] Re: Autocreated content objects

2006-09-25 Thread Baiju M

On 9/26/06, Fred Drake <[EMAIL PROTECTED]> wrote:

On 9/25/06, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote:
> Yeah, like Stephan says, Zope should probably send an
> IObjectCreatedEvent there. In the mean time, you can hook into
> IDatabaseOpenedEvent which gets sent every time Zope starts up and opens
> a connection to the ZODB.

I've fixed the trunk so that an IObjectCreatedEvent is generated when
the root folder is created.


If this is a _bug fix_ and not a _feature_, can we port it to 3.3 also.
Of cource in 3.3.1 release only.

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


Re: [Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread Fred Drake

On 9/25/06, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote:

Yeah, like Stephan says, Zope should probably send an
IObjectCreatedEvent there. In the mean time, you can hook into
IDatabaseOpenedEvent which gets sent every time Zope starts up and opens
a connection to the ZODB.


I've fixed the trunk so that an IObjectCreatedEvent is generated when
the root folder is created.

The IDatabaseOpenedEvent certainly could be used to establish an
alternate application root, but the ordering of the events is a
problem (predictable, but that's somewhat fragile); it's not
completely obvious how to get your subscriber called before the
default subscriber.

I'd like to suggest that a new event be fired by the default
subscriber if there isn't already an application root.  Currently, a
separate event is fired when the database is opened and the presence
of an application root has been established
(IDatabaseOpenedWithRootEvent).  A separate event could be fired
before the root is created and added
(IDatabaseOpenedWithoutRootEvent); this should provide the same
information as the IDatabaseOpenedEvent, plus the name of the key that
is expected to hold the root object.  A subscriber can use that event
to add the application root (and anything else).  After the event is
processed, the default subscriber can check again for the root; if it
still doesn't exist, the current creation code can be used to create
the root folder.

This should make it a lot easier to use alternate root objects,
something it sounds like many of us have run up against.


 -Fred

--
Fred L. Drake, Jr.
"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


[Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread Philipp von Weitershausen

Tom Dossis wrote:

mats.nordgren wrote:

The IntId subscribers are fired on
zope.app.container.interfaces.IObjectAddedEvent and IObjectRemovedEvent.



That's correct, however the (IWrite)Container __setitem__ method invokes
the ObjectAddedEvent for you when you add an object to the container.

Your code below looks like it's running zope directly, e.g. `zopectl
debug`.  In this case you need to explicitly set a/the current site
yourself.  Try insert the following first up...

  from zope.app.component import hooks
  hooks.setSite(app.root())


Correct. SItes are usually found during traversal. When doing stuff 
before any traversal is happening, you won't have a local site yet. So, 
using setSite() is appropriate, just remember to call setSite(None) 
afterwards for cleanup!


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


Re: [Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread Tom Dossis
mats.nordgren wrote:
> The IntId subscribers are fired on
> zope.app.container.interfaces.IObjectAddedEvent and IObjectRemovedEvent.
> 

That's correct, however the (IWrite)Container __setitem__ method invokes
the ObjectAddedEvent for you when you add an object to the container.

Your code below looks like it's running zope directly, e.g. `zopectl
debug`.  In this case you need to explicitly set a/the current site
yourself.  Try insert the following first up...

  from zope.app.component import hooks
  hooks.setSite(app.root())

> 
> On Mon, 25 Sep 2006 18:55:11 +0200, Volker Bachschneider wrote
>> Philipp von Weitershausen schrieb:
>>> John Maddison wrote:
 Is it possible/wise to "auto-create" content objects in the ZODB?  Say
>>> Yeah, like Stephan says, Zope should probably send an 
>>> IObjectCreatedEvent there. In the mean time, you can hook into
>> That works fine to me, but:
>>
>> import transaction
>> from zope.app.myproject.person import Person
>> from zope.event import notify
>> from zope.livecycleevent import ObjectCreatedEvent
>> obj = app.root()['005'] = Person()
>> obj.nnam = u'Karlson'
>> notify(ObjectCreatedEvent(obj))
>> transaction.commit()
>>
>> creates a perfect object with timestamp in the ZODB. But the IntId / 
>> Catalog do not recognizes the object. On the other hand, an object 
>> manual created via zmi and programatically modified via Script (with 
>> event ObjectModifiedEvent) is noticed and can be reindexed. Objects 
>> created only via zmi are recognizes and indexed. I think i have to 
>> fire up an IntIdAddedEvent but do not how.
>>
>> Volker
>> ___
>> 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 mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread mats.nordgren
The IntId subscribers are fired on
zope.app.container.interfaces.IObjectAddedEvent and IObjectRemovedEvent.

Cheers,

Mats

On Mon, 25 Sep 2006 18:55:11 +0200, Volker Bachschneider wrote
> Philipp von Weitershausen schrieb:
> > John Maddison wrote:
> >> Is it possible/wise to "auto-create" content objects in the ZODB?  Say
> 
> > 
> > Yeah, like Stephan says, Zope should probably send an 
> > IObjectCreatedEvent there. In the mean time, you can hook into
> 
> That works fine to me, but:
> 
> import transaction
> from zope.app.myproject.person import Person
> from zope.event import notify
> from zope.livecycleevent import ObjectCreatedEvent
> obj = app.root()['005'] = Person()
> obj.nnam = u'Karlson'
> notify(ObjectCreatedEvent(obj))
> transaction.commit()
> 
> creates a perfect object with timestamp in the ZODB. But the IntId / 
> Catalog do not recognizes the object. On the other hand, an object 
> manual created via zmi and programatically modified via Script (with 
> event ObjectModifiedEvent) is noticed and can be reindexed. Objects 
> created only via zmi are recognizes and indexed. I think i have to 
> fire up an IntIdAddedEvent but do not how.
> 
> Volker
> ___
> 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] Re: Autocreated content objects

2006-09-25 Thread Volker Bachschneider

Philipp von Weitershausen schrieb:

John Maddison wrote:
Is it possible/wise to "auto-create" content objects in the ZODB?  Say 




Yeah, like Stephan says, Zope should probably send an 
IObjectCreatedEvent there. In the mean time, you can hook into 


That works fine to me, but:

import transaction
from zope.app.myproject.person import Person
from zope.event import notify
from zope.livecycleevent import ObjectCreatedEvent
obj = app.root()['005'] = Person()
obj.nnam = u'Karlson'
notify(ObjectCreatedEvent(obj))
transaction.commit()

creates a perfect object with timestamp in the ZODB. But the IntId / 
Catalog do not recognizes the object. On the other hand, an object 
manual created via zmi and programatically modified via Script (with 
event ObjectModifiedEvent) is noticed and can be reindexed. Objects 
created only via zmi are recognizes and indexed. I think i have to fire 
up an IntIdAddedEvent but do not how.


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


[Zope3-Users] Re: Autocreated content objects

2006-09-25 Thread Philipp von Weitershausen

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.  


Yeah, like Stephan says, Zope should probably send an 
IObjectCreatedEvent there. In the mean time, you can hook into 
IDatabaseOpenedEvent which gets sent every time Zope starts up and opens 
a connection to the ZODB.


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