Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-20 Thread Roman Klesel
Chris Withers schrieb:
 for id in self.manage_targets.keys():   
 title =
 self.manage_targets[id]['name']   
 self.tgt_folder=Folder()   
 
 
 This is dangerous...

Why is that?

 self._setObject(id,self.tgt_folder)   
 
 
 This is silly...

What's silly about persisting the object I just created?


 Why not just:
 
 self.manage_addFolder(id,title)

Well, the suggestion I got was to do:

self.manage_addProduct['OFSP'].manage_addFolder(...

and this runs in the Error Value: _getProducts
Error.

 
 grinder_home = self.manage_targets['gr_sys']['grinder_home']   
 host_name = self.getHostname(grinder_home)   
 
 
 Okay, what type of object is 'self' here, where did you take this code
 from?

I'm proud to say: I wrote this myself. :-)

self is supposed to be a foldeish object that is supposed to be the container 
for all objects I'm about to create in
this routine.


 system = self.__getitem__(id)   
 
 why not just:
 
 system=self[id]


Great! Didn't know that!



 Also, this will result in system not being acquisition wrapped in some
 circumstances, what you really want is:
 
 system = getattr(self,id)
 
 ...but it really depends on what 'self' is, I'm not sure you have that
 right.

This also works. However to me it looks like, it produces the exact same result 
as __getitem__ and self[id] ...

This  being acquisition wrapped is driving me nuts!
I just don't get it.

And I belive it's the cause for the problems I'm facing ...

Thanks for taking the time analyzing my code!

Greetings Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-20 Thread Sascha Welter
(Thu, Feb 16, 2006 at 12:00:05PM -0500) [EMAIL PROTECTED] wrote/schrieb/egrapse:
 From: Roman Klesel [EMAIL PROTECTED]
 Still I can't get what I want.
 
 when I now do:
 
 system.manage_addProduct['OFSP'].manage_addFile(fid,
   title='',
   file=cpu_load,
   content_type='text/plain',
   precondition='')
 
 I get:
 
 AttributeError: _getProducts

manage_addFile (and some others like manage_addFolder, ...) work
directly without xy.manage_addProduct[...]. 

That part is in the Zope book.

The syntax with manage_addProduct[... is used for filesystem based
products (like the stuff you have in your instances Products folder).

Regards,

Sascha

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-20 Thread Roman Klesel
Hello Sascha,

Sascha Welter schrieb:
 
 manage_addFile (and some others like manage_addFolder, ...) work
 directly without xy.manage_addProduct[...]. 
 
 That part is in the Zope book.
 
 The syntax with manage_addProduct[... is used for filesystem based
 products (like the stuff you have in your instances Products folder).

well, thanks for your consideration, but I'm actually concerned about fs based 
products.
The whole thread is probably totally confusing because I'm totally confused.
I found several inconsistnecies in my code. I'm right now doing a total 
rewright. I'll see it the problems persist.
If so, I'll try to be less confused and decribe the problem more clearly.

Greetings Roman


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-20 Thread Sascha Welter
(Mon, Feb 20, 2006 at 03:45:31PM +0100) Roman Klesel wrote/schrieb/egrapse:
 Sascha Welter schrieb:
  
  manage_addFile (and some others like manage_addFolder, ...) work
  directly without xy.manage_addProduct[...]. 
  
  That part is in the Zope book.
  
  The syntax with manage_addProduct[... is used for filesystem based
  products (like the stuff you have in your instances Products folder).

 well, thanks for your consideration, but I'm actually concerned about.
 fs based products 

Why be concerned? Don't worry, be happy!
- You can use manage_addFile *from* your own fs based product. 
- You can use manage_addProduct['something']... *from* your own product.
- You can use manage_addProduct['something']... to add instances of your
  own product to folderish objects (and you can do this from TTW code or
  from fs based code)

But you don't use manage_addProduct[... to do manage_addFile, no matter
if your code runs in a TTW script or in a fs based product.

Regards,

Sascha

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-20 Thread Chris Withers

Roman Klesel wrote:

Chris Withers schrieb:
for id in self.manage_targets.keys():   
title =
self.manage_targets[id]['name']   
self.tgt_folder=Folder()   


This is dangerous...


Why is that?


'cos arbitarilly assigning objects to attributes without understanding 
acquisition of the pseudo-interfaces you need to adhere to in Zope will 
mean this _will_ bite you later...



Why not just:

self.manage_addFolder(id,title)


Well, the suggestion I got was to do:

self.manage_addProduct['OFSP'].manage_addFolder(...


They're the same thing really...


and this runs in the Error Value: _getProducts
Error.


Yes, because, almost certainly, 'self' above was not acquisition wrapped.


Okay, what type of object is 'self' here, where did you take this code
from?


I'm proud to say: I wrote this myself. :-)


Well, you did it wrong... show us soem code and we can fix it.


system = getattr(self,id)

...but it really depends on what 'self' is, I'm not sure you have that
right.


This also works. However to me it looks like, it produces the exact same result 
as __getitem__ and self[id] ...


_don't_ count on it...


This  being acquisition wrapped is driving me nuts!
I just don't get it.


Then go use PHP ;-)


And I belive it's the cause for the problems I'm facing ...


Yes, stop fighting the framework ;-)
Take some existing examples and try and adapt them rather than starting 
from scratch with everything...


cheers,

Chris

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

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-17 Thread Chris Withers

Roman Klesel wrote:

form OFS.Image import File

- I build a class _File(File):


I really doubt you need to do that...


- pimped it up a little bit.


What, specifically, did you add?


- _setObject'ed it


You shouldn't be calling that directly...

Chris

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

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-17 Thread Chris Withers

Roman Klesel wrote:

for id in self.manage_targets.keys():   

title = self.manage_targets[id]['name'] 

self.tgt_folder=Folder()


This is dangerous...


self._setObject(id,self.tgt_folder) 


This is silly...

Why not just:

self.manage_addFolder(id,title)


grinder_home = self.manage_targets['gr_sys']['grinder_home']
host_name = self.getHostname(grinder_home)  



Okay, what type of object is 'self' here, where did you take this code from?


for id in self.objectIds('Folder'): 

location_sar = self.manage_targets[id]['location_sar']  

phy_mem = self.manage_targets[id]['phy_mem']

system = self.__getitem__(id)   



why not just:

system=self[id]

?

Also, this will result in system not being acquisition wrapped in some 
circumstances, what you really want is:


system = getattr(self,id)

...but it really depends on what 'self' is, I'm not sure you have that 
right.


cheers,

Chris

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

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread bruno desthuilliers
Roman Klesel wrote:
 Hello,
 
 Roman Klesel schrieb:
 
Hello,

in a product I try to make a file object persistent with the _setObject() 
method.

What's wrong with:

container.manage_addProduct['OFSP'].manage_addFile(id, file='',
title='', precondition='', content_type='', REQUEST=None)


-- 
bruno desthuilliers
développeur
[EMAIL PROTECTED]
http://www.modulix.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread Jens Vagelpohl


On 16 Feb 2006, at 09:33, Roman Klesel wrote:


Hello Bruno,

bruno desthuilliers schrieb:

What's wrong with:

container.manage_addProduct['OFSP'].manage_addFile(id, file='',
title='', precondition='', content_type='', REQUEST=None)


Well, in a fs product I don't have container nor  
self.manage_addProduct or something (AFAIK).


Therefore I use the ._setObject() method.


Instead of container you substitute the object that you called  
_setObject on before. No rocket science here. If that object  
subclasses from the normal Zope Folder class (or is a Zope Folder)  
you *will* have manage_addProduct.


jens

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread Roman Klesel
Hello,

Jens Vagelpohl schrieb:
 If that object  subclasses
 from the normal Zope Folder class (or is a Zope Folder)  you *will* have
 manage_addProduct.

Yes, actually you guys a right! self.manage_addProduct is available...
Hmmm ... wonder what made me think it's not ...

Still I can't get what I want.

when I now do:

system.manage_addProduct['OFSP'].manage_addFile(fid,
title='',
file=cpu_load,
content_type='text/plain',
precondition='')


I get:

AttributeError: _getProducts

So I poked around and rose an exception like this:

 raise KeyError, 'id: %s object: %s self: %s' % (id, system, self)
KeyError: 'id: gr_sys object: Folder at  self: Lasttest at lasttest55004'

Where
 - id is the id of the folder where I want to create the file in.
 - object is the object reference of the same folder
 - and self ist ... self: a folderish object.

So there seems to be something wrong with object. It's recognized that it is 
a folder but for some reason
it seems that it has no real object reference.

It is created like this:

self.tgt_folder[id]=Folder()
self._setObject(id,self.tgt_folder[id])

Of course I should create it with the managed_addProduct[ ... method, but it 
doesn't work. I again get:
AttributeError: _getProducts

I'm getting more and more confused ...

I mean the whole thing can't be totally wrong since everything worked exept 
for, that the objects that I wanted to
have where of type SimpleItem and not File.

So there seems to be something wrong with by parent obejct ... But again this 
is also not possible since i can add
a File product manually with the ZMI ..


Any light s.o.?

Roman


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread Stefan H. Holek
Please learn to read and to provide the *complete* traceback. The  
error text alone is not enough most of the time.


Your error *may* mean that 'system' is not yet wrapped. Are your  
positive that 'system' is a folder that already exists in the ZODB,  
i.e. has already been _setObject'ed?


Stefan


On 16. Feb 2006, at 13:33, Roman Klesel wrote:


when I now do:

system.manage_addProduct['OFSP'].manage_addFile(fid,
title='',
file=cpu_load,
content_type='text/plain',
precondition='')


I get:

AttributeError: _getProducts


--
Anything that happens, happens.  --Douglas Adams


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread Roman Klesel
Hello,

one more thing ...

Roman Klesel schrieb:
Your error *may* mean that 'system' is not yet wrapped. Are your 
positive that 'system' is a folder that already exists in the ZODB, 
i.e. has already been _setObject'ed?
 
 
 As far as I can tell: Yes!

Actually I'm pretty shure, because as I said:

the whole thing ran successfully with _setObject() but in order to get a File 
Produkt I took the advice
to use manage_addProduct[... and that's where I'm stuck ...

Roman

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: 'File' object has no attribute 'manage_fixupOwnershipAfterAdd'

2006-02-16 Thread Roman Klesel
Hello again,

I works! I just managed to get everything as I expected it to be.

How I did it:

form OFS.Image import File

- I build a class _File(File):
- pimped it up a little bit.
- instatiated it
- _setObject'ed it

... et voila

I have nice File-objects with nice CMI interface...

Thanks for holding my hand.

Greetings Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )