[Zope3-checkins] CVS: Zope3/src/zope/app/content - __init__.py:1.3
configure.zcml:1.32
Suresh Babu Eddala
sbabu at zeomega.com
Thu Dec 18 11:32:34 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/content
In directory cvs.zope.org:/tmp/cvs-serv5646
Modified Files:
__init__.py configure.zcml
Log Message:
queryContentType added to get ConentType for objects
for default contents interface type(IContentType) added
=== Zope3/src/zope/app/content/__init__.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/content/__init__.py:1.2 Wed Dec 25 09:12:48 2002
+++ Zope3/src/zope/app/content/__init__.py Thu Dec 18 11:32:03 2003
@@ -1,2 +1,80 @@
+##############################################################################
#
-# This file is necessary to make this directory a package.
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+from zope.app.interfaces.content import IContentType
+from zope.interface.declarations import providedBy
+
+def queryContentType(object):
+ """returns object content type
+
+ >>> from zope.interface import Interface, implements, directlyProvides
+ >>> class I(Interface):
+ ... pass
+ >>> directlyProvides(I, IContentType)
+ >>> class C:
+ ... implements(I)
+ >>> obj = C()
+ >>> c1_ctype = queryContentType(obj)
+ >>> c1_ctype.__name__
+ 'I'
+ >>> class I1(I):
+ ... pass
+ >>> class I2(I1):
+ ... pass
+ >>> class I3(Interface):
+ ... pass
+ >>> class C1:
+ ... implements(I1)
+ >>> obj1 = C1()
+ >>> c1_ctype = queryContentType(obj1)
+ >>> c1_ctype.__name__
+ 'I'
+ >>> class C2:
+ ... implements(I2)
+ >>> obj2 = C2()
+ >>> c2_ctype = queryContentType(obj2)
+ >>> c2_ctype.__name__
+ 'I'
+ >>> class C3:
+ ... implements(I3)
+ >>> obj3 = C3()
+
+ If Interface doesn't provide IContentType, queryContentType returns None.
+
+ >>> c3_ctype = queryContentType(obj3)
+ >>> c3_ctype
+ >>> class I4(I):
+ ... pass
+ >>> directlyProvides(I4, IContentType)
+ >>> class C4:
+ ... implements(I4)
+ >>> obj4 = C4()
+ >>> c4_ctype = queryContentType(obj4)
+ >>> c4_ctype.__name__
+ 'I4'
+
+ """
+
+ object_iro = providedBy(object).__iro__
+ for iface in object_iro:
+ if IContentType.isImplementedBy(iface):
+ return iface
+
+ return None
+
+
+
+
=== Zope3/src/zope/app/content/configure.zcml 1.31 => 1.32 ===
--- Zope3/src/zope/app/content/configure.zcml:1.31 Tue Dec 16 10:42:00 2003
+++ Zope3/src/zope/app/content/configure.zcml Thu Dec 18 11:32:03 2003
@@ -7,6 +7,11 @@
<!-- Simple Folder Directives -->
+<interface
+ interface="zope.app.interfaces.content.folder.IFolder"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.folder.Folder">
<implements interface="zope.app.interfaces.container.IContentContainer" />
@@ -74,6 +79,11 @@
title="[add-images-permission] Add Images"
/>
+<interface
+ interface="zope.app.interfaces.content.image.IImage"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.image.Image">
<factory
@@ -104,8 +114,13 @@
provides="zope.app.interfaces.size.ISized"
for="zope.app.interfaces.content.image.IImage"
/>
+<interface
+ interface="zope.app.content.i18nimage.II18nImage"
+ type="zope.app.interfaces.content.IContentType"
+ />
<content class="zope.app.content.i18nimage.I18nImage">
+
<factory
id="I18nImage"
permission="zope.ManageContent"
@@ -133,7 +148,13 @@
</content>
+<interface
+ interface="zope.app.interfaces.content.zpt.IZPTPage"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.zpt.ZPTPage">
+
<factory
id="ZPTPage"
permission="zope.ManageContent"
@@ -188,6 +209,11 @@
provides="zope.app.interfaces.size.ISized"
for="zope.app.interfaces.content.zpt.IZPTPage" />
+<interface
+ interface="zope.app.interfaces.content.dtmlpage.IDTMLPage"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.dtmlpage.DTMLPage">
<factory
@@ -220,6 +246,11 @@
/>
+<interface
+ interface="zope.app.interfaces.content.file.IFile"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.file.File">
<factory
@@ -258,6 +289,10 @@
permission="zope.ManageContent"
/>
+<interface
+ interface="zope.app.content.i18nfile.II18nFile"
+ type="zope.app.interfaces.content.IContentType"
+ />
<content class="zope.app.content.i18nfile.I18nFile">
@@ -296,9 +331,13 @@
title="[add-sql-scripts-permission] Add SQL Scripts"
/>
+<interface
+ interface="zope.app.interfaces.content.sql.ISQLScript"
+ type="zope.app.interfaces.content.IContentType"
+ />
+
<content class="zope.app.content.sql.SQLScript">
-
<require
permission = "zope.ManageContent"
interface = "zope.app.interfaces.content.sql.ISQLScript"
@@ -334,7 +373,7 @@
<!-- Filesystem Synchronization -->
- <!-- fssync:adapter directives -->
+<!-- fssync:adapter directives -->
<fssync:adapter factory="zope.app.fssync.classes.Default" />
More information about the Zope3-Checkins
mailing list