Skip to content

Commit d9a3e63

Browse files
committed
* server/setup.py: install default spaces.
1 parent 11fa4c4 commit d9a3e63

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

server/setup.py

+27
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ def init(dbname="shiftspace/master"):
4949
sync()
5050

5151

52+
def installSpace(space):
53+
from models import core
54+
import simplejson as json
55+
fh = open(os.path.join("spaces", space, "attrs.json"))
56+
data = json.loads(fh.read())
57+
data["type"] = "space"
58+
db = core.connect()
59+
if db.get(space):
60+
del db[space]
61+
db[space] = data
62+
63+
64+
DEFAULT_SPACES = (
65+
"Notes",
66+
"Highlights",
67+
"SourceShift",
68+
"ImageSwap",
69+
)
70+
71+
72+
def installDefaultSpaces():
73+
for space in DEFAULT_SPACES:
74+
installSpace(space)
75+
76+
5277
def sync(createAdmin=True):
5378
import models.core as core
5479
from models.ssuser import SSUser
@@ -68,6 +93,8 @@ def sync(createAdmin=True):
6893
master["admins"] = adminDoc
6994
master["shiftspace"] = adminUser
7095

96+
installDefaultSpaces()
97+
7198
Spaces = ViewDefinition('spaces', 'by_name', '''
7299
function(doc) {
73100
if(doc.type == "space") {

shifty.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,7 @@ def installSpace(space):
379379
"""
380380
Installs a space's attributes into the database.
381381
"""
382-
from server.models import core
383-
fh = open(os.path.join("spaces", space, "attrs.json"))
384-
data = json.loads(fh.read())
385-
data["type"] = "space"
386-
db = core.connect()
387-
db[space] = data
382+
setup.installSpace(space)
388383

389384

390385
def shell():

0 commit comments

Comments
 (0)