[Zope] ZClass property that is a map

Scott Brodsky sbrodsky@mail.com
Tue, 8 Aug 2000 12:54:08 -0400 (EDT)


It's my understanding that this can only be done
in python in the Products subfolder.

I did something like this with David Murray's help
for a BannerProduct.  I modified an existing
python-based banner class and added two "maps" to
each banner object called 'history_views' and
'history_clicks' indexed by a date.

Here's part of code I'm using:

in /Products/ Ban.py file:

__doc__="""Ban Ad Classes"""
__version__=0.1

from Globals import HTMLFile
from Globals import MessageDialog
from Globals import Persistent
from OFS.Image import Image
#import OFS.Image
import OFS.ObjectManager
import Acquisition                # Various
acquisition types.
import AccessControl.Role         # Zope Security
management.
import string


class Ban:
" A Ban Ad Class"

meta_type="Banner Base Class"

def
__init__(self,id,title,file,content_type='',precondition=''):
self.history_clicks = {}
self.history_views = {}

def __setstate__(self,state):
Persistent.__setstate__(self,state)

if not hasattr(self,'history_views'):
self.history_views = {}
if not hasattr(self,'history_clicks'):
self.history_clicks= {}

later in the code the history_views map is updated
when a banner ad is viewed:

keydate=time.strftime("%y%m%d",time.localtime(time.time()))
if self.history_views.has_key(keydate):
self.history_views[keydate] =
self.history_views[keydate]+1

DV,
Scott Brodsky
http://scottb.homepage.com
icq:2202686, Yahoo:sbrodsky2000     
Romans 14:11


______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup