Changeset 4688
- Timestamp:
- 06/08/08 10:05:27 (6 months ago)
- Files:
-
- projects/tgMochiKit/trunk/ChangeLog (added)
- projects/tgMochiKit/trunk/README.txt (modified) (2 diffs)
- projects/tgMochiKit/trunk/tgmochikit/base.py (modified) (4 diffs)
- projects/tgMochiKit/trunk/tgmochikit/__init__.py (modified) (1 diff)
- projects/tgMochiKit/trunk/tgmochikit/tests/test_tgmochikit.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/tgMochiKit/trunk/README.txt
r4684 r4688 121 121 This setting selects the version of the MochiKit library that the 122 122 ``turbogears.mochikit`` widget will use. tgMochiKit currently ships 123 with version 1.3.1 and a snapshotof the 1.4 development version.123 with version 1.3.1 and several snapshots of the 1.4 development version. 124 124 125 125 ``tg_mochikit.packed -- False`` … … 132 132 ``MochiKit.js`` file. 133 133 134 ``tg_mochikit.draganddrop -- False`` 135 Selects whether the ``turbogears.mochikit`` widget should include the 136 ``DragAndDrop.js`` file. 137 138 Version selection 139 ----------------- 140 141 The selection of a proper version of MochiKit is a bit more elaborated due to 142 the fact that MockiKit hasn't had a proper 1.4 release for a few years now. 143 144 tgMochiKit ships with various versions of MochKit. 145 146 - the stable 1.3.1 version, as used by the TurboGears 1.0.x series. 147 - various snapshots of the 1.4 version from the subversion. 148 - the ``trunk``, also a subversion snapshot, which reflects the 149 version inside trunk at the time of the tgMochiKit release you are using. 150 151 You can get the shipped versions by doing ::: 152 153 >>> import tgmochikit 154 >>> print tgmochikit.get_shipped_versions() 155 156 157 Now when using tgMochiKit, the problem of which version to chose arises. 158 159 If you want 1.3.1, just configure that as version to chose. 160 161 If you want a specific version that is shipped, configure that. This is the 162 safe course of action for you application, because by this you ensure that 163 even if you install newer versions of tgMochiKit (which might happen due 164 to TurboGears upgrades), you will end up with code you verified that it works. 165 166 If you feel confident that using the latest of MochiKit is ok for you, configure 167 ``tg_mochikit.version`` to be ``1.4``. This will always pick the newest from the 168 pack. 169 170 The ``trunk``-version is something special. In the shipped tgMochiKit it will always 171 be equal to the latest 1.4 version. 172 173 However, if you want the latest from trunk, you can simply 174 175 - check out tgMochiKit. This will fetch the latest from trunk into the distribution 176 - create your own tgMochiKit.egg, and use that for your application. 177 178 The version actually used by tgMochiKit based on your configuration is by the way 179 logged on the logger ``tgmochikit`` with level ``INFO`` with the text:: 180 181 Version chosen: <version> 134 182 135 183 Installation projects/tgMochiKit/trunk/tgmochikit/base.py
r4683 r4688 1 import pkg_resources 2 3 import os 1 4 import glob 2 import os5 import logging 3 6 4 import pkg_resources 7 logger = logging.getLogger(".".join(__name__.split(".")[:-1])) 5 8 6 9 VERSION = '1.3.1' … … 13 16 DRAGANDDROP = False 14 17 15 def init(register_static_directory, version=None, packed=None, xhtml=None, draganddrop=None):18 def init(register_static_directory, config={}, version=None, packed=None, xhtml=None, draganddrop=None): 16 19 """Initializes the MochiKit resources. 17 20 … … 32 35 if draganddrop is not None: 33 36 DRAGANDDROP = draganddrop 34 import turbogears.config35 37 INITIALIZED = True 36 PACKED = turbogears.config.get('tg_mochikit.packed', PACKED)37 VERSION = turbogears.config.get('tg_mochikit.version', VERSION)38 XHTML = turbogears.config.get('tg_mochikit.xhtml', XHTML)39 DRAGANDDROP = turbogears.config.get('tg_mochikit.draganddrop', DRAGANDDROP)38 PACKED = config.get('tg_mochikit.packed', PACKED) 39 VERSION = config.get('tg_mochikit.version', VERSION) 40 XHTML = config.get('tg_mochikit.xhtml', XHTML) 41 DRAGANDDROP = config.get('tg_mochikit.draganddrop', DRAGANDDROP) 40 42 41 js_dir = pkg_resources.resource_filename("tgmochikit", 42 "static/javascript/%s" % VERSION) 43 43 is_131 = '1.3.1' in VERSION 44 js_base_dir = pkg_resources.resource_filename("tgmochikit", 45 "static/javascript/") 46 # we check for all the versions in the js_base_dir and fetch the 47 # one that matches best. If several candidates exist, the best is the latest. 48 candidates = glob.glob(os.path.join(js_base_dir, "%s*" % VERSION)) 49 candidates.sort() 50 js_dir = candidates[-1] 51 logger.info("MochiKit version chosen: %s", os.path.basename(js_dir)) 44 52 path = os.path.join(js_dir, "unpacked", "*.js") 45 53 for name in glob.glob(path): … … 57 65 res.append("unpacked/%s" % submodule) 58 66 PATHS = res 59 if DRAGANDDROP :67 if DRAGANDDROP and not is_131: 60 68 PATHS.append("unpacked/DragAndDrop.js") 61 69 62 70 def get_paths(): 63 71 return PATHS 72 73 74 def get_shipped_versions(): 75 js_base_dir = pkg_resources.resource_filename("tgmochikit", 76 "static/javascript/") 77 return [os.path.basename(p) for p in glob.glob(os.path.join(js_base_dir, "*"))] 78 projects/tgMochiKit/trunk/tgmochikit/__init__.py
r4604 r4688 1 from tgmochikit.base import init, get_paths 1 from tgmochikit.base import init, get_paths, get_shipped_versions 2 2 3 3 __all__ = [ 4 4 "init", 5 "get_paths" 5 "get_paths", 6 "get_shipped_versions", 6 7 ]