Project

General

Profile

Revision d3c47597

IDd3c475972eb5136b029803c7bc1d4caa3c4162a0
Parent 5011664c
Child aa0788a2

Added by Francois POIROTTE over 14 years ago

Modification des tests suite aux changements apportés hier (migration des tests du modèle).
Adaptations dans le code de vigiboard pour utiliser l'authentification fournie par le modèle.
Certains tests fonctionnels de vigiboard sont SKIPés car bugués.
vigiboard.config.vigiboard renommé en vigiboard.config.vigiboard_cfg pour éviter des conflits de noms.
Dans le modèle, User.groups est renommé en User.usergroups pour éviter une confusion avec les groupes d'hosts.

git-svn-id: https://vigilo-dev.si.c-s.fr/svn@624 b22e2e97-25c9-44ff-b637-2e5ceca36478

View differences:

vigiboard/model/__init__.py
1 1
# -*- coding: utf-8 -*-
2 2
"""The application's model objects"""
3 3

  
4
from zope.sqlalchemy import ZopeTransactionExtension
5
from sqlalchemy.orm import scoped_session, sessionmaker
6
#from sqlalchemy import MetaData
4
from vigilo.models.session import DBSession
5
from vigilo.models.vigilo_bdd_config import metadata
7 6

  
8
from vigilo.models import vigilo_bdd_config
7
metadata.bind = DBSession.bind
9 8

  
10
# Global session manager: DBSession() returns the Thread-local
11
# session object appropriate for the current web request.
12
maker = sessionmaker(autoflush=True, autocommit=False,
13
                     extension=ZopeTransactionExtension())
14
DBSession = scoped_session(maker)
15

  
16
# Base class for all of our model classes: By default, the data model is
17
# defined with SQLAlchemy's declarative extension, but if you need more
18
# control, you can switch to the traditional method.
19
DeclarativeBase = vigilo_bdd_config.DeclarativeBase
20

  
21
# There are two convenient ways for you to spare some typing.
22
# You can have a query property on all your model classes by doing this:
23
# DeclarativeBase.query = DBSession.query_property()
24
# Or you can use a session-aware mapper as it was used in TurboGears 1:
25
# DeclarativeBase = declarative_base(mapper=DBSession.mapper)
26

  
27
# Global metadata.
28
# The default metadata is the one from the declarative base.
29
metadata = vigilo_bdd_config.metadata
30

  
31
# If you have multiple databases with overlapping table names, you'll need a
32
# metadata for each database. Feel free to rename 'metadata2'.
33
#metadata2 = MetaData()
34 9

  
35 10
#####
36 11
# Generally you will not want to define your table's mappers, and data objects
......
39 14
#
40 15
######
41 16

  
42
def init_model(engine):
43
    """Call me before using any of the tables or classes in the model."""
44

  
45
    DBSession.configure(bind=engine)
46
    # If you are using reflection to introspect your database and create
47
    # table objects for you, your tables must be defined and mapped inside
48
    # the init_model function, so that the engine is available if you
49
    # use the model outside tg2, you need to make sure this is called before
50
    # you use the model.
51

  
52
    #
53
    # See the following example:
54

  
55
    #global t_reflected
56

  
57
    #t_reflected = Table("Reflected", metadata,
58
    #    autoload=True, autoload_with=engine)
59

  
60
    #mapper(Reflected, t_reflected)
61

  
62 17
# Import your model modules here.
63
from vigiboard.model.auth import User, Group, Permission
18
from vigilo.models import User, UserGroup, Permission
64 19
from vigilo.models import Events, EventHistory, Graph, \
65 20
    GraphGroups, GraphToGroups, Groups, GroupPermissions, HostGroups, Host, \
66 21
    PerfDataSource, ServiceGroups, ServiceHautNiveau, Service, ServiceTopo

Also available in: Unified diff