Issue 269 in dexterity: Documentation error or bug or bits shifted? Breaking things by using __of__

3 views
Skip to first unread message

dext...@googlecode.com

unread,
Apr 30, 2012, 9:17:22 AM4/30/12
to dexterity-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 269 by do3cc...@gmail.com: Documentation error or bug or bits
shifted? Breaking things by using __of__
http://code.google.com/p/dexterity/issues/detail?id=269

We programatically generate dexterity objects, like explained here:


http://plone.org/products/dexterity/documentation/manual/developer-manual/reference/manipulating-content-objects

We use createObject(), then we used new_ob.__of__(container)

Then we used addContentToContainer() to add the content to the folder.

Then things got fancy, trying to access the newly created objects we got
errors because the request object did not contain a RESPONSE. The Request
itself was also weird, the __repr__ of it did not show the URL. Weirder
yet, consistently id(request) on each object jielded the same id, and when
creating the object we also had a request with the same id.
Restarting the instance, all issues vanished.

The Contenttypes themselves are the plone.app.contenttypes types, a pretty
standard File object. We could reproduce it with many different content
types.

After no success with debugging this, we went the trial and error route,
and after we stopped wrapping the object with __of__()
All objects disappeared. I am not sure if this is known behavior, then it
might make sense to add a warning in the dexterity manual, or remove the
hint of using __of__.

dext...@googlecode.com

unread,
Jan 10, 2013, 6:00:56 AM1/10/13
to dexterity-...@googlegroups.com

Comment #1 on issue 269 by wich...@wiggy.net: Documentation error or bug or
bits shifted? Breaking things by using __of__
http://code.google.com/p/dexterity/issues/detail?id=269

I'm not sure what you mean with "all objects disappeared", can you explain
that?

You must not acquisition-wrap an objects before calling
addContentToContainer. You should do this instead:

obj = createContent('my.type')
obj = addContentToContainer(container, obj)

addContentToContainer will return the acquisition-wrapped object and will
also handle some corner cases such as a content rule moving an object to a
different folder automatically.

Using createContent is preferred over createObject since it adds a
convenient method to set some initial attributes via keyword arguments and
takes care of sending an ObjectCreatedEvent.

dext...@googlecode.com

unread,
Jan 10, 2013, 6:12:28 AM1/10/13
to dexterity-...@googlegroups.com

Comment #2 on issue 269 by do3cc...@gmail.com: Documentation error or bug
or bits shifted? Breaking things by using __of__
http://code.google.com/p/dexterity/issues/detail?id=269

I am totally capable of writing "All objects disappeared" while
meaning "All problems disappeared" and not noticing the error while
reviewing my own bug report. This is a feature of mine, of course.

I can not remember why we did not use createContent, my source history
gives no indication.

The bug report is valid insofar as the documentation linked above still
states one must use __of__ on the newly created object. It is a
documentation bug.


Reply all
Reply to author
Forward
0 new messages