equal
deleted
inserted
replaced
56 """some monkey patching necessary when an application has to deal with |
56 """some monkey patching necessary when an application has to deal with |
57 several connections to different repositories. It tries to hide buggy class |
57 several connections to different repositories. It tries to hide buggy class |
58 attributes since classes are not designed to be shared among multiple |
58 attributes since classes are not designed to be shared among multiple |
59 registries. |
59 registries. |
60 """ |
60 """ |
61 defaultcls = cwvreg.VRegistry.REGISTRY_FACTORY[None] |
61 defaultcls = cwvreg.CWRegistryStore.REGISTRY_FACTORY[None] |
62 |
62 |
63 etypescls = cwvreg.VRegistry.REGISTRY_FACTORY['etypes'] |
63 etypescls = cwvreg.CWRegistryStore.REGISTRY_FACTORY['etypes'] |
64 orig_etype_class = etypescls.orig_etype_class = etypescls.etype_class |
64 orig_etype_class = etypescls.orig_etype_class = etypescls.etype_class |
65 @monkeypatch(defaultcls) |
65 @monkeypatch(defaultcls) |
66 def etype_class(self, etype): |
66 def etype_class(self, etype): |
67 """return an entity class for the given entity type. |
67 """return an entity class for the given entity type. |
68 Try to find out a specific class for this kind of entity or |
68 Try to find out a specific class for this kind of entity or |
73 return usercls |
73 return usercls |
74 usercls.e_schema = self.schema.eschema(etype) |
74 usercls.e_schema = self.schema.eschema(etype) |
75 return usercls |
75 return usercls |
76 |
76 |
77 def multiple_connections_unfix(): |
77 def multiple_connections_unfix(): |
78 etypescls = cwvreg.VRegistry.REGISTRY_FACTORY['etypes'] |
78 etypescls = cwvreg.CWRegistryStore.REGISTRY_FACTORY['etypes'] |
79 etypescls.etype_class = etypescls.orig_etype_class |
79 etypescls.etype_class = etypescls.orig_etype_class |
80 |
80 |
81 |
81 |
82 class ConnectionProperties(object): |
82 class ConnectionProperties(object): |
83 def __init__(self, cnxtype=None, lang=None, close=True, log=False): |
83 def __init__(self, cnxtype=None, lang=None, close=True, log=False): |
190 if method == 'inmemory': |
190 if method == 'inmemory': |
191 vreg = repo.vreg |
191 vreg = repo.vreg |
192 elif setvreg: |
192 elif setvreg: |
193 if mulcnx: |
193 if mulcnx: |
194 multiple_connections_fix() |
194 multiple_connections_fix() |
195 vreg = cwvreg.CubicWebVRegistry(config, initlog=initlog) |
195 vreg = cwvreg.CWRegistryStore(config, initlog=initlog) |
196 schema = repo.get_schema() |
196 schema = repo.get_schema() |
197 for oldetype, newetype in ETYPE_NAME_MAP.items(): |
197 for oldetype, newetype in ETYPE_NAME_MAP.items(): |
198 if oldetype in schema: |
198 if oldetype in schema: |
199 print 'aliasing', newetype, 'to', oldetype |
199 print 'aliasing', newetype, 'to', oldetype |
200 schema._entities[newetype] = schema._entities[oldetype] |
200 schema._entities[newetype] = schema._entities[oldetype] |
205 cnx.vreg = vreg |
205 cnx.vreg = vreg |
206 return cnx |
206 return cnx |
207 |
207 |
208 def in_memory_repo(config): |
208 def in_memory_repo(config): |
209 """Return and in_memory Repository object from a config (or vreg)""" |
209 """Return and in_memory Repository object from a config (or vreg)""" |
210 if isinstance(config, cwvreg.CubicWebVRegistry): |
210 if isinstance(config, cwvreg.CWRegistryStore): |
211 vreg = config |
211 vreg = config |
212 config = None |
212 config = None |
213 else: |
213 else: |
214 vreg = None |
214 vreg = None |
215 # get local access to the repository |
215 # get local access to the repository |