Author: reebalazs
Date: Sun Nov 11 11:15:48 2007
New Revision: 48547
Added:
kukit/kss.zope/trunk/kss/zope/concatresource/
- copied from r48545,
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/
kukit/kss.zope/trunk/kss/zope/concatresource/meta.py
- copied, changed from r48546,
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/meta.py
Removed:
kukit/kss.zope/trunk/kss/core/concatresource.zcml
kukit/kss.zope/trunk/kss/zope/concatresource/fields.py
kukit/kss.zope/trunk/kss/zope/concatresource/kss.concatresource-configure.zcml
kukit/kss.zope/trunk/kss/zope/concatresource/kss.concatresource-meta.zcml
kukit/kss.zope/trunk/kss/zope/concatresource/version.txt
Modified:
kukit/kss.zope/trunk/kss/core/configure.zcml
kukit/kss.zope/trunk/kss/zope/concatresource/__init__.py
kukit/kss.zope/trunk/kss/zope/concatresource/cachingadapter.py
kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py
kukit/kss.zope/trunk/kss/zope/concatresource/directives.py
kukit/kss.zope/trunk/kss/zope/concatresource/fileresource.py
kukit/kss.zope/trunk/kss/zope/concatresource/interfaces.py
kukit/kss.zope/trunk/kss/zope/concatresource/meta.zcml
kukit/kss.zope/trunk/kss/zope/concatresource/resource.py
kukit/kss.zope/trunk/kss/zope/configure.zcml
Log:
Relocate concatresource zope part to kss.zope, and clean up a bit.
(It does not yet reuse kss base.)
Deleted: /kukit/kss.zope/trunk/kss/core/concatresource.zcml
==============================================================================
--- /kukit/kss.zope/trunk/kss/core/concatresource.zcml Sun Nov 11 11:15:48 2007
+++ (empty file)
@@ -1,41 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- xmlns:five="http://namespaces.zope.org/five">
-
- <!-- Add
-
- caching="memory"
-
- to cache concatenation of kukit.js -->
-
- <!--
-
- Available values for compress_level in javascript:
-
- - none: the raw sources
- - devel: like none but the ;;;-s themselves are removed
- - stripped: the production version unpacked, readable
- - safe-devel: safe packing, devel version
- - safe: safe packing of the production version
- - full-devel: full packing, devel version
- - full: full packing of the production version
-
- -->
-
- <!-- Production version -->
- <browser:concatresource
- files=""
- name="kukit.js"
- compress_level="safe"
- />
-
- <!-- Development version -->
- <browser:concatresource
- files=""
- name="kukit-devel.js"
- compress_level="devel"
- caching="memory"
- lmt_check_period="5"
- />
-
-</configure>
Modified: kukit/kss.zope/trunk/kss/core/configure.zcml
==============================================================================
--- kukit/kss.zope/trunk/kss/core/configure.zcml (original)
+++ kukit/kss.zope/trunk/kss/core/configure.zcml Sun Nov 11 11:15:48 2007
@@ -9,10 +9,6 @@
<!-- This include MUST come first! -->
<include package=".pluginregistry"/>
- <!-- The next file defines all the default components -->
- <!-- XXX edit that file to enable javascript debugging support -->
- <include file="concatresource.zcml" />
-
<!-- Include the core plugins -->
<include package=".plugins" />
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/__init__.py
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/__init__.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/__init__.py Sun Nov 11
11:15:48 2007
@@ -1,11 +1 @@
-'''\
-Product init
-'''
-# alias myself to python import root, directly
-try:
- import sys
- if not 'concatresource' in sys.modules:
- # only 1st import is aliased.
- sys.modules['concatresource'] = sys.modules[globals()['__name__']]
-except ImportError:
- pass
+#
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/cachingadapter.py
==============================================================================
---
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/cachingadapter.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/cachingadapter.py Sun Nov
11 11:15:48 2007
@@ -1,13 +1,7 @@
from time import time
from interfaces import ICachedResource
from zope.interface import implements
-
-try:
- from zope.datetime import rfc1123_date
-except ImportError:
- # Zope < 2.10
- from zope.app.datetimeutils import rfc1123_date
-
+from zope.datetime import rfc1123_date
class CachedResource(object):
'Adapts a ContextFile to a cached resource'
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py
==============================================================================
---
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/concatfileresource.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py Sun Nov
11 11:15:48 2007
@@ -8,34 +8,21 @@
from zope.interface import implements
from interfaces import IContextFile
-# we are aliased to Products, hence the following absolute import
-from concatresource.interfaces import IConcatResourceAddon
from fileresource import File
from compression import compress
import time
-import zope.component
-try:
- from zope.component.interfaces import ComponentLookupError
-except ImportError:
- # Zope < 2.10
- from zope.component.exceptions import ComponentLookupError
+import zope.component as capi
+from kss.zope.interfaces import IKSSPluginRegistry
-class ConcatFiles(object):
- '''A resource that concatenates files and compresses the result
+class KSSConcatFiles(object):
+ '''A resource that concatenates KSS files and compresses the result
It is also possible to extend the statically given list via
a utility.
'''
implements(IContextFile)
- def __init__(self, pathlist, name, compress_level, caching,
lmt_check_period):
- # Path is now a list.
- assert isinstance(pathlist, (list, tuple))
- # check all files, just to raise error if don't exist
- for path in pathlist:
- file(path, 'rb').close()
- #
- self.pathlist_base = pathlist
+ def __init__(self, name, compress_level, caching, lmt_check_period):
self.__name__ = name
self.compress_level = compress_level
self.caching = caching
@@ -45,31 +32,12 @@
self.fileslist_changed = None
self.fileslist = []
- def getPathList(self):
- 'Gets the extended pathlist'
- # we allow the list to be extended via an utility
- try:
- registry = zope.component.getUtility(IConcatResourceAddon,
self.__name__)
- except ComponentLookupError:
- extend = []
- else:
- extend = registry.getAddonFiles()
- pathlist = self.pathlist_base + extend
- return pathlist
-
def getFilesList(self):
'Gets the list of files'
- ## # XXX We have two choices:
- ## # 1. We only calculate the list once, on startup
- ## # that is, we suppose that the file resource is
- ## # called up after the extension reg has been finished
- ## # and that it never changes later.
- ## # 2. but it also could be like this to allow changes later:
- pathlist = self.getPathList()
+ # Use the kss plugin registry
+ registry = capi.getUtility(IKSSPluginRegistry)
+ pathlist = registry.javascripts()
if pathlist != self.pathlist:
- ##if not self.pathlist:
- ##pathlist = self.getPathList()
- # mark pathlist modification
self.pathlist = pathlist
self.fileslist_changed = time.time()
fileslist = self.fileslist = [File(path, self.__name__) for path
in pathlist]
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/directives.py
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/directives.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/directives.py Sun Nov 11
11:15:48 2007
@@ -1,21 +1,9 @@
-from zope.interface import Interface
-from zope.configuration.fields import GlobalObject, Tokens, Path, \
- PythonIdentifier, MessageID
-from zope.schema import TextLine, Text, Id, Choice, Float
-from fields import PathList
-from zope.app.component.metadirectives import IBasicViewInformation
+from zope.schema import TextLine, Choice, Float
from zope.app.publisher.browser.metadirectives import IBasicResourceInformation
-try:
- from zope.security.zcml import Permission
-except ImportError:
- # Zope < 2.10
- from zope.app.security.fields import Permission
-
-
-class IConcatResourceDirective(IBasicResourceInformation):
+class IKSSConcatResourceDirective(IBasicResourceInformation):
"""
- Defines a concatenated browser resource
+ Defines a concatenated browser resource for kss
"""
name = TextLine(
@@ -30,12 +18,6 @@
required=True
)
- files = PathList(
- title=u"Files",
- description=u"A space separated list of resource files",
- required=True
- )
-
compress_level = Choice(
title=u"Compress level",
description=u"Level of compression applied, by default 'safe'.",
@@ -58,5 +40,3 @@
to set this to 0, for production it can be left to the
default 60.0""",
required=False,
)
-
-
Deleted: /kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/fields.py
==============================================================================
--- /kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/fields.py
Sun Nov 11 11:15:48 2007
+++ (empty file)
@@ -1,19 +0,0 @@
-
-from zope.schema import Text
-from zope.schema.interfaces import IFromUnicode
-from zope.interface import implements
-import os.path
-
-class PathList(Text):
-
- implements(IFromUnicode)
-
- def fromUnicode(self, u):
- result = []
- for u in u.split():
- if os.path.isabs(u):
- path = os.path.normpath(u)
- else:
- path = self.context.path(u)
- result.append(path)
- return result
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/fileresource.py
==============================================================================
---
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/fileresource.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/fileresource.py Sun Nov
11 11:15:48 2007
@@ -6,15 +6,7 @@
'''
from zope.interface import implements
-try:
- from zope.contenttype import guess_content_type
-except ImportError: # BBB: Zope < 2.10
- try:
- # XXX ??? What zope version needs this?
- from zope.app.contenttypes import guess_content_type
- except ImportError:
- from zope.app.content_types import guess_content_type
-
+from zope.contenttype import guess_content_type
import os
from interfaces import IContextFile
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/interfaces.py
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/interfaces.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/interfaces.py Sun Nov 11
11:15:48 2007
@@ -22,20 +22,3 @@
def purgeData(self):
'Purges the cached data'
-
-class IConcatResourceAddon(Interface):
- '''Utility to register addons
-
- This can be used to dynamically extend components for a given resource.
- We don't provide implementation for this here, but other
- components can implement this to provide dynamic add-ons.
-
- The name of the utility should be the name of the resource.
- '''
-
- def getAddonFiles(request):
- '''Returns a list of addon files.
- This will be concatenated to the end of the static list.
- '''
-
-
Deleted:
/kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/kss.concatresource-configure.zcml
==============================================================================
---
/kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/kss.concatresource-configure.zcml
Sun Nov 11 11:15:48 2007
+++ (empty file)
@@ -1 +0,0 @@
-<include package="kss.concatresource" />
Deleted:
/kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/kss.concatresource-meta.zcml
==============================================================================
---
/kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/kss.concatresource-meta.zcml
Sun Nov 11 11:15:48 2007
+++ (empty file)
@@ -1 +0,0 @@
-<include package="kss.concatresource" file="meta.zcml" />
Copied: kukit/kss.zope/trunk/kss/zope/concatresource/meta.py (from r48546,
kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/meta.py)
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/meta.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/meta.py Sun Nov 11
11:15:48 2007
@@ -1,21 +1,19 @@
-import os
from zope.security.checker import CheckerPublic, NamesChecker
-from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.app.component.metaconfigure import handler
from zope.interface import Interface
-from resource import ConcatResourceFactory
+from resource import KSSConcatResourceFactory
try:
import Products.Five
+ Products.Five # satisfy pyflakes
except ImportError:
__five__ = False
else:
__five__ = True
from Products.Five.metaclass import makeClass
- from Products.Five.security import getSecurityInfo, protectClass,
protectName,\
- initializeClass
+ from Products.Five.security import protectClass, initializeClass
try:
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
@@ -28,6 +26,7 @@
try:
from zope.component import zcml
+ zcml # satisfy pyflakes
__pre_3_3__ = False
except:
__pre_3_3__ = True
@@ -39,24 +38,16 @@
# We keep this in order to allow an occasional merge to browser:resource
_factory_map = {
'files': {
- 'prefix': 'ConcatResource',
+ 'prefix': 'KSSConcatResource',
'count': 0,
- 'factory': ConcatResourceFactory
+ 'factory': KSSConcatResourceFactory
},
}
-def concatresource(_context, name, files=None, compress_level='safe',
+def concatresource(_context, name, compress_level='safe',
caching='default', lmt_check_period=60.0,
layer=_layer, permission='zope.Public'):
- #if not files:
- # raise ConfigurationError(
- # "Must use a files"
- # " attribute for concatresource directives, with at least"
- # " one file contained."
- # )
-
- res = files
res_type = 'files'
factory_info = _factory_map.get(res_type)
factory_info['count'] += 1
@@ -86,7 +77,7 @@
checker = NamesChecker(allowed_names, permission)
- factory = res_factory(res, name, compress_level, caching, lmt_check_period,
+ factory = res_factory(name, compress_level, caching, lmt_check_period,
resource_factory=new_class, checker=checker)
if __pre_3_2__:
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/meta.zcml
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/meta.zcml
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/meta.zcml Sun Nov 11
11:15:48 2007
@@ -2,11 +2,11 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
- <meta:directives namespace="http://namespaces.zope.org/browser">
+ <meta:directives namespace="http://namespaces.zope.org/kss">
<meta:directive
name="concatresource"
- schema=".directives.IConcatResourceDirective"
+ schema=".directives.IKSSConcatResourceDirective"
handler=".meta.concatresource"
/>
Modified: kukit/kss.zope/trunk/kss/zope/concatresource/resource.py
==============================================================================
--- kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/resource.py
(original)
+++ kukit/kss.zope/trunk/kss/zope/concatresource/resource.py Sun Nov 11
11:15:48 2007
@@ -1,32 +1,23 @@
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.interface import implements
-from concatfileresource import ConcatFiles
+from concatfileresource import KSSConcatFiles
from interfaces import ICachedResource
import cachingadapter # force adapter registration
-
-try:
- from zope.publisher.browser import BrowserView
- from zope.datetime import time as timeFromDateTimeString
-except ImportError:
- # Zope < 2.10
- from zope.app.publisher.browser import BrowserView
- from zope.app.datetimeutils import time as timeFromDateTimeString
+cachingadapter # satisfy pyflakes
+from zope.publisher.browser import BrowserView
+from zope.datetime import time as timeFromDateTimeString
try:
import Products.Five
+ Products.Five # satisfy pyflakes
except ImportError:
__five__ = False
from zope.app.publisher.browser.resource import Resource
+ Resource # satisfy pyflakes
else:
__five__ = True
- try:
- # Zope 2.8 / Five 1.0.2
- from Products.Five.resource import Resource
- __five_pre_1_3_ = True
- except ImportError:
- # Zope 2.9 / Five 1.3
- from Products.Five.browser.resource import Resource
- __five_pre_1_3__ = False
+ from Products.Five.browser.resource import Resource as _Resource
+ Resource = _Resource # satisfy pyflakes
class GenericResource(BrowserView, Resource):
"""A publishable resource"""
@@ -121,10 +112,9 @@
factory = None
resource = None
- def __init__(self, path, name, compress_level, caching, lmt_check_period,
+ def __init__(self, name, compress_level, caching, lmt_check_period,
resource_factory=None, checker=None):
self.__name = name
- self.__path = path
self.__compress_level = compress_level
self.__caching = caching
self.__lmt_check_period = lmt_check_period
@@ -138,7 +128,7 @@
rsrc = self.__rsrc
except AttributeError:
# Delayed creation. That assures that registry is set up by this
time.
- rsrc = self.__rsrc = ICachedResource(self.factory(self.__path,
self.__name,
+ rsrc = self.__rsrc = ICachedResource(self.factory(self.__name,
self.__compress_level, self.__caching,
self.__lmt_check_period))
resource = self.resource(rsrc, request)
# z3 only
@@ -148,8 +138,8 @@
resource.__Security_checker__ = self.__checker
return resource
-class ConcatResourceFactory(ResourceFactory):
+class KSSConcatResourceFactory(ResourceFactory):
"""A factory for concat resources"""
- factory = ConcatFiles
+ factory = KSSConcatFiles
resource = GenericResource
Deleted:
/kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/version.txt
==============================================================================
--- /kukit/kss.zope/trunk/kss/core/pluginregistry/_concatresource/version.txt
Sun Nov 11 11:15:48 2007
+++ (empty file)
@@ -1 +0,0 @@
-1.4dev Unreleased
Modified: kukit/kss.zope/trunk/kss/zope/configure.zcml
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/configure.zcml (original)
+++ kukit/kss.zope/trunk/kss/zope/configure.zcml Sun Nov 11 11:15:48 2007
@@ -1,6 +1,29 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:kss="http://namespaces.zope.org/kss"
+ >
+
+ <include package=".concatresource" />
<utility factory=".registry.GlobalPluginRegistry"
permission="zope.Public" />
+
+ <!-- Defining the kss concatenated javascript
+ as resources
+ -->
+
+ <!-- Production version -->
+ <kss:concatresource
+ name="kukit.js"
+ compress_level="safe"
+ />
+
+ <!-- Development version -->
+ <kss:concatresource
+ name="kukit-devel.js"
+ compress_level="devel"
+ caching="memory"
+ lmt_check_period="5"
+ />
+
</configure>
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins