~jamesj/+junk/wsdlexplorer

« back to all changes in this revision

Viewing changes to wsdlexplorer/common/connection.py

  • Committer: James Jesudason
  • Date: 2011-08-31 11:06:17 UTC
  • Revision ID: james.jesudason@canonical.com-20110831110617-e2jf7iichqv23t52
Added main files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
3
### BEGIN LICENSE
 
4
# Copyright (C) 2010 James Jesudason <james.jesudason@canonical.com>
 
5
# This program is free software: you can redistribute it and/or modify it 
 
6
# under the terms of the GNU General Public License version 3, as published 
 
7
# by the Free Software Foundation.
 
8
 
9
# This program is distributed in the hope that it will be useful, but 
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of 
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
 
14
# You should have received a copy of the GNU General Public License along 
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
### END LICENSE
 
17
 
 
18
from wsdlexplorer.common.database import Database
 
19
 
 
20
 
 
21
class Connection:
 
22
    """Model class for a WSDL Connection"""
 
23
    # WSDL Connection record defaults
 
24
    record_type = "http://wiki.ubuntu.com/Quickly/WSDLConnection"
 
25
    keys = ["Name", "Type" ,"WSDL", "Username"]
 
26
    key_field = "Name"
 
27
 
 
28
    def __init__(self):
 
29
        self.database = Database()
 
30
        
 
31
        # Connection types
 
32
        self.types = ["WSDL", "Salesforce"]
 
33
 
 
34
    def get_grid(self):
 
35
        """Get the CouchGrid for display"""
 
36
        grid = self.database.get_grid(self.record_type, self.keys)
 
37
        return grid
 
38
 
 
39
    def save_record(self, record):
 
40
        record_id = self.database.save_record(self.record_type, record, self.key_field)
 
41
        return record_id
 
42
 
 
43
    def get_record(self, record):
 
44
        document = self.database.get_record(self.record_type, record, self.key_field)
 
45
        return document
 
46
 
 
47
    def delete_record(self, record):
 
48
        self.database.delete_record(self.record_type, record, self.key_field)
 
49
 
 
50