Back to index

plone3  3.1.7
configure.py
Go to the documentation of this file.
00001 # Copyright (c) 2005-2007
00002 # Authors: KSS Project Contributors (see docs/CREDITS.txt)
00003 #
00004 # This program is free software; you can redistribute it and/or modify
00005 # it under the terms of the GNU General Public License version 2 as published
00006 # by the Free Software Foundation.
00007 #
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License
00014 # along with this program; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00016 # 02111-1307, USA.
00017 
00018 from zope.component.zcml import adapter
00019 from interfaces import IEventType, ISelectorType, IAction, IParamProvider
00020 from event_type import EventType
00021 from action import Action
00022 from selector_type import SelectorType
00023 from commandset import registerAndAllowCommandSet
00024 from pprovider import ParamProvider
00025 from plugin import registerPlugin
00026 
00027 def registerEventType(_context, name, jsfile=None):
00028     'Directive that registers an event type' 
00029     
00030     # check to see if the file exists
00031     if jsfile is not None:
00032         file(jsfile, 'rb').close()
00033 
00034     _context.action(
00035         discriminator = ('registerKssEventType', name, jsfile),
00036         callable = registerPlugin,
00037         args = (EventType, IEventType, name, jsfile),
00038         )
00039  
00040 def registerAction(_context, name, jsfile=None, command_factory='none',
00041         params_mandatory=[], params_optional=[], deprecated=None):
00042     'Directive that registers an action.' 
00043     
00044     # check to see if the file exists
00045     if jsfile is not None:
00046         file(jsfile, 'rb').close()
00047 
00048     _context.action(
00049         discriminator = ('registerKssAction', name, jsfile),
00050         callable = registerPlugin,
00051         args = (Action, IAction, name, jsfile, command_factory, params_mandatory, params_optional, deprecated),
00052         )
00053 
00054 def registerSelectorType(_context, name, jsfile=None):
00055     'Directive that registers a selector type' 
00056     
00057     # check to see if the file exists
00058     if jsfile is not None:
00059         file(jsfile, 'rb').close()
00060 
00061     _context.action(
00062         discriminator = ('registerKssSelectorType', name, jsfile),
00063         callable = registerPlugin,
00064         args = (SelectorType, ISelectorType, name, jsfile),
00065         )
00066 
00067 def registerCommandSet(_context, for_, class_, name, provides):
00068     'Directive that registers a command set' 
00069     
00070     adapter(_context, [class_], provides, [for_])
00071     _context.action(
00072         discriminator = ('registerKssCommandSet', name),
00073         callable = registerAndAllowCommandSet,
00074         args = (class_, name, provides),
00075         )
00076 
00077 def registerParamProvider(_context, name, jsfile=None):
00078     'Directive that registers a parameter provider' 
00079     
00080     # check to see if the file exists
00081     if jsfile is not None:
00082         file(jsfile, 'rb').close()
00083 
00084     _context.action(
00085         discriminator = ('registerKssParamProvider', name),
00086         callable = registerPlugin,
00087         args = (ParamProvider, IParamProvider, name, jsfile),
00088         )