15 |
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License |
16 |
# along with this program; if not, write to the Free Software |
# along with this program; if not, write to the Free Software |
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
18 |
from ZOPT import initialize, __FactoryDispatcher__ |
__version__='$Revision$'[11:-2] |
19 |
|
|
20 |
|
from ZOPT import ZopePageTemplate, default_text_dir, \ |
21 |
|
manage_addPageTemplateForm, manage_addPageTemplate |
22 |
|
from App.FactoryDispatcher import FactoryDispatcher |
23 |
|
import Globals, AccessControl, os, fnmatch |
24 |
|
|
25 |
|
class __FactoryDispatcher__(FactoryDispatcher): |
26 |
|
"customized FactoryDispatcher for OpenPT" |
27 |
|
security = AccessControl.ClassSecurityInfo() |
28 |
|
security.declareObjectProtected('Add Page Templates') |
29 |
|
security.declareProtected('Add Page Templates', 'default_text_dir') |
30 |
|
def default_text_dir(*a, **kw): |
31 |
|
return [name[:-3] for name in os.listdir(default_text_dir) if |
32 |
|
fnmatch.fnmatch(name, '*.pt')] |
33 |
|
Globals.InitializeClass(__FactoryDispatcher__) |
34 |
|
|
35 |
|
|
36 |
|
def initialize(context): |
37 |
|
context.registerClass( |
38 |
|
ZopePageTemplate, |
39 |
|
permission='Add Page Templates', |
40 |
|
constructors=(manage_addPageTemplateForm, |
41 |
|
manage_addPageTemplate), |
42 |
|
icon='www/opt.png', |
43 |
|
) |
44 |
|
try: |
45 |
|
# hook OpenPT up CMF's brain |
46 |
|
import FSOPT |
47 |
|
FSOPT.initialize(context) |
48 |
|
except ImportError: |
49 |
|
pass |