106 return cnx |
106 return cnx |
107 |
107 |
108 def connect(database=None, login=None, host=None, group=None, |
108 def connect(database=None, login=None, host=None, group=None, |
109 cnxprops=None, setvreg=True, mulcnx=True, initlog=True, **kwargs): |
109 cnxprops=None, setvreg=True, mulcnx=True, initlog=True, **kwargs): |
110 """Constructor for creating a connection to the CubicWeb repository. |
110 """Constructor for creating a connection to the CubicWeb repository. |
111 Returns a Connection object. |
111 Returns a :class:`Connection` object. |
112 |
112 |
113 When method is 'pyro', setvreg is True, try to deal with connections to |
113 Typical usage:: |
114 differents instances in the same process unless specified otherwise by |
114 |
115 setting the mulcnx to False. |
115 cnx = connect('myinstance', login='me', password='toto') |
|
116 |
|
117 Arguments: |
|
118 |
|
119 :database: |
|
120 the instance's pyro identifier. |
|
121 |
|
122 :login: |
|
123 the user login to use to authenticate. |
|
124 |
|
125 :host: |
|
126 the pyro nameserver host. Will be detected using broadcast query if |
|
127 unspecified. |
|
128 |
|
129 :group: |
|
130 the instance's pyro nameserver group. You don't have to specify it unless |
|
131 tweaked in instance's configuration. |
|
132 |
|
133 :cnxprops: |
|
134 an optional :class:`ConnectionProperties` instance, allowing to specify |
|
135 the connection method (eg in memory or pyro). A Pyro connection will be |
|
136 established if you don't specify that argument. |
|
137 |
|
138 :setvreg: |
|
139 flag telling if a registry should be initialized for the connection. |
|
140 Don't change this unless you know what you're doing. |
|
141 |
|
142 :mulcnx: |
|
143 Will disappear at some point. Try to deal with connections to differents |
|
144 instances in the same process unless specified otherwise by setting this |
|
145 flag to False. Don't change this unless you know what you're doing. |
|
146 |
|
147 :initlog: |
|
148 flag telling if logging should be initialized. You usually don't want |
|
149 logging initialization when establishing the connection from a process |
|
150 where it's already initialized. |
|
151 |
|
152 :kwargs: |
|
153 there goes authentication tokens. You usually have to specify for |
|
154 instance a password for the given user, using a named 'password' argument. |
116 """ |
155 """ |
117 config = cwconfig.CubicWebNoAppConfiguration() |
156 config = cwconfig.CubicWebNoAppConfiguration() |
118 if host: |
157 if host: |
119 config.global_set_option('pyro-ns-host', host) |
158 config.global_set_option('pyro-ns-host', host) |
120 if group: |
159 if group: |