- move table description to tables.py
- new sysuser class git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@220 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
		
							parent
							
								
									6b1c80899d
								
							
						
					
					
						commit
						bd306389f0
					
				
					 3 changed files with 96 additions and 19 deletions
				
			
		|  | @ -20,26 +20,10 @@ | |||
| # Version: $Id$ | ||||
| 
 | ||||
| from sqlalchemy import * | ||||
| from gnuviechadmin import gva_cfg | ||||
| from gnuviechadmin.tables import * | ||||
| from gnuviechadmin import sysuser | ||||
| from gnuviechadmin.exceptions import * | ||||
| 
 | ||||
| meta = BoundMetaData(gva_cfg.GVA_DBE) | ||||
| client_table = Table('clients', meta, | ||||
|                      Column('clientid', Integer, primary_key=True), | ||||
|                      Column('title', String(10)), | ||||
|                      Column('firstname', String(64), nullable=False), | ||||
|                      Column('lastname', String(64), nullable=False), | ||||
|                      Column('address1', String(64), nullable=False), | ||||
|                      Column('address2', String(64)), | ||||
|                      Column('zip', String(7), nullable=False), | ||||
|                      Column('city', String(64), nullable=False), | ||||
|                      Column('country', String(5), nullable=False), | ||||
|                      Column('phone', String(32), nullable=False), | ||||
|                      Column('mobile', String(32)), | ||||
|                      Column('fax', String(32)), | ||||
|                      Column('email', String(64), unique=True, nullable=False)) | ||||
| client_table.create(checkfirst=True) | ||||
| 
 | ||||
| class Client(object): | ||||
|     mandatory = ('firstname', 'lastname', 'address1', 'zip', 'city', | ||||
|                  'country', 'phone', 'email') | ||||
|  | @ -92,7 +76,9 @@ class Client(object): | |||
|             {'clientid' : self.clientid, 'firstname' : self.firstname, | ||||
|              'lastname' : self.lastname, 'email' : self.email}) | ||||
| 
 | ||||
| clientmapper = mapper(Client, client_table) | ||||
| clientmapper = mapper( | ||||
|     Client, client_table, | ||||
|     properties = {'sysusers': relation(sysuser.Sysuser)}) | ||||
| 
 | ||||
| def create(**kwargs): | ||||
|     try: | ||||
|  |  | |||
							
								
								
									
										34
									
								
								gnuviechadmin/sysuser.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								gnuviechadmin/sysuser.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| # -*- coding: UTF-8 -*- | ||||
| # | ||||
| # Copyright (C) 2007 by Jan Dittberner. | ||||
| # | ||||
| # This program is free software; you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation; either version 2 of the License, or | ||||
| # (at your option) any later version. | ||||
| # | ||||
| # This program is distributed in the hope that it will be useful, but | ||||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
| # General Public License for more details. | ||||
| # | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program; if not, write to the Free Software | ||||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||||
| # USA. | ||||
| # | ||||
| # Version: $Id$ | ||||
| 
 | ||||
| from sqlalchemy import * | ||||
| from gnuviechadmin.tables import * | ||||
| from gnuviechadmin.exceptions import * | ||||
| 
 | ||||
| class Sysuser(object): | ||||
|     def __repr__(self): | ||||
|         return "%(sysuserid)d,%(username)s,%(clientid)d,%(sysuid)d" % ({ | ||||
|             'sysuserid': self.sysuserid, | ||||
|             'username': self.username, | ||||
|             'clientid': self.clientid, | ||||
|             'sysuid': self.sysuid}) | ||||
| 
 | ||||
| sysusermapper = mapper(Sysuser, sysuser_table) | ||||
							
								
								
									
										57
									
								
								gnuviechadmin/tables.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								gnuviechadmin/tables.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,57 @@ | |||
| # -*- coding: UTF-8 -*- | ||||
| # | ||||
| # Copyright (C) 2007 by Jan Dittberner. | ||||
| # | ||||
| # This program is free software; you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation; either version 2 of the License, or | ||||
| # (at your option) any later version. | ||||
| # | ||||
| # This program is distributed in the hope that it will be useful, but | ||||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
| # General Public License for more details. | ||||
| # | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program; if not, write to the Free Software | ||||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||||
| # USA. | ||||
| # | ||||
| # Version: $Id$ | ||||
| 
 | ||||
| from sqlalchemy import * | ||||
| from gnuviechadmin import gva_cfg | ||||
| 
 | ||||
| meta = BoundMetaData(gva_cfg.GVA_DBE) | ||||
| client_table = Table( | ||||
|     'client', meta, | ||||
|     Column('clientid', Integer, primary_key=True), | ||||
|     Column('title', String(10)), | ||||
|     Column('firstname', String(64), nullable=False), | ||||
|     Column('lastname', String(64), nullable=False), | ||||
|     Column('address1', String(64), nullable=False), | ||||
|     Column('address2', String(64)), | ||||
|     Column('zip', String(7), nullable=False), | ||||
|     Column('city', String(64), nullable=False), | ||||
|     Column('country', String(5), nullable=False), | ||||
|     Column('phone', String(32), nullable=False), | ||||
|     Column('mobile', String(32)), | ||||
|     Column('fax', String(32)), | ||||
|     Column('email', String(64), unique=True, nullable=False)) | ||||
| client_table.create(checkfirst=True) | ||||
| 
 | ||||
| sysuser_table = Table( | ||||
|     'sysuser', meta, | ||||
|     Column('sysuserid', Integer, primary_key=True), | ||||
|     Column('username', String(12), nullable=False, unique=True), | ||||
|     Column('usertype', Integer, nullable=False, default=0, index=True), | ||||
|     Column('home', String(128)), | ||||
|     Column('shell', Boolean, nullable=False, default=False), | ||||
|     Column('clearpass', String(64)), | ||||
|     Column('md5pass', String(32)), | ||||
|     Column('clientid', Integer, ForeignKey("client.clientid"), nullable=False), | ||||
|     Column('sysuid', Integer, nullable=False, unique=True), | ||||
|     Column('lastchange', DateTime, default=func.now()) | ||||
|     ) | ||||
| sysuser_table.create(checkfirst=True) | ||||
| 
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue