Package rrlog :: Module environment
[hide private]
[frames] | no frames]

Source Code for Module rrlog.environment

 1  #Copyright (c) 2007 
 2  #        Ruben Reifenberg, Germany, 07381. 
 3  #    All rights reserved. 
 4  # 
 5  #Redistribution and use in source and binary forms, with or without 
 6  #modification, are permitted provided that the following conditions 
 7  #are met: 
 8  #1. Redistributions of source code must retain the above copyright 
 9  #   notice, this list of conditions and the following disclaimer as 
10  #   the first lines of this file unmodified. 
11  #2. Redistributions in binary form must reproduce the above copyright 
12  #   notice, this list of conditions and the following disclaimer in the 
13  #   documentation and/or other materials provided with the distribution. 
14  # 
15  # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 
16  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
17  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
18  # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 
19  # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
20  # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
21  # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
22  # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
23  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
24  # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
25  # SUCH DAMAGE. 
26   
27  """ 
28  constants about the environment (SQLAlchemy) available 
29  Purpose: provide compatibility with a wide SQLAlchemy version range 
30  @author: Ruben Reifenberg 
31  """ 
32   
33  try: 
34          import sqlalchemy 
35          sa_available = True 
36  except: 
37          sa_available = False 
38   
39  if sa_available: 
40          try: 
41                  v = sqlalchemy.__version__ 
42          except AttributeError: 
43                  # older 0.3.x has no __version__ attribute 
44                  # assume old 0.3.x. Not prepared for 0.2.x and older. 
45                  v = "0.3.x" 
46   
47          if v.startswith("0.3."): 
48                  # SA exactly 0.3.x 
49                  sa_v0_3_x = True 
50          else: 
51                  sa_v0_3_x = False 
52   
53          if v.startswith("0.3.") or v.startswith("0.4.") or v.startswith("0.5."): 
54                  # SA lower than 0.6.0 
55                  sa_lt_v0_6_0 = True 
56          else: 
57                  sa_lt_v0_6_0 = False 
58