Changeset 3366
- Timestamp:
- 07/25/07 10:47:36 (1 year ago)
- Files:
-
- branches/1.0/apigen/apigen/command.py (modified) (2 diffs)
- branches/1.0/apigen/setup.py (modified) (1 diff)
- branches/1.0/codename.py (modified) (1 diff)
- branches/1.0/ez_setup.py (modified) (1 diff)
- branches/1.0/thirdparty/externals.py (modified) (1 diff)
- branches/1.0/turbogears/command/i18n.py (modified) (11 diffs)
- branches/1.0/turbogears/command/info.py (modified) (2 diffs)
- branches/1.0/turbogears/command/quickstart.py (modified) (1 diff)
- branches/1.0/turbogears/config.py (modified) (8 diffs)
- branches/1.0/turbogears/database.py (modified) (6 diffs)
- branches/1.0/turbogears/docgen.py (modified) (21 diffs)
- branches/1.0/turbogears/feed/feed.py (modified) (1 diff)
- branches/1.0/turbogears/i18n/format.py (modified) (7 diffs)
- branches/1.0/turbogears/i18n/__init__.py (modified) (1 diff)
- branches/1.0/turbogears/i18n/sogettext/__init__.py (modified) (3 diffs)
- branches/1.0/turbogears/i18n/utils.py (modified) (2 diffs)
- branches/1.0/turbogears/identity/conditions.py (modified) (2 diffs)
- branches/1.0/turbogears/identity/exceptions.py (modified) (2 diffs)
- branches/1.0/turbogears/identity/soprovider.py (modified) (21 diffs)
- branches/1.0/turbogears/identity/tests/test_identity.py (modified) (8 diffs)
- branches/1.0/turbogears/identity/visitor.py (modified) (10 diffs)
- branches/1.0/turbogears/paginate.py (modified) (2 diffs)
- branches/1.0/turbogears/scheduler.py (modified) (16 diffs)
- branches/1.0/turbogears/startup.py (modified) (7 diffs)
- branches/1.0/turbogears/tests/catwalk_models/browse.py (modified) (2 diffs)
- branches/1.0/turbogears/tests/catwalk_models/model_list.py (modified) (1 diff)
- branches/1.0/turbogears/tests/catwalk_models/model_structure.py (modified) (1 diff)
- branches/1.0/turbogears/tests/catwalk_models/single_join.py (modified) (1 diff)
- branches/1.0/turbogears/tests/test_catwalk.py (modified) (7 diffs)
- branches/1.0/turbogears/tests/test_config.py (modified) (3 diffs)
- branches/1.0/turbogears/tests/test_database.py (modified) (2 diffs)
- branches/1.0/turbogears/tests/test_decorator.py (modified) (1 diff)
- branches/1.0/turbogears/tests/test_errorhandling.py (modified) (1 diff)
- branches/1.0/turbogears/tests/test_expose.py (modified) (2 diffs)
- branches/1.0/turbogears/tests/test_form_controllers.py (modified) (4 diffs)
- branches/1.0/turbogears/tests/test_sqlalchemy.py (modified) (3 diffs)
- branches/1.0/turbogears/tests/test_testutil.py (modified) (2 diffs)
- branches/1.0/turbogears/tests/test_validators.py (modified) (1 diff)
- branches/1.0/turbogears/tests/test_view.py (modified) (2 diffs)
- branches/1.0/turbogears/toolbox/admi18n/catalog.py (modified) (7 diffs)
- branches/1.0/turbogears/toolbox/admi18n/__init__.py (modified) (11 diffs)
- branches/1.0/turbogears/toolbox/admi18n/msgfmt.py (modified) (1 diff)
- branches/1.0/turbogears/toolbox/admi18n/pygettext.py (modified) (2 diffs)
- branches/1.0/turbogears/toolbox/base.py (modified) (5 diffs)
- branches/1.0/turbogears/toolbox/catwalk/browse.py (modified) (11 diffs)
- branches/1.0/turbogears/toolbox/catwalk/__init__.py (modified) (1 diff)
- branches/1.0/turbogears/toolbox/designer/__init__.py (modified) (18 diffs)
- branches/1.0/turbogears/toolbox/shell.py (modified) (5 diffs)
- branches/1.0/turbogears/util.py (modified) (1 diff)
- branches/1.0/turbogears/validators.py (modified) (6 diffs)
- branches/1.0/turbogears/visit/api.py (modified) (1 diff)
- branches/1.0/turbogears/visit/savisit.py (modified) (1 diff)
- branches/1.0/turbogears/visit/sovisit.py (modified) (1 diff)
- branches/1.0/turbogears/widgets/base.py (modified) (27 diffs)
- branches/1.0/turbogears/widgets/big_widgets.py (modified) (3 diffs)
- branches/1.0/turbogears/widgets/forms.py (modified) (1 diff)
- branches/1.0/turbogears/widgets/i18n.py (modified) (2 diffs)
- branches/1.0/turbogears/widgets/links.py (modified) (11 diffs)
- branches/1.0/turbogears/widgets/meta.py (modified) (8 diffs)
- branches/1.0/turbogears/widgets/rpc.py (modified) (1 diff)
- branches/1.0/turbogears/widgets/tests/test_datagrid.py (modified) (3 diffs)
- branches/1.0/turbogears/widgets/tests/test_link_inclusion.py (modified) (2 diffs)
- branches/1.0/turbogears/widgets/tests/test_nested_form_controllers.py (modified) (1 diff)
- branches/1.0/turbogears/widgets/tests/test_nested_widgets.py (modified) (1 diff)
- branches/1.0/turbogears/widgets/tests/test_new_validation.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/apigen/apigen/command.py
r1484 r3366 76 76 h2.text = "Subpackages" 77 77 dl = ET.SubElement(body, "dl") 78 78 79 79 for p in packages: 80 80 dt = ET.SubElement(dl, "dt") … … 90 90 h2.text = "Modules" 91 91 dl = ET.SubElement(body, "dl") 92 92 93 93 for f in files: 94 94 f = os.path.splitext(f)[0] branches/1.0/apigen/setup.py
r1325 r3366 43 43 test_suite = 'nose.collector', 44 44 ) 45 branches/1.0/codename.py
r1097 r3366 1 1 #!/usr/bin/env python 2 names = ["aces", "astonishing", "astounding", 3 "best", "breathtaking", "cool", 4 "doozie", "extravagant", "fab", "fantastic", 5 "groovy", 2 names = ["aces", "astonishing", "astounding", 3 "best", "breathtaking", "cool", 4 "doozie", "extravagant", "fab", "fantastic", 5 "groovy", 6 6 "immense", "in spades", "inconceivable", 7 "legendary", "marvelous", "mind-blowing", "out-of-this-world", 8 "outrageous", "phenomenal", "primo", "prodigious", 9 "remarkable", "spectacular", "striking", 10 "super", "superb", "terrific", "top drawer", "tops", "turn-on", 7 "legendary", "marvelous", "mind-blowing", "out-of-this-world", 8 "outrageous", "phenomenal", "primo", "prodigious", 9 "remarkable", "spectacular", "striking", 10 "super", "superb", "terrific", "top drawer", "tops", "turn-on", 11 11 "unbelievable", "wicked", "wondrous"] 12 12 branches/1.0/ez_setup.py
r2571 r3366 222 222 else: 223 223 main(sys.argv[1:]) 224 225 226 227 228 branches/1.0/thirdparty/externals.py
r3227 r3366 46 46 print "You must run this script from the thirdparty directory." 47 47 sys.exit(1) 48 48 49 49 for proj in externals: 50 50 if os.path.exists(proj): branches/1.0/turbogears/command/i18n.py
r3358 r3366 55 55 # why this isn't working with the config=True from above !?!! 56 56 self.config = True 57 57 58 58 parser = optparse.OptionParser(usage=""" 59 59 %prog [options] <command> … … 90 90 action="store", dest="js_support", 91 91 help="Extract messages from js-files.") 92 parser.add_option("", "--js-base-dir", 92 parser.add_option("", "--js-base-dir", 93 93 action="store", dest="js_base_dir", 94 94 default="static/javascript", … … 108 108 if self.config: 109 109 load_project_config() 110 110 111 111 if turbogears.config.get("i18n.locale_dir"): 112 112 self.locale_dir = turbogears.config.get("i18n.locale_dir") … … 118 118 if os.path.exists(self.locale_dir) and \ 119 119 not os.path.isdir(self.locale_dir): 120 raise ProgramError, \121 ('%s is not a directory' % self.locale_dir)120 raise ProgramError, \ 121 ('%s is not a directory' % self.locale_dir) 122 122 123 123 if not os.path.exists(self.locale_dir): … … 193 193 """ % locale 194 194 footer = """ 195 ];195 ]; 196 196 197 197 for(var i in _messages) { … … 235 235 else: 236 236 print "File %s exists, use --force to override" % targetfile 237 237 238 238 239 239 def _copy_moduletranslation(self, sourcefile, targetdir, language): … … 267 267 268 268 self._copy_file_withcheck(potfile, catalog_file) 269 270 271 272 269 270 271 272 273 273 def scan_source_files(self): 274 274 source_files = [] … … 354 354 if el.tail is not None: 355 355 ents.append((False, el.tail.strip())) 356 if el.attrib: 356 if el.attrib: 357 357 ents.extend((True, v) for v in el.attrib.values()) 358 358 for is_attribute, k in ents: … … 391 391 for i, line in enumerate(open(fname)): 392 392 s = gettext_expr_re.search(line) 393 while s: 393 while s: 394 394 key = s.groupdict()['texta'] or s.groupdict()['textb'] 395 395 pos = s.end() … … 405 405 gettext_expr_re = re.compile(r"_\(('(?P<texta>[^']*)'|\"(?P<textb>[^\"]*)\")\)") 406 406 for fname in files: 407 print 'Working on', fname 407 print 'Working on', fname 408 408 k, m = self.get_strings_in_js(fname) 409 409 keys.extend(k) … … 419 419 420 420 421 422 421 422 423 423 def get_potfile_path(self): 424 424 return os.path.join(self.locale_dir, '%s.pot' % self.domain) branches/1.0/turbogears/command/info.py
r2793 r3366 3 3 4 4 entrypoints = {"tg-admin Commands" : "turbogears.command", 5 "Template Engines" : "python.templating.engines", 6 "Widget Packages" : "turbogears.widgets", 5 "Template Engines" : "python.templating.engines", 6 "Widget Packages" : "turbogears.widgets", 7 7 "TurboGears Extensions" : "turbogears.extensions", 8 8 "Identity Providers" : "turbogears.identity.provider", … … 13 13 def retrieve_info(): 14 14 """retrieve default and extension packages info""" 15 15 16 16 # get default packages 17 17 packages=['%s' % i for i in pkg_resources.require("Turbogears")] branches/1.0/turbogears/command/quickstart.py
r3343 r3366 321 321 if file == "empty": 322 322 os.remove(os.path.join(base, file)) 323 branches/1.0/turbogears/config.py
r3151 r3366 55 55 if level: 56 56 level = eval(level, logging.__dict__) 57 handler_obj.setLevel(level) 57 handler_obj.setLevel(level) 58 58 except KeyError: 59 59 raise ConfigError("No class specified for logging " … … 76 76 else: 77 77 log = logging.getLogger() 78 78 79 79 level = logger.get("level", None) 80 80 if level: … … 83 83 level = logging.NOTSET 84 84 log.setLevel(level) 85 85 86 86 propagate = logger.get("propagate", None) 87 87 if propagate is not None: 88 88 log.propagate = propagate 89 89 90 90 cfghandlers = logger.get("handlers", None) 91 91 if cfghandlers: … … 106 106 because CherryPy doesn't like it there. Here are some of the Python 107 107 examples converted to the format used here: 108 108 109 109 [logging] 110 110 [[loggers]] … … 122 122 formatter="form01" 123 123 args="(sys.stdout,)" 124 124 125 125 [[formatters]] 126 126 [[[form01]]] 127 127 format="F1 *(asctime)s *(levelname)s *(message)s" 128 128 datefmt= 129 130 129 130 131 131 One notable format difference is that *() is used in the formatter 132 132 instead of %() because %() is already used for config file … … 139 139 formatters = logcfg.get("formatters", {}) 140 140 _get_formatters(formatters) 141 141 142 142 handlers = logcfg.get("handlers", {}) 143 143 _get_handlers(handlers, formatters) 144 144 145 145 loggers = logcfg.get("loggers", {}) 146 146 _get_loggers(loggers, handlers) 147 147 148 148 del config["logging"] 149 149 config["global"]["tg.new_style_logging"] = True 150 150 151 def config_defaults(): 151 def config_defaults(): 152 152 current_dir_uri = os.path.abspath(os.getcwd()) 153 153 if not current_dir_uri.startswith("/"): … … 164 164 packagename = modulename[:lastdot] 165 165 top_level_package = modulename[:firstdot] 166 166 167 167 modname = modulename[lastdot+1:] 168 modfile = pkg_resources.resource_filename(packagename, 168 modfile = pkg_resources.resource_filename(packagename, 169 169 modname + ".cfg") 170 170 if not os.path.exists(modfile): 171 modfile = pkg_resources.resource_filename(packagename, 171 modfile = pkg_resources.resource_filename(packagename, 172 172 modname) 173 173 if os.path.isdir(modfile): … … 200 200 """Updates the system configuration either from a ConfigObj 201 201 (INI-style) config file, a module name specified in dotted notation 202 or both (the module name is assumed to have a ".cfg" extension). 203 If both are specified, the module is called first, 202 or both (the module name is assumed to have a ".cfg" extension). 203 If both are specified, the module is called first, 204 204 followed by the config file. This means that the config file's options 205 205 override the options in the module file.""" branches/1.0/turbogears/database.py
r3325 r3366 85 85 def _mysql_timestamp_converter(raw): 86 86 """Convert a MySQL TIMESTAMP to a floating point number representing 87 the seconds since the Un*x Epoch. It uses custom code the input seems 88 to be the new (MySQL 4.1+) timestamp format, otherwise code from the 87 the seconds since the Un*x Epoch. It uses custom code the input seems 88 to be the new (MySQL 4.1+) timestamp format, otherwise code from the 89 89 MySQLdb module is used.""" 90 90 if raw[4] == '-': … … 93 93 import MySQLdb.converters 94 94 return MySQLdb.converters.mysql_timestamp_converter(raw) 95 95 96 96 97 97 class AutoConnectHub(ConnectionHub): … … 119 119 120 120 def _enable_timestamp_workaround(self, connection): 121 """Enable a workaround for an incompatible timestamp format change 122 in MySQL 4.1 when using an old version of MySQLdb. See trac ticket 121 """Enable a workaround for an incompatible timestamp format change 122 in MySQL 4.1 when using an old version of MySQLdb. See trac ticket 123 123 #1235 - http://trac.turbogears.org/ticket/1235 for details.""" 124 124 # precondition: connection is a MySQLConnection … … 129 129 conversions[MySQLdb.constants.FIELD_TYPE.TIMESTAMP] = \ 130 130 _mysql_timestamp_converter 131 # There is no method to use custom keywords when using 131 # There is no method to use custom keywords when using 132 132 # "connectionForURI" in sqlobject so we have to insert the 133 133 # conversions afterwards. … … 261 261 class AutoConnectHub(object): 262 262 pass 263 263 264 264 class PackageHub(object): 265 265 pass … … 395 395 if columns is None: 396 396 columns = {} 397 columns.update(filter(lambda i: i[0] != 'childName', 397 columns.update(filter(lambda i: i[0] != 'childName', 398 398 sqlclass.sqlmeta.columns.items())) 399 399 if sqlclass._inheritable: branches/1.0/turbogears/docgen.py
r1863 r3366 13 13 class GenSite(Command): 14 14 "setuptools command to generate the TurboGears website" 15 15 16 16 user_options = [ 17 17 ("srcdirs=", "s", "directories containing the source files (default: docs)"), … … 27 27 ("eggdir=", "g", "which directory has the eggs in it (default: '../thirdparty/eggs')") 28 28 ] 29 29 30 30 boolean_options=["force"] 31 31 32 32 srcdirs = None 33 33 destdir = "dist/site" … … 41 41 eggdir = "../thirdparty/eggs" 42 42 noprintable = False 43 43 44 44 def initialize_options(self): 45 45 pass 46 46 47 47 def finalize_options(self): 48 48 if self.srcdirs is None: … … 62 62 self.ensure_string_list("nodelete") 63 63 self.ensure_string_list("ignorefiles") 64 64 65 65 regexes = [] 66 66 for pat in self.ignorefiles: 67 67 regexes.append(re.compile(pat)) 68 68 self.ignorepatterns = regexes 69 69 70 70 self.templates, self.templates_order = self._split_mapping(self.templates, True) 71 71 self.copydirs = self._split_mapping(self.copydirs) 72 72 73 73 def _split_mapping(self, valToSplit, preserve_order=False): 74 74 mapping = {} … … 83 83 return mapping, order 84 84 return mapping 85 85 86 86 def check_if_newer(self, src, dest): 87 87 srcmtime = os.path.getmtime(src) … … 91 91 destmtime = 0 92 92 return srcmtime > destmtime 93 93 94 94 def copy_if_newer(self, src, dest): 95 95 if self.force or self.check_if_newer(src, dest): … … 98 98 os.makedirs(d) 99 99 self.copy_file(src, dest) 100 100 101 101 def render_template(self, src, dest, depth): 102 102 if not self.force and not self.check_if_newer(src, dest): … … 107 107 log.info("skipping rendering %s" % dest) 108 108 return 109 109 110 110 template = kid.load_template(src, cache=False) 111 111 template.Template.serializer = self.serializer … … 119 119 destfile.write(output) 120 120 destfile.close() 121 121 122 122 def update_site_files(self, srcdir, processTemplates = True, destroot=None): 123 123 if not destroot: … … 140 140 else: 141 141 log.info("skipping creating directory %s" % (destdir)) 142 142 143 143 for file in files: 144 144 ignore = False … … 150 150 if ignore: 151 151 continue 152 152 153 153 for tempfile in self.templates.values(): 154 154 if tempfile == abs: … … 157 157 if ignore: 158 158 continue 159 159 160 160 ext = os.path.splitext(file)[1] 161 161 dest = os.path.join(destdir, file) 162 162 self.currentfiles.add(dest) 163 163 if not processTemplates or ext != ".html": 164 self.copy_if_newer(os.path.join(root, file), 164 self.copy_if_newer(os.path.join(root, file), 165 165 dest) 166 166 else: 167 self.render_template(os.path.join(root, file), 167 self.render_template(os.path.join(root, file), 168 168 dest, depth) 169 169 … … 193 193 log.info("creating %s" % destdir) 194 194 os.makedirs(destdir) 195 195 196 196 for name in self.templates_order: 197 197 filename = self.templates[name] 198 198 log.info("template %s loaded as %s" % (filename, name)) 199 199 kid.load_template(filename, name=name) 200 200 201 201 if self.eggdir: 202 202 if not self.eggdir.endswith("/"): … … 214 214 for dest, src in self.copydirs.items(): 215 215 if os.path.isdir(src): 216 self.update_site_files(src, processTemplates=False, 216 self.update_site_files(src, processTemplates=False, 217 217 destroot=os.path.join(self.destdir, dest)) 218 218 else: … … 222 222 self.printable_tutorial() 223 223 self.delete_excess_files() 224 224 225 225 def printable_tutorial(self): 226 226 if self.noprintable: … … 228 228 self._make_printable(os.path.join("docs", "tutorials", "wiki20"), 3) 229 229 self._make_printable(os.path.join("docs", "wiki20")) 230 230 231 231 def _make_printable(self, tutdir, up_to_root=2): 232 232 endpath = tutdir … … 239 239 <meta content="text/html; charset=UTF-8" http-equiv="content-type" /> 240 240 <link rel="stylesheet" type="text/css" href="../../default.css" py:attrs="href=root+'default.css'"/> 241 <link type="text/css" rel="stylesheet" href="../../sh/SyntaxHighlighter.css" py:attrs="href=root+'sh/SyntaxHighlighter.css'"></link> 241 <link type="text/css" rel="stylesheet" href="../../sh/SyntaxHighlighter.css" py:attrs="href=root+'sh/SyntaxHighlighter.css'"></link> 242 242 <title>TurboGears: 20 Minute Wiki Tutorial</title> 243 243 </head> … … 257 257 bodytext = bodytext.replace('<html:body xmlns:html="http://www.w3.org/1999/xhtml">', "") 258 258 masterdoc += bodytext 259 259 260 260 masterdoc += """<script src="../../sh/shCore.js" py:attrs="src=root+'sh/shCore.js'"></script> 261 261 <script src="../../sh/shBrushPython.js" py:attrs="src=root+'sh/shBrushPython.js'"></script> … … 263 263 <script src="../../sh/shBrushJScript.js" py:attrs="src=root+'sh/shBrushJScript.js'"></script> 264 264 <script language="javascript"> 265 dp.SyntaxHighlighter.HighlightAll('code');265 dp.SyntaxHighlighter.HighlightAll('code'); 266 266 </script> 267 267 </body></html>""" … … 269 269 template = kid.Template(source=masterdoc, root="../" * up_to_root) 270 270 template.serializer = self.serializer 271 271 272 272 destend = os.path.join(self.destdir, endpath) 273 273 if not os.path.exists(destend): … … 281 281 outfile.close() 282 282 self.currentfiles.add(outfn) 283 branches/1.0/turbogears/feed/feed.py
r2372 r3366 20 20 date = date.strftime("%a, %d %b %Y %H:%M:%S GMT") 21 21 return date 22 22 23 23 def depr_entrys(self, feed): 24 24 if "entrys" in feed: branches/1.0/turbogears/i18n/format.py
r3076 r3366 1 1 """ 2 2 Localized formatting functions. These functions extract localization data 3 from config files located in the data/directory. 3 from config files located in the data/directory. 4 4 """ 5 5 … … 29 29 if not is_locale_format(locale): 30 30 31 locale = locale[:2]31 locale = locale[:2] 32 32 33 33 name = "turbogears.i18n.data.%s" %locale … … 45 45 locale = get_locale(locale) 46 46 mod = get_locale_module(locale) 47 47 48 48 return getattr(mod, name, default) 49 49 … … 56 56 countries = get(locale, "countries", {}).items() 57 57 countries.sort(lambda x,y:cmp(x[1], y[1])) 58 return countries 58 return countries 59 59 60 60 def get_country(key, locale=None): … … 73 73 languages = get(locale, "languages", {}).items() 74 74 languages.sort(lambda x,y:cmp(x[1], y[1])) 75 return languages 75 return languages 76 76 77 77 def get_language(key, locale=None): … … 133 133 def format_decimal(value, num_places, locale=None): 134 134 """ 135 Returns number formatted with grouping for thousands and correct 135 Returns number formatted with grouping for thousands and correct 136 136 notation, e.g. 5000000.898>5,000,000.898 137 137 """ 138 138 139 139 format = "%%.%df"%num_places 140 str = format%value 140 str = format%value 141 141 num, decimals = str.split(".") 142 142 return unicode( … … 220 220 'abbrdayname':get_abbr_weekday_names(locale)[weekday], 221 221 } 222 branches/1.0/turbogears/i18n/__init__.py
r3294 r3366 12 12 format_decimal, format_currency, parse_number, parse_decimal 13 13 from turbogears.i18n.kidutils import translate, i18n_filter 14 branches/1.0/turbogears/i18n/sogettext/__init__.py
r3076 r3366 49 49 results = TG_Message.selectBy(domain=domain) 50 50 for message in results: 51 locale = message.locale 51 locale = message.locale 52 52 messages = catalog.get(locale, {}) 53 53 messages[message.name] = message.text … … 85 85 for k, v in catalog.items(): 86 86 87 TG_Message(domain=domain, locale=locale, name=k, text=v) 88 87 TG_Message(domain=domain, locale=locale, name=k, text=v) 88 89 89 def dump_so_catalogs(locales): 90 """Takes all domains and messages and creates message catalogs 90 """Takes all domains and messages and creates message catalogs 91 91 """ 92 92 localedir = turbogears.config.get("i18n.locale_dir", "locales") … … 128 128 129 129 f.close() 130 branches/1.0/turbogears/i18n/utils.py
r1960 r3366 60 60 if not request_available(): 61 61 return config.get("i18n.default_locale", "en") 62 62 63 63 if config.get("session_filter.on", False): 64 64 locale_key = config.get("i18n.session_key", "locale") … … 89 89 """ 90 90 cherrypy.session[config.get("i18n.session_key", "locale")] = locale 91 92 93 branches/1.0/turbogears/identity/conditions.py
r2845 r3366 233 233 if predicate is None or \ 234 234 predicate.eval_with_object(current, errors): 235 return fn(self, *args, **kwargs)235 return fn(self, *args, **kwargs) 236 236 except IdentityException, e: 237 237 errors= [str(e)] … … 254 254 if predicate is None or \ 255 255 predicate.eval_with_object( current, errors ): 256 return fn( self, *args, **kwargs )256 return fn( self, *args, **kwargs ) 257 257 except IdentityException, e: 258 258 errors= [str(e)] branches/1.0/turbogears/identity/exceptions.py
r2250 r3366 28 28 "outside of a request." 29 29 30 30 31 31 class IdentityManagementNotEnabledException(IdentityException): 32 32 """ User forgot to enable Identity management """ 33 33 34 34 def __str__(self): 35 35 return "An attempt was made to use a facility of the TurboGears " \ 36 36 "Identity Management framework but identity management hasn't " \ 37 37 "been enabled in the config file [via identity.on]." 38 39 38 39 40 40 class IdentityConfigurationException(IdentityException): 41 41 ''' … … 46 46 def __init__(self, message): 47 47 self.message= message 48 48 49 49 def __str__(self): 50 50 return self.message branches/1.0/turbogears/identity/soprovider.py
r2826 r3366 39 39 self.old_name= old_name 40 40 self.new_name= new_name 41 41 42 42 def __get__(self, obj, type=None): 43 43 warnings.warn( "%s has been deprecated in favour of %s" % … … 50 50 return setattr( obj, self.new_name, value ) 51 51 52 52 53 53 # Global class references -- these will be set when the Provider is initialised. 54 54 user_class= None … … 62 62 self._user= user 63 63 self.visit_key= visit_key 64 64 65 65 def _get_user(self): 66 66 try: … … 85 85 return None 86 86 user= property(_get_user) 87 87 88 88 def _get_user_name(self): 89 89 if not self.user: … … 95 95 return not self.user 96 96 anonymous= property(_get_anonymous) 97 97 98 98 def _get_permissions(self): 99 99 try: … … 108 108 return self._permissions 109 109 permissions= property(_get_permissions) 110 110 111 111 def _get_groups(self): 112 112 try: … … 139 139 identity.set_current_identity( anon ) 140 140 141 141 142 142 class SqlObjectIdentityProvider(object): 143 143 ''' 144 144 IdentityProvider that uses a model from a database (via SQLObject). 145 145 ''' 146 146 147 147 def __init__(self): 148 148 super(SqlObjectIdentityProvider, self).__init__() 149 149 get=turbogears.config.get 150 150 151 151 global user_class, group_class, permission_class, visit_class 152 153 user_class_path= get( "identity.soprovider.model.user", 152 153 user_class_path= get( "identity.soprovider.model.user", 154 154 __name__ + ".TG_User" ) 155 155 #log.debug('userclassp:%s'% user_class_path) … … 168 168 if group_class: 169 169 log.info("Succesfully loaded \"%s\"" % group_class_path) 170 170 171 171 permission_class_path= get( "identity.soprovider.model.permission", 172 172 __name__ + ".TG_Permission" ) … … 174 174 if permission_class: 175 175 log.info("Succesfully loaded \"%s\"" % permission_class_path) 176 176 177 177 visit_class_path= get( "identity.soprovider.model.visit", 178 178 __name__ + ".TG_VisitIdentity" ) … … 180 180 if visit_class: 181 181 log.info("Succesfully loaded \"%s\"" % visit_class_path) 182 183 182 183 184 184 # Default encryption algorithm is to use plain text passwords 185 185 algorithm = get("identity.soprovider.encryption_algorithm", None) 186 186 self.encrypt_password = lambda pw: \ 187 187 identity._encrypt_password(algorithm, pw) 188 188 189 189 def create_provider_model( self ): 190 190 # create the database tables … … 205 205 Look up the identity represented by user_name and determine whether the 206 206 password is correct. 207