[Zope] TREE tag - not showing Folderish objects that contain no sub-objects

2001-01-13 Thread Kevin Howe

I currently have a TREE tag as follows:

  dtml-tree expr="PARENTS[-1]" branches_expr="objectValues()" sort=id

which basically says:

  "Display objects which can contain sub-objects"

such as Folders, Folderish Products, ZClassed based on ObjectManager, etc.

What I would like to do is display these objects, but ONLY IF they currently
contain some objects, so that if an object does not contain any subobjects
at the moment, it is not displayed. Something like the following:

  dtml-tree expr="PARENTS[-1]" branches_expr="_.len( objectValues() )  0"
sort=id

Unfortuntately the above doesn't seem to work (can Python's len() function
be called from DTML?).

Does anyone know what expression might do what I am looking for?

Kevin



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




[Zope-dev] Assigning Permissions To Roles

2000-09-21 Thread Kevin Howe

I am having trouble getting Roles to work via my Python Product.

Creating a local role works fine:
 
  self._addRole('myRole')

But how do I tell the Role what permissions it has programmatically?

After looking in Role.py, I tried the following:

  self.manage_role('myRole', ['View management screens, View'])

but this kicks up an error. Am I calling this impoperly?

kh


___
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] Can ZPatterns Plugins be used separately?

2000-09-18 Thread Kevin Howe

Hi, I'm wondering if it is possible to use ZPattern Plugins in a
non-ZPatterns Product? Allowance for Plugins would be a very useful feature
in many applications.

kh


___
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] Can ZPatterns Plugins be used separately?

2000-09-18 Thread Kevin Howe

Splitting into DataSkins and Plugins sounds like a really sensible idea, I
defintely put my vote in for that.

- Original Message -
From: "Steve Alexander" [EMAIL PROTECTED]
To: "Kevin Howe" [EMAIL PROTECTED]
Cc: "ZOPE-Dev Mailing List" [EMAIL PROTECTED]
Sent: Monday, September 18, 2000 2:28 PM
Subject: Re: [Zope-dev] Can ZPatterns Plugins be used separately?


 Kevin Howe wrote:

  Hi, I'm wondering if it is possible to use ZPattern Plugins in a
  non-ZPatterns Product? Allowance for Plugins would be a very useful
feature
  in many applications.

 You can use PlugIns without using the rest of ZPatterns, such as
 DataSkins and Racks. You still have to have the ZPatterns product
 installed, obviously. I can see this becoming even more useful when
 ZClasses work with PlugIns. This may be a while off, though.

 I'm still in favour of splitting ZPatterns into separate DataSkins and
 PlugIns packages in the next feature release.

 --
 Steve Alexander
 Software Engineer
 Cat-Box limited
 http://www.cat-box.net



___
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] Creating a new Role equivalent to Manager?

2000-09-10 Thread Kevin Howe

I want to create a Role (myRole) for an object which is equivalent to the
Manager Role, basically kust with a different name. How do I (via python)
say that myRole is equivalent?

Something similar to this:

self._addRole( 'myRole', InheritPermissionsFromManager() )

Thanks,
kh


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




[Zope] ZCatalog problem!

2000-09-03 Thread Kevin Howe

Hi, I have a Folderish class (FClass) and I am trying to write it so that
when an FClass object is added in ZOPE, it will automatically create a
ZCatalog object inside itself. I attempted to do this in the manner I had
successfully done this before with other object types:

# handle represents the new object to be added with self,_setObject(id,
handle)
handle.manage_addZCatalog('CatName', 'CatTitle, None)

But this doesn't work. I then did some testing with DTML using the following
method inside a Folder:

dtml-call " manage_addFolder('FolderName') "
dtml-call " manage_addImage('ImageName', '') "
dtml-call " manage_addZCatalog('CatName', 'CatTitle', _.None) "

The new Folder and new Image were both added with no problems. This was what
I expected since the "manage_addFolder" and "manage_addZCatalog" methods are
inherited from OFS.Folder.Folder. The method "manage_addZCatalog" however,
doesn't seem to have been inherited for some reason.

I can add a ZCatalog using the "Add" List, but not programmatically for some
reason, as I can with Folder and Image (and probably most other object
types). Anyone have the faintest clue why this might be?

Thanks,
kh







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




[Zope] initialize()

2000-09-03 Thread Kevin Howe



I've noticed that some ZOPEPython Products define an 
initialize() routine in their __init__.py file and some don't. From what I can 
tell it is not really needed, but simplyoffersa more organized way 
of registering the Product.

Is it good practice to define initialize(), and if so, why + 
what does it do?

kh





[Zope] accessing PARENTS from python???

2000-08-13 Thread Kevin Howe

I am trying to access the PARENT of an object in a python class of mine.
I want to use the absolute_url() of the parent in a variable.

I though it could be done the following way, but got an error:

 parent=self.PARENTS[0]
 aurl = parent.absolute_url()

I then tried using REQUEST. It works, but doesn't give the correct
information. Instead of giving me the parent  of the current object(self),
it gives the parent of the DTML page in which the object was called.

 parent=self.REQUEST.PARENTS[0]
 aurl = parent.absolute_url()

How do you resolve the PARENT object of an object?

Kevin Howe


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




[Zope] Make a Python Products Add list show only certain meta types?

2000-08-12 Thread Kevin Howe

I have a custom Python class (Container)  which uses Folder as it's base
class. I also have a custom Python class (AnObject). I want it so that when
you view a Container object, "AnObject" will be the only meta_type available
to be added in the Add List. The problem is that since Container inherits
from Folder, the Add List makes all object types available to be added. Is
there any way to tell a class to show only certain meta_types?

Kevin




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




[Zope] How to read raw data from HTMLFile?

2000-08-09 Thread Kevin Howe

I would like to pre-process a DTML file (accessed using HTMLFile) before
displaying it in the web browser.

Example Code:

  dtml=HTMLFile('manage/mycode', globals())

  def cleanUp:
 # eliminate blank lines and !-- comments-- from DTML
 .

  def printDTML(self):
 return self.cleanUp(dtml)

The problem is that the dtml variable doesn't return the DTML,  but the
object reference. Is there a way to fetch the raw DTML content from the
HTMLFile object?

Kevin Howe





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




Re: [Zope] interating though REQUEST.form in python???

2000-08-08 Thread Kevin Howe

Yes, when I use this I get the following error:

Error Type: TypeError
Error Value: loop over non-sequence

Kevin

- Original Message -
From: "peter be" [EMAIL PROTECTED]
To: "Kevin Howe" [EMAIL PROTECTED]
Sent: Tuesday, August 08, 2000 5:05 PM
Subject: SV: [Zope] interating though REQUEST.form in python???



 Have you tried?:

 for name,value in REQUEST.form.keys:
 # kewl stuff


 - Original Message -----
 From: Kevin Howe [EMAIL PROTECTED]
 To: ZOPE Mailing List [EMAIL PROTECTED]
 Sent: Tuesday, August 08, 2000 8:16 PM
 Subject: [Zope] interating though REQUEST.form in python???


  I'm trying to do a FOR statement to loop though items in a REQUEST, but
keep
  getting errors:
 
  def myMethod(self,REQUEST):
for name,value in REQUEST.form:
  # do this
 
  I've tried variations:
 
  for name,value in REQUEST.items:
  for item in REQUEST.form.items:
  for key in REQUEST.keys:
 
  but none seem to work.
 
  When I used "return REQUEST.form", a Dictionary was displayed like so:
 
{'item': 'val1', 'item2':'val2', etc.}
 
  so I tried fetching it as a plain dictionary:
 
form = REQUEST.form
return form.keys
 
  but no luck.
 
  Is it not possible to access the REQUEST methods via python?
 
  Kevin
 
 
 
 
  ___
  Zope maillist  -  [EMAIL PROTECTED]
  http://lists.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists -
   http://lists.zope.org/mailman/listinfo/zope-announce
   http://lists.zope.org/mailman/listinfo/zope-dev )
 



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




Re: [Zope] Accessing .gif on disk with Python Product?

2000-08-07 Thread Kevin Howe

Right you are, here's how I solved it:

# __init.py__ for myProduct

misc_={
  'chooserIcon': ImageFile('images/chooserIcon.gif',globals()),
  }

# DTML file

img src="dtml-var absolute_url/misc_/myProduct/chooserIcon" border=0


Thanks!
Kevin

- Original Message -
From: "Martijn Pieters" [EMAIL PROTECTED]
To: "Performance.net Strategic Internet Solutions"
[EMAIL PROTECTED]
Cc: "ZOPE Mailing List" [EMAIL PROTECTED]
Sent: Monday, August 07, 2000 1:15 PM
Subject: Re: [Zope] Accessing .gif on disk with Python Product?



 On Mon, Aug 07, 2000 at 01:12:03PM -0300, Performance.net Strategic
Internet Solutions wrote:
   On Mon, Aug 07, 2000 at 11:21:53AM -0300, Performance.net Strategic
   Internet Solutions wrote:
I am writing a python product and want to display a GIF file in some
of
the manage_pages. It is not meant to be the "icon" property of the
class, just an image to be included in DTML. I included it in my
class
as follows:
   
  chooser = ImageFile('images/chooser.gif',globals()),
   
but when I call it in DTML (dtml-var chooser) I get the following:
   
ImageFile instance at 014F1D90
   
I thought maybe I could use an instance of the Image class:
   
  chooser = OFS.Image('images/chooser.gif',globals()),
   
but this doesn't seem to work.
   
How do you create an instance of an Image in a Python Product?
  
   ImageFile objects do not (like ZODB stored Image objects) generate an
IMG
   tag when called. Image object, when called, generate an IMG tag that
   points the browser to the correct address to retrieve tha actual
image.
  
   With an ImageFile object, you need to construct the tag yourself. If
this
   class has an instance foo, with this ImageFile attribute chooser, and
the
   instance foo is stored in the root of your Zope ZODB, you need to
point
   the browser to http://yoursever/foo/chooser. So your DTML needs to
   generate the following HTML:
  
 img src="http://yoursever/foo/chooser"
  
   I don't know enough about your DTML, but if it is another attribute of
the
   same class, you could use one of the URLx REQUEST variables or
something
   to construct the URL for the image. Also, absolute_url() called on the
foo
   instance may also work for a base URL.
  
   Hope this helps.
 
  Okay, I've done the following:
 
  # Create the method in the .py Class File
  chooserIcon=ImageFile('images/chooserIcon.gif',globals()),
 
  # Call from the .dtml File img src="dtml-var
absolute_url/chooserIcon"
  border=0
 
  absolute_url() works and the URL points correctly to
  http://myserver/foo/chooserIcon, but  if I type in that URL directly, I
get
  a "Not Found" error as though the method does not exist. I've
double-checked
  that the image is there and named correctly, so it's not a syntax thing.
 
  Perhaps I need to convert it to an "Image" object something like below?
 
  # this doesn't work but illustrates the idea chooserIcon = Image(
  ImageFile('images/chooserIcon.gif',globals() )
 
  Help! =:)

 Hmm.. This is how Product Icons are stored, that is, as ImageFile objects.
At
 product init time, a ImageFile objetcs is created for the Product icon and
 stroed in the special misc_ structure for later access.

 Have a look through the Product initialisation code, which is started up
in
 OFS/Application.py::install_products().

 --
 Martijn Pieters
 | Software Engineermailto:[EMAIL PROTECTED]
 | Digital Creations  http://www.digicool.com/
 | Creators of Zope   http://www.zope.org/
 | ZopeStudio: http://www.zope.org/Products/ZopeStudio
 -



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




[Zope] Is DTML a bastardized form of XML, or valid XML?

2000-06-22 Thread Kevin Howe

Hi,

just wondering if DTML is actually a valid form of XML, or a bastardized
version of XML created specifically for ZOPE. I've done a little reasearch
on XML, and I it seems like DTML tags such as:

dtml-var "..."or

dtml-if "..."
...
dtml-else
...
/dtml-if

aren't really valid XML forms. The following would make more sense:

dtml-var expr="..."/or

dtml-if expr="..."
...
dtml-else
...
/dtml-else
...
/dtml-if

Anyone care to enlighten me?

Thanks,
kh





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