File: configure.py

package info (click to toggle)
plone3 3.1.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 73,972 kB
  • ctags: 39,149
  • sloc: python: 209,481; xml: 25,065; sh: 1,395; makefile: 585; php: 129; lisp: 54
file content (88 lines) | stat: -rw-r--r-- 3,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright (c) 2005-2007
# Authors: KSS Project Contributors (see docs/CREDITS.txt)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

from zope.component.zcml import adapter
from interfaces import IEventType, ISelectorType, IAction, IParamProvider
from event_type import EventType
from action import Action
from selector_type import SelectorType
from commandset import registerAndAllowCommandSet
from pprovider import ParamProvider
from plugin import registerPlugin

def registerEventType(_context, name, jsfile=None):
    'Directive that registers an event type' 
    
    # check to see if the file exists
    if jsfile is not None:
        file(jsfile, 'rb').close()

    _context.action(
        discriminator = ('registerKssEventType', name, jsfile),
        callable = registerPlugin,
        args = (EventType, IEventType, name, jsfile),
        )
 
def registerAction(_context, name, jsfile=None, command_factory='none',
        params_mandatory=[], params_optional=[], deprecated=None):
    'Directive that registers an action.' 
    
    # check to see if the file exists
    if jsfile is not None:
        file(jsfile, 'rb').close()

    _context.action(
        discriminator = ('registerKssAction', name, jsfile),
        callable = registerPlugin,
        args = (Action, IAction, name, jsfile, command_factory, params_mandatory, params_optional, deprecated),
        )

def registerSelectorType(_context, name, jsfile=None):
    'Directive that registers a selector type' 
    
    # check to see if the file exists
    if jsfile is not None:
        file(jsfile, 'rb').close()

    _context.action(
        discriminator = ('registerKssSelectorType', name, jsfile),
        callable = registerPlugin,
        args = (SelectorType, ISelectorType, name, jsfile),
        )

def registerCommandSet(_context, for_, class_, name, provides):
    'Directive that registers a command set' 
    
    adapter(_context, [class_], provides, [for_])
    _context.action(
        discriminator = ('registerKssCommandSet', name),
        callable = registerAndAllowCommandSet,
        args = (class_, name, provides),
        )

def registerParamProvider(_context, name, jsfile=None):
    'Directive that registers a parameter provider' 
    
    # check to see if the file exists
    if jsfile is not None:
        file(jsfile, 'rb').close()

    _context.action(
        discriminator = ('registerKssParamProvider', name),
        callable = registerPlugin,
        args = (ParamProvider, IParamProvider, name, jsfile),
        )