Skip to content

Commit 1ecbfa9

Browse files
authored
Merge pull request #137 from saumilpatel/master
Trigger DJ setup from Connection instantiation
2 parents 1bea6d0 + e7d0bd2 commit 1ecbfa9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

+dj/Connection.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
% specify the connection to the database.
2727
% initQuery is the SQL query to be executed at the start
2828
% of each new session.
29+
setupDJ(true);
2930
try
3031
mymVersion = mym('version');
3132
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6)
@@ -151,7 +152,7 @@ function reload(self)
151152
error 'Server disconnected during a transaction'
152153
end
153154
end
154-
end
155+
end
155156

156157

157158
function ret = query(self, queryStr, varargin)

+dj/conn.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
function connObj = conn(host, user, pass, initQuery, reset)
2222
persistent CONN
23+
2324
if nargin < 5
2425
reset = false;
2526
end
@@ -29,7 +30,6 @@
2930
'connection already instantiated. To reconnect, clear functions')
3031
else
3132
% invoke setupDJ
32-
setupDJ(true);
3333
% optional environment variables specifying the connection.
3434
env = struct(...
3535
'host', 'DJ_HOST', ...

setupDJ.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
function setupDJ(skip)
1+
function setupDJ(skipPathAddition, force)
2+
3+
if nargin < 2
4+
force = false;
5+
end
6+
7+
persistent INVOKED;
8+
9+
if ~isempty(INVOKED) && ~force
10+
return
11+
end
12+
213
base = fileparts(mfilename('fullpath'));
314

415
if nargin < 1
5-
skip = false;
16+
skipPathAddition = false;
617
end
718

8-
if ~skip
19+
if ~skipPathAddition
920
fprintf('Adding DataJoint to the path...\n')
1021
addpath(base)
1122
end
@@ -31,4 +42,6 @@ function setupDJ(skip)
3142
% run mymSetup.m
3243
fprintf('Setting up mym...\n')
3344
run(fullfile(mymdir, 'mymSetup.m'))
45+
46+
INVOKED = 1;
3447
end

0 commit comments

Comments
 (0)