Re: [Zope] Deleting a file in Python

2007-08-28 Thread zozer
 On Sat, Aug 25, 2007 at 07:35:06AM -0400, [EMAIL PROTECTED] wrote:
 but I can't figure out where context.* is documented.

 It depends what kind of object context is.
 To find out, you may find this product useful:
 http://plone.org/products/docfindertab

 Here is a good start reference for Zope 2 APIs... it was never
 finished or updated for zope later than 2.7, but it's a lot
 better than nothing:
 http://www.plope.com/Books/2_7Edition/AppendixB.stx

 --

 Paul Winkler
 http://www.slinkp.com

Thanks for the links, I'll try installing docfindertab soon as I can.

I'm trying to read a property of a file and the description of it on the
plope site is too terse for me to understand. Here is my code:
doc=getattr(context, filename)
getname=doc.manage_getProperty('user_name')

filename is a parameter passed to the python script, it the name of the
file I'm wanting a property of. I've tried several ways of specifying the
property and none of them work. The property is called user_name, its a
string. Above I'm using quotes to make it a string passing it by value,
I've also done it by assigning a variable the property name, etc.
I also tried it with the optional 2nd argument with different variables like:
getname=doc.manage_getProperty('user_name',d=None)

I've tried not assigning it to a variable, all kinds of minor syntax
changes, but nothing I do works, it gives the same error:
Error Type: AttributeError
Error Value: manage_getProperty


___
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] Deleting a file in Python

2007-08-27 Thread Paul Winkler
On Sat, Aug 25, 2007 at 07:35:06AM -0400, [EMAIL PROTECTED] wrote:
 but I can't figure out where context.* is documented.

It depends what kind of object context is.
To find out, you may find this product useful:
http://plone.org/products/docfindertab

Here is a good start reference for Zope 2 APIs... it was never
finished or updated for zope later than 2.7, but it's a lot
better than nothing:
http://www.plope.com/Books/2_7Edition/AppendixB.stx

-- 

Paul Winkler
http://www.slinkp.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 )


[Zope] Deleting a file in Python

2007-08-25 Thread zozer
I'm reading the zope book, 2.6. And I've worked through the ZopeZoo
tutorial in chapter 11. I want to make it possible to delete entries in
the GuestBook via its web interface. It uses a python script to create the
file with the line:
context.manage_addProduct['OFSP'].manage_addFile(id,
 title=, file=comments)

I assume I could write something like:

context.manage_deleteProduct['OFSP'].manage_removeFile(id)

or maybe:

context.manage_addProduct['OFSP'].manage_deleteFile(id)

but I can't figure out where context.* is documented.


___
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] Deleting a file in Python

2007-08-25 Thread Andreas Jung



--On 25. August 2007 07:35:06 -0400 [EMAIL PROTECTED] wrote:


I'm reading the zope book, 2.6. And I've worked through the ZopeZoo
tutorial in chapter 11. I want to make it possible to delete entries in
the GuestBook via its web interface. It uses a python script to create the
file with the line:
context.manage_addProduct['OFSP'].manage_addFile(id,
 title=, file=comments)

I assume I could write something like:

context.manage_deleteProduct['OFSP'].manage_removeFile(id)



folder.manage_delObjects(id)

-aj

pgpEOat4C6M5N.pgp
Description: PGP signature
___
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] Deleting a file in Python

2007-08-25 Thread Tim Nash
I had to go to the zope cookbook today to get this script so I thought
I'd paste it here for you as well. It may help you. It is from this
url: http://zopelabs.com/cookbook/1037768468

hth
Tim



# to copy something from a folder

copy_info = some_folder.manage_copyObjects(('object_foo',
'object_bar',
'object_baz')
   )

# The argument to manage_copyObjects is a tuple of object IDs which must exist
# in the folder where you call the method.
# The returned result is clipboard data, suitable for putting in a cookie.
# but we don't need cookies if we're copying and pasting in one
# script.
## If you WANT the clipboard in a cookie, maybe because you're
# going to paste it later in some other script, you need to
# pass in a REQUEST like so:

copy_info = some_folder.manage_copyObjects(('object_foo',
'object_bar',
'object_baz'),
   REQUEST
   )
# The cookie is set in REQUEST.RESPONSE.



 To cut stuff from a folder

copy_info = some_folder.manage_cutObjects(('object_foo',
'object_bar',
'object_baz')
   )
# ... it's just like manage_copyObjects


 To delete things completely - no cut, no paste, just gone

some_folder.manage_delObjects(('object_foo',
   'object_bar')
  )



 To paste the result of a cut or copy into a folder

some_other_folder.manage_pasteObjects(copy_info)










## A complete copy / paste example

# get the source and destination parent folders
dest_base = context.restrictedTraverse('/foo/bar/baz')
src_base = context.restrictedTraverse('/fool/bear/booze')

folds = src_base.objectItems('Folder') # where the objects to copy live
for src_id, src_obj in folds:
   # prepare the destination
   try:
  # we might have run the script already, or the destination
  # might just exist already.
  dest = getattr(dest_base, src_id)
  print 'folder exists already',
   except AttributeError:
  # make sure the destination is there.
  dest_base.manage_addProduct['OFSP'].manage_addFolder(src_id, '')
  dest = getattr(dest, s_id)
   print dest.absolute_url()

   # now the real work, actually quite easy
   try:
  copy_info = src_obj.manage_copyObjects(('stylesheet_properties',))
  print   copied...,
  d.manage_pasteObjects(copy_info)
  print pasted!
   except:
  print ...couldn't paste it there.


return printed

On 8/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I'm reading the zope book, 2.6. And I've worked through the ZopeZoo
 tutorial in chapter 11. I want to make it possible to delete entries in
 the GuestBook via its web interface. It uses a python script to create the
 file with the line:
 context.manage_addProduct['OFSP'].manage_addFile(id,
  title=, file=comments)

 I assume I could write something like:

 context.manage_deleteProduct['OFSP'].manage_removeFile(id)

 or maybe:

 context.manage_addProduct['OFSP'].manage_deleteFile(id)

 but I can't figure out where context.* is documented.


 ___
 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 )

___
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 )