[Zope-dev] Python Based DataSkins and Propertysheets

Johan Carlsson johanc@torped.se
Mon, 12 Feb 2001 09:50:03 +0100


> > Hi,=20
> > I am trying to figure out ZPatterns and because I rather work with =
Python Products when with Zclasses I am trying to convert the EmployZ =
product to Python.
> > So far I got half the way there, the Rack recognizes the DataSkin
> > And on newItem in the Specialist it a new slot gets created and I =
can see them and their ID.
> >=20
> > Now the problem is creating a Propertysheet in the DataSkin that =
gets stored in the Rack.
>=20
> The attributes of a Persistent DataSkin will get stored in the Rack =
without too much extra work.
>=20
>=20
> > class EmployX(
> >         DataSkin,
> >         #VirtualSheets,
> > ):=20
>=20
> You need to derive EmployX from DataSkin and some=20
> Zope persistent class such as SimpleItem. Otherwise,
> it won't be persistent.

Accualy I don=B4t have to do that.
Have a look at Itamar Shtull-Traurings and Heiko Stoermers
FlatDatabase:

class EntryDataSkin(DataSkin):
    """=20
    Flat Database entry.
    """
   =20
    meta_type =3D "Entry DataSkin"

    ...

    def manage_change(self, REQUEST, RESPONSE):
        """ Change properties """
        for prop in self.database_properties.propertyMap():
            name=3Dprop['id']
            if REQUEST.has_key(name):
                if 'w' in prop.get('mode', 'wd'):
                    value=3DREQUEST.get(name)
                    setattr(self, name, value) <<<<
        RESPONSE.redirect(REQUEST.URL1)


But as I noticed the "properties" was saved as
attributes not as properties in a propertysheet.

I can live with that, but I still would like to know if and=20
how to use propertysheets provided by a DataManager
inside a Pyhton DataSkin?

Johan