Commit 36f0f082 authored by Stuart Bishop's avatar Stuart Bishop

Merging to HEAD

Added getId() to Item_w__name__, since the one inherited from Item
has broken __name__ handling.

PageTemplateFile now using Item_w__name__ mixin, making getId()
and absolute_url() actually work.
parent 82ed622c
......@@ -91,6 +91,11 @@ Zope Changes
Bugs fixed
- Item_w__name__ now has a working getId() method
- PageTemplateFile now using Item_w__name__ mixin, fixing
its getId() and absolute_url() methods.
- Only one VirtualHostMonster is allowed per container.
- Collector #1133: TreeTag choked on Ids of type long.
......
......@@ -17,8 +17,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.108 2003/11/28 16:45:42 jim Exp $'''
__version__='$Revision: 1.108 $'[11:-2]
$Id: SimpleItem.py,v 1.109 2003/12/13 07:57:49 Zen Exp $'''
__version__='$Revision: 1.109 $'[11:-2]
import re, sys, Globals, App.Management, Acquisition, App.Undo
import AccessControl.Role, AccessControl.Owned, App.Common
......@@ -313,6 +313,10 @@ Globals.default__class_init__(Item)
class Item_w__name__(Item):
"""Mixin class to support common name/id functions"""
def getId(self):
"""Returns the id"""
return self.__name__
def title_or_id(self):
"""Utility that returns the title if it is not blank and the id
otherwise."""
......
......@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template from the filesystem.
"""
__version__ = '$Revision: 1.29 $'[11:-2]
__version__ = '$Revision: 1.30 $'[11:-2]
import os, AccessControl
from Globals import package_home, DevelopmentMode
......@@ -29,8 +29,9 @@ from Expressions import SecureModuleImporter
from ComputedAttribute import ComputedAttribute
from Acquisition import aq_parent, aq_inner
from App.config import getConfiguration
from OFS.SimpleItem import Item_w__name__
class PageTemplateFile(Script, PageTemplate, Traversable):
class PageTemplateFile(Item_w__name__, Script, PageTemplate, Traversable):
"Zope wrapper for filesystem Page Template using TAL, TALES, and METAL"
meta_type = 'Page Template (File)'
......
"""Tests of PageTemplateFile."""
import os
import os, os.path
import tempfile
import unittest
......@@ -118,6 +118,33 @@ class TypeSniffingTestCase(unittest.TestCase):
self.check_content_type("<doc><element/></doc>",
"text/xml")
def test_getId(self):
desired_id = os.path.splitext(os.path.split(self.TEMPFILENAME)[-1])[0]
f = open(self.TEMPFILENAME, 'w')
print >> f, 'Boring'
f.close()
pt = PageTemplateFile(self.TEMPFILENAME)
pt_id = pt.getId()
self.failUnlessEqual(
pt_id, desired_id,
'getId() returned %r. Expecting %r' % (pt_id, desired_id)
)
def test_getPhysicalPath(self):
desired_id = os.path.splitext(os.path.split(self.TEMPFILENAME)[-1])[0]
desired_path = (desired_id,)
f = open(self.TEMPFILENAME, 'w')
print >> f, 'Boring'
f.close()
pt = PageTemplateFile(self.TEMPFILENAME)
pt_path = pt.getPhysicalPath()
self.failUnlessEqual(
pt_path, desired_path,
'getPhysicalPath() returned %r. Expecting %r' % (
desired_path, pt_path,
)
)
def test_suite():
return unittest.makeSuite(TypeSniffingTestCase)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment