[Zope-dev] manage_clone

2002-07-06 Thread Florent Guillaume

I noticed that CopyContainer.manage_clone doesn't call
manage_afterClone. Is this an oversight or is there a reason ?

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] manage_clone? (amongst others!)

2000-07-11 Thread Chris Withers

Shane Hathaway wrote:
> Chris Withers wrote:
> > I'm still not clear on this. Why would I need access to the product
> > factory when where.manage_addFolder(id,title) works just fine?
> > I thought manage_addFolder was the product factoy method?
> 
> manage_addFolder() is to be considered a shortcut, actually.  The full
> equivalent would be manage_addProduct['OFSP'].manage_addFolder().  If
> you look at Products/OFSP/__init__.py, you'll see there's the class
> registration for the "Folder" type.  In the registration call you'll
> see it uses the argument name "legacy", which suggests that the
> manage_addFolder shortcut may be deprecated.

Okay, that makes sense :-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] manage_clone? (amongst others!)

2000-07-11 Thread Shane Hathaway

Chris,

I'm sorry to hear about your challenges.  I've had some myself.

I think you're being bitten by a bug which prevented manage_clone from
working in a lot of situations, but is solved in 2.2.  The problem was
that when a new object was placed in a container, it didn't get a _p_jar
attribute until the database transaction was completed (which is
standard practice).  But _getCopy() depends on a _p_jar.  So if you
tried to copy an object into an object which has just been placed in the
object hierarchy (a common thing to do), _getCopy() failed.

To fix this, change ObjectManager._setObject() to this:

def _setObject(self,id,object,roles=None,user=None, set_owner=1):
v=self._checkId(id)
if v is not None: id=v
try:t=object.meta_type
except: t=None
self._objects=self._objects+({'id':id,'meta_type':t},)
# Prepare the _p_jar attribute immediately. _getCopy() may need
it.
object._p_jar = self._p_jar
self._setOb(id,object)
object=self._getOb(id)

This will probably work fine in 2.1.x.

manage_addProduct[] gives you access to the object factories.  I wonder
if it would be clearer if you could use "productFactory[]" as a synonym?

Shane

Chris Withers wrote:
> 
> I was going to title this 'I should give up using Zope' but I thought
> I'd give it one last go...
> 
> Yesterday's 6hrs failing to do a tree-walk-and-copy in DTML failed, so I
> thought I'd try in an external method today...
> 
> ..well, that proved to be just as stupid.
> 
> Okay, firstup, has anything happened on this issue:
> http://zope.nipltd.com/public/lists/dev-archive.nsf/ByKey/37C533B80F56E22A
> 
> Basically, it seems like doing anything with ZClasses in python (an
> external method in my case) is likely to lead to suicide on your part.
> 
> How shoudl I be instantiating one?
> 
> Secondly, AFAIU, the following should copy o and put it in the folder
> object 'where' with an id of 'new_id':
> 
> where.manage_clone(o,'new_id')
> 
> It does, for DTML Methods, but for anything else I get:
> 
> Error Type: AttributeError
> Error Value: 'None' object has no attribute 'importFile'
> (the traceback is in a PS ;-)
> 
> Why? How should I be doing this?!
> 
> Lastly, in the following:
> where.manage_addProduct['OFSP'].manage_addFolder(id,title)
> 
> What does the manage_addProduct['OFSP'] actually do?
> In what way does the above differ from:
> where.manage_addFolder(id,title)
> 
> ...which works just fine for me...
> 
> Hope _someone_ can help,
> 
> Chris
> 
> PS:
> Traceback (innermost last):
>   File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 214,
> in publish_module
>   File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 179,
> in publish
>   File /usr/local/zope/2-1-6/lib/python/Zope/__init__.py, line 202, in
> zpublisher_exception_hook
> (Object: ElementWithAttributes)
>   File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 165,
> in publish
>   File /usr/local/zope/2-1-6/lib/python/ZPublisher/mapply.py, line 160,
> in mapply
> (Object: start)
>   File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 102,
> in call_object
> (Object: start)
>   File /usr/local/zope/2-1-6/lib/python/OFS/DTMLMethod.py, line 150, in
> __call__
> (Object: start)
>   File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_String.py,
> line 502, in __call__
> (Object: start)
>   File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_With.py,
> line 148, in render
> (Object: o-e-s)
>   File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_Util.py,
> line 335, in eval
> (Object: iterate(this(),where=REQUEST['where']))
> (Info: this)
>   File , line 0, in ?
>   File
> /usr/local/zope/2-1-6/lib/python/Products/ExternalMethod/ExternalMethod.py,
> line 248, in __call__
> (Object: iterate)
> (Info: ((,), {'where':  at 869c2c0>}, None))
>   File /usr/local/zope/dev/2-1-6/Extensions/chris.py, line 36, in
> iterate
> (Object: ElementWithAttributes)
>   File /usr/local/zope/dev/2-1-6/Extensions/chris.py, line 42, in
> iterate
> (Object: ElementWithAttributes)
>   File /usr/local/zope/2-1-6/lib/python/OFS/CopySupport.py, line 290, in
> manage_clone
> (Object: ElementWithAttributes)
>   File /usr/local/zope/2-1-6/lib/python/OFS/CopySupport.py, line 402, in
> _getCopy
> (Object: index_html)
> AttributeError: (see above)
> 
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.

[Zope-dev] manage_clone? (amongst others!)

2000-07-11 Thread Chris Withers

I was going to title this 'I should give up using Zope' but I thought
I'd give it one last go...

Yesterday's 6hrs failing to do a tree-walk-and-copy in DTML failed, so I
thought I'd try in an external method today...

..well, that proved to be just as stupid.

Okay, firstup, has anything happened on this issue:
http://zope.nipltd.com/public/lists/dev-archive.nsf/ByKey/37C533B80F56E22A

Basically, it seems like doing anything with ZClasses in python (an
external method in my case) is likely to lead to suicide on your part.

How shoudl I be instantiating one?

Secondly, AFAIU, the following should copy o and put it in the folder
object 'where' with an id of 'new_id':

where.manage_clone(o,'new_id')

It does, for DTML Methods, but for anything else I get:

Error Type: AttributeError
Error Value: 'None' object has no attribute 'importFile'
(the traceback is in a PS ;-)

Why? How should I be doing this?!

Lastly, in the following:
where.manage_addProduct['OFSP'].manage_addFolder(id,title)

What does the manage_addProduct['OFSP'] actually do?
In what way does the above differ from:
where.manage_addFolder(id,title)

...which works just fine for me...

Hope _someone_ can help,

Chris

PS:
Traceback (innermost last):
  File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 214,
in publish_module
  File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 179,
in publish
  File /usr/local/zope/2-1-6/lib/python/Zope/__init__.py, line 202, in
zpublisher_exception_hook
(Object: ElementWithAttributes)
  File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 165,
in publish
  File /usr/local/zope/2-1-6/lib/python/ZPublisher/mapply.py, line 160,
in mapply
(Object: start)
  File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 102,
in call_object
(Object: start)
  File /usr/local/zope/2-1-6/lib/python/OFS/DTMLMethod.py, line 150, in
__call__
(Object: start)
  File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
(Object: start)
  File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_With.py,
line 148, in render
(Object: o-e-s)
  File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_Util.py,
line 335, in eval
(Object: iterate(this(),where=REQUEST['where']))
(Info: this)
  File , line 0, in ?
  File
/usr/local/zope/2-1-6/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 248, in __call__
(Object: iterate)
(Info: ((,), {'where': }, None))
  File /usr/local/zope/dev/2-1-6/Extensions/chris.py, line 36, in
iterate
(Object: ElementWithAttributes)
  File /usr/local/zope/dev/2-1-6/Extensions/chris.py, line 42, in
iterate
(Object: ElementWithAttributes)
  File /usr/local/zope/2-1-6/lib/python/OFS/CopySupport.py, line 290, in
manage_clone
(Object: ElementWithAttributes)
  File /usr/local/zope/2-1-6/lib/python/OFS/CopySupport.py, line 402, in
_getCopy
(Object: index_html)
AttributeError: (see above)

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )