~jbaker/storm/nose_plugin

« back to all changes in this revision

Viewing changes to storm/expr.py

  • Committer: Gustavo Niemeyer
  • Date: 2006-06-01 02:42:53 UTC
  • Revision ID: gustavo@niemeyer.net-20060601024253-a75ab5c2391b237d
- Created exception hierarchy, and patched DBAPI2 modules to include
  Storm exceptions as bases for their exceptions.
- Added new finer-grained exceptions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from copy import copy
11
11
import sys
12
12
 
 
13
from storm.exceptions import CompileError, NoTableError
13
14
from storm.variables import Variable
14
15
from storm import Undef
15
16
 
17
18
# --------------------------------------------------------------------
18
19
# Basic compiler infrastructure
19
20
 
20
 
class CompileError(Exception):
21
 
    pass
22
 
 
23
21
class Compile(object):
24
22
    """Compiler based on the concept of generic functions."""
25
23
 
59
57
                    statement = "(%s)" % statement
60
58
                return statement
61
59
        else:
62
 
            raise CompileError("Don't know how to compile %r"
63
 
                               % expr.__class__)
 
60
            raise CompileError("Don't know how to compile %r" % expr.__class__)
64
61
 
65
62
    def _compile(self, state, expr, join=", "):
66
63
        outer_precedence = state.precedence
276
273
        return ", ".join(tables)
277
274
    elif expr.default_tables is not Undef:
278
275
        return compile(state, expr.default_tables)
279
 
    raise CompileError("Couldn't find any tables")
 
276
    raise NoTableError("Couldn't find any tables")
280
277
 
281
278
def build_table(compile, state, expr):
282
279
    if expr.table is not Undef:
290
287
        return ", ".join(tables)
291
288
    elif expr.default_table is not Undef:
292
289
        return compile(state, expr.default_table)
293
 
    raise CompileError("Couldn't find any table")
 
290
    raise NoTableError("Couldn't find any table")
294
291
 
295
292
 
296
293
class Select(Expr):