Nobody's really answering and I keep getting both closer and further
looking at the ZClasses code.  As I understand it now,
ZClasses.ZClass.createZClassForBase is supposed to address the ZClass
"meta class" issues such as creating the _zclass_ in addition to the
actual class and handling propertysheets.  So I would assume that my
error lies somewhere in there, but I can't figure it out.

A few more notes, when I create a ZClass that subclasses my python base
class which in turn subclasses ZClasses.ObjectManager.ZObjectManager,
it creates a ZClass with a default "View" for "Subobjects".  This
seems to indicate that somewhere the subobjects propertysheet is being
treated as an instance propertysheet rather than a propertysheet of
the ZClass meta class.

Also, when I create an instance from such a ZClass, trying to access
the instance in the ZMI yields an authorization error.  Following is
the traceback:

Traceback (innermost last):
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /usr/Zope/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
    (Object: blah1)
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 98, in publish
  File /usr/Zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
    (Object: manage_workspace)
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 39, in
call_object
    (Object: manage_workspace)
  File /usr/Zope/lib/python/App/Management.py, line 76, in
manage_workspace
    (Object: blah1)
Unauthorized: (see above)

I would assume this happens because the
propertysheets/subobjects/manage method listed in the view tab is not
valid for the instance, but trying to call that method on the ZClass
directly returns:

Traceback (innermost last):
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /usr/Zope/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
  File /usr/Zope/lib/python/ZPublisher/Publish.py, line 89, in publish
  File /usr/Zope/lib/python/ZPublisher/BaseRequest.py, line 278, in
traverse
  File /usr/Zope/lib/python/OFS/PropertySheets.py, line 601, in
__bobo_traverse__
AttributeError: subobjects

I have also tried the two variations in the quoted message below.
Then I tried the two variations below except substituting
ZClasses.ObjectManager.ZObjectManager for
ZClasses.ObjectManager.ObjectManager.  All with the same results

Again, my goal is to be able create a ZClass that subclasses a python
base class that in turn subclasses
ZClasses.ObjectManager.ZObjectManager in such a way that the final
ZClass and any other ZClasses that subclass it have a subobjects tab
in the management view of the ZClass.  Thanks.

On Sun, 27 Jan 2002, Ross Patterson wrote:

> I'm transitioning a product from pure ZClasses to a hybrid product python base
> classes and ZClasses.  So this is my first time working with python
> products.
>
> I'm trying to setup a python base class to provide a central place to
> subclass ZObjectManager and CatalogAware that I can rebase later
> without the ZClass hassle.  But when I try to create a ZClass in the
> product and subclass to one of my python base classes, I don't get the
> subobjects tab in my ZClass.
>
> Clearly I'm missing somthing basic here, but I have scoured the docs
> and mailing lists for a clue before coming here.  BTW, I did find this
> post earlier that no one seemed to reply to, and below that are my
> actual python files.
>
> ---quoted message---
>
> I want to create a Python base class that inherits from the
> ObjectManager and has the "Subobjects" tab in the ZClass management
> screen.  Inheriting from OFS.ObjectManager.ObjectManager does not do
> this - I need to inherit from ZClasses.ObjectManager.ObjectManager.
>
> I still don't know how to have the Subobjects propertysheet thing
> work.  I've tried the two ways I listed in my last email of doing
> this, but I can't get it to work.
>
> One way was:
>
> class MyObjectManager(ZClasses.ObjectManager.ObjectManager):
>     " .... "
>
> class ZMyObjectManager:
>     """Mix-in for Object Management
>     """
>
>     _zclass_=myObjectManager
>
>     propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()
>
>     manage_options=(
>         {'label': 'Subobjects', 'action'
> :'propertysheets/subobjects/manage'},
> )
>
> and then register ZMyObjectManager as a base class in __init__.py.
> The other way was:
>
> class MyObjectManager(ZClasses.ObjectManager.ObjectManager):
>     propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()
>
>     manage_options=(
>         {'label': 'Subobjects', 'action'
> :'propertysheets/subobjects/manage'},
> )
>
> and register that as the base class.  Neither of them work.
>
> --
> Itamar S.T.  [EMAIL PROTECTED]
>
> ---end quoted message---


#!/usr/bin/python
# Products/ZCapitalProjects/__init__.py

from ZClasses import createZClassForBase

from PartBases import PartBases
from PartBase import PartBase
from SitePartBase import SitePartBase
from ProjectPartBase import ProjectPartBase
from PartBases import ZZCPObjectManager, ZCPObjectManager2, ZZCPObjectManager3, 
ZCPObjectManager4

createZClassForBase( PartBases, globals(), 'ZCPPartBases' )
createZClassForBase( PartBase, globals(), 'ZCPPartBase' )
createZClassForBase( SitePartBase, globals(), 'ZCPSitePartBase' )
createZClassForBase( ProjectPartBase, globals(), 'ZCPProjectPartBase' )

createZClassForBase( ZZCPObjectManager, globals(), 'ZZCPObjectManager' )
createZClassForBase( ZCPObjectManager2, globals(), 'ZCPObjectManager2' )
createZClassForBase( ZZCPObjectManager3, globals(), 'ZZCPObjectManager3' )
createZClassForBase( ZCPObjectManager4, globals(), 'ZCPObjectManager4' )

#!/usr/bin/python
# Products/ZCapitalProjects/PartBases.py

import ZClasses
from ZClasses.ObjectManager import ZObjectManager
from Products.ZCatalog.CatalogAwareness import CatalogAware


class PartBases ( ZObjectManager ) : # CatalogAware,
        """
        Base Classes for all ZCP Parts
        """

        pass

class ZCPObjectManager(ZClasses.ObjectManager.ObjectManager):
    " .... "

class ZZCPObjectManager:
    """Mix-in for Object Management
    """

    _zclass_=ZCPObjectManager

    propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()

    manage_options=(
        {'label': 'Subobjects', 'action':'propertysheets/subobjects/manage'},)

class ZCPObjectManager2(ZClasses.ObjectManager.ObjectManager):
    propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()

    manage_options=(
        {'label': 'Subobjects', 'action' :'propertysheets/subobjects/manage'},)

class ZCPObjectManager3(ZClasses.ObjectManager.ZObjectManager):
    " .... "

class ZZCPObjectManager3:
    """Mix-in for Object Management
    """

    _zclass_=ZCPObjectManager3

    propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()

    manage_options=(
        {'label': 'Subobjects', 'action':'propertysheets/subobjects/manage'},)

class ZCPObjectManager4(ZClasses.ObjectManager.ZObjectManager):
    propertysheets=ZClasses.ObjectManager.ZObjectManagerPropertySheets()

    manage_options=(
        {'label': 'Subobjects', 'action' :'propertysheets/subobjects/manage'},)


#!/usr/bin/python
# Products/ZCapitalProjects/PartBase.py

from PartBases import PartBases

class PartBase ( PartBases ) :
        """
        Base Class for ZCP Parts
        """

        pass


#!/usr/bin/python
# Products/ZCapitalProjects/SitePartBases.py

from PartBases import PartBases

class SitePartBase ( PartBases ) :
        """
        Base Class for ZCP Site Parts
        """

        pass


#!/usr/bin/python
# Products/ZCapitalProjects/ProjectPartBases.py

from PartBases import PartBases

class ProjectPartBase ( PartBases ) :
        """
        Base Class for ZCP Project Parts
        """

        pass


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

Reply via email to