61 '(not registered in Pyro), ' |
61 '(not registered in Pyro), ' |
62 'you may have to restart your server-side ' |
62 'you may have to restart your server-side ' |
63 'application' % nsid) |
63 'application' % nsid) |
64 return core.getProxyForURI(uri) |
64 return core.getProxyForURI(uri) |
65 |
65 |
66 def repo_connect(repo, user, password, cnxprops=None): |
66 def repo_connect(repo, login, password, cnxprops=None): |
67 """Constructor to create a new connection to the CubicWeb repository. |
67 """Constructor to create a new connection to the CubicWeb repository. |
68 |
68 |
69 Returns a Connection instance. |
69 Returns a Connection instance. |
70 """ |
70 """ |
71 cnxprops = cnxprops or ConnectionProperties('inmemory') |
71 cnxprops = cnxprops or ConnectionProperties('inmemory') |
72 cnxid = repo.connect(unicode(user), password, cnxprops=cnxprops) |
72 cnxid = repo.connect(unicode(login), password, cnxprops=cnxprops) |
73 cnx = Connection(repo, cnxid, cnxprops) |
73 cnx = Connection(repo, cnxid, cnxprops) |
74 if cnxprops.cnxtype == 'inmemory': |
74 if cnxprops.cnxtype == 'inmemory': |
75 cnx.vreg = repo.vreg |
75 cnx.vreg = repo.vreg |
76 return cnx |
76 return cnx |
77 |
77 |
78 def connect(database=None, user=None, password=None, host=None, |
78 def connect(database=None, login=None, password=None, host=None, |
79 group=None, cnxprops=None, port=None, setvreg=True, mulcnx=True, |
79 group=None, cnxprops=None, port=None, setvreg=True, mulcnx=True, |
80 initlog=True): |
80 initlog=True): |
81 """Constructor for creating a connection to the CubicWeb repository. |
81 """Constructor for creating a connection to the CubicWeb repository. |
82 Returns a Connection object. |
82 Returns a Connection object. |
83 |
83 |
109 print 'aliasing', newetype, 'to', oldetype |
109 print 'aliasing', newetype, 'to', oldetype |
110 schema._entities[newetype] = schema._entities[oldetype] |
110 schema._entities[newetype] = schema._entities[oldetype] |
111 vreg.set_schema(schema) |
111 vreg.set_schema(schema) |
112 else: |
112 else: |
113 vreg = None |
113 vreg = None |
114 cnx = repo_connect(repo, user, password, cnxprops) |
114 cnx = repo_connect(repo, login, password, cnxprops) |
115 cnx.vreg = vreg |
115 cnx.vreg = vreg |
116 return cnx |
116 return cnx |
117 |
117 |
118 def in_memory_cnx(config, user, password): |
118 def in_memory_cnx(config, login, password): |
119 """usefull method for testing and scripting to get a dbapi.Connection |
119 """usefull method for testing and scripting to get a dbapi.Connection |
120 object connected to an in-memory repository instance |
120 object connected to an in-memory repository instance |
121 """ |
121 """ |
122 if isinstance(config, CubicWebRegistry): |
122 if isinstance(config, CubicWebRegistry): |
123 vreg = config |
123 vreg = config |
126 vreg = None |
126 vreg = None |
127 # get local access to the repository |
127 # get local access to the repository |
128 repo = get_repository('inmemory', config=config, vreg=vreg) |
128 repo = get_repository('inmemory', config=config, vreg=vreg) |
129 # connection to the CubicWeb repository |
129 # connection to the CubicWeb repository |
130 cnxprops = ConnectionProperties('inmemory') |
130 cnxprops = ConnectionProperties('inmemory') |
131 cnx = repo_connect(repo, user, password, cnxprops=cnxprops) |
131 cnx = repo_connect(repo, login, password, cnxprops=cnxprops) |
132 return repo, cnx |
132 return repo, cnx |
133 |
133 |
134 |
134 |
135 class DBAPIRequest(RequestSessionMixIn): |
135 class DBAPIRequest(RequestSessionMixIn): |
136 |
136 |