Change app data model a bit. Store app properties in separate files and support app cloning.

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1098491 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jsdelfino 2011-05-02 05:58:59 +00:00
commit 5842f30c2a
25 changed files with 140 additions and 78 deletions

View file

@ -15,15 +15,13 @@
# specific language governing permissions and limitations
# under the License.
# Apps collection implementation
import uuid
import sys
# App collection implementation
import os
from util import *
# Convert an id to an app id
def appid(id):
return ("'" + car(id), "'app.composite")
return ("'" + car(id), "'app.stats")
# Link implementation resources into an app
def mkapplink(id):
@ -31,45 +29,41 @@ def mkapplink(id):
os.symlink('../../../../../nuvem/nuvem-parallel/nuvem', 'apps/' + car(id) + '/nuvem')
os.symlink('../../../../components', 'apps/' + car(id) + '/lib')
os.mkdir('apps/' + car(id) + '/htdocs')
os.symlink('../../../htdocs/cache-manifest.cmf', 'apps/' + car(id) + '/htdocs/cache-manifest.cmf');
os.symlink('../../../htdocs/login', 'apps/' + car(id) + '/htdocs/login');
os.symlink('../../../htdocs/logout', 'apps/' + car(id) + '/htdocs/logout');
os.symlink('../../../htdocs/public', 'apps/' + car(id) + '/htdocs/public');
os.symlink('../../../htdocs/data', 'apps/' + car(id) + '/htdocs/data');
os.symlink('../../../htdocs/app/index.html', 'apps/' + car(id) + '/htdocs/index.html');
os.symlink('../../../htdocs/robots.txt', 'apps/' + car(id) + '/htdocs/robots.txt');
os.symlink('../../../htdocs/favicon.ico', 'apps/' + car(id) + '/htdocs/favicon.ico');
os.symlink('../app.html', 'apps/' + car(id) + '/htdocs/app.html');
except:
pass
return True
# Post a new app to the apps db
def post(collection, app, cache):
id = appid((str(uuid.uuid1()),))
comp = cdr(cadddr(car(app)))
cache.put((id,), comp)
mkapplink((id,))
return id
# Put an app into the apps db
def put(id, app, cache):
comp = cdr(cadddr(car(app)))
cache.put(appid(id), comp)
def put(id, app, cache, store, composites, pages):
eid = cadr(caddr(car(app)))
appentry = (("'entry", cadr(car(app)), ("'id", car(id))),)
# Update app in apps db
if car(id) == eid:
cache.put(appid(id), appentry)
mkapplink(id)
return True
# Clone an app's composite and page
cache.put(appid(id), appentry)
mkapplink(id)
composites.put(id, composites.get((eid,)))
pages.put(id, pages.get((eid,)))
return True
# Get an app from the apps db
def get(id, cache):
def get(id, cache, store, composites, pages):
if isNil(id):
return (("'feed", ("'title", "Apps"), ("'id", "apps")),)
app = cache.get(appid(id));
if (isNil(app) or app is None):
return (("'entry", ("'title", car(id)), ("'id", car(id))),)
return (("'entry", ("'title", car(id)), ("'id", car(id)), ("'content", car(app))),)
return app
# Delete an app from the apps db
def delete(id, cache):
def delete(id, cache, store, composites, pages):
cache.delete(appid(id))
composites.delete(id)
pages.delete(id)
return True

View file

@ -0,0 +1 @@
((entry (title "Check my public social data") (id "me360")))

View file

@ -0,0 +1 @@
((entry (title "Where are my friends") (id "nearme")))

View file

@ -0,0 +1 @@
((entry (title "Our photos of an event") (id "ourphotos")))

View file

@ -0,0 +1 @@
((entry (title "My online store") (id "shoppingcart")))

View file

@ -0,0 +1 @@
((entry (title "Slice") (id "slice")))

View file

@ -0,0 +1 @@
((entry (title "An empty test app") (id "test")))

View file

@ -0,0 +1 @@
((entry (title "Test database components") (id "testdb")))

View file

@ -0,0 +1 @@
((entry (title "Test event components") (id "testevents")))

View file

@ -0,0 +1 @@
((entry (title "Test HTTP components") (id "testhttp")))

View file

@ -0,0 +1 @@
((entry (title "Test logic components") (id "testlogic")))

View file

@ -0,0 +1 @@
((entry (title "Test search components") (id "testsearch")))

View file

@ -0,0 +1 @@
((entry (title "Test social components") (id "testsocial")))

View file

@ -0,0 +1 @@
((entry (title "Test text processing components") (id "testtext")))

View file

@ -0,0 +1 @@
((entry (title "Test URL components") (id "testurl")))

View file

@ -0,0 +1 @@
((entry (title "Test values and lists") (id "testvalues")))

View file

@ -0,0 +1 @@
((entry (title "Test widgets") (id "testwidgets")))

View file

@ -0,0 +1 @@
((entry (title "Test more widgets") (id "testwidgets2")))

View file

@ -0,0 +1,44 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# App composites collection implementation
from util import *
# Convert an id to an app id
def appid(id):
return ("'" + car(id), "'app.composite")
# Put an app into the apps db
def put(id, app, cache):
comp = cdr(cadddr(car(app)))
cache.put(appid(id), comp)
return True
# Get an app from the apps db
def get(id, cache):
if isNil(id):
return (("'feed", ("'title", "Composites"), ("'id", "composites")),)
app = cache.get(appid(id));
if (isNil(app) or app is None):
return (("'entry", ("'title", car(id)), ("'id", car(id))),)
return (("'entry", ("'title", car(id)), ("'id", car(id)), ("'content", car(app))),)
# Delete an app from the apps db
def delete(id, cache):
cache.delete(appid(id))
return True

View file

@ -16,8 +16,6 @@
# under the License.
# Dashboards collection implementation
import uuid
import sys
from util import *
# Convert a particular user email to a dashboard id
@ -31,16 +29,8 @@ def getdashboard(id, cache):
return ()
return dashboard
# Post a new app to the user's dashboard
def post(collection, app, user, cache):
id = (str(uuid.uuid1()),)
newapp = list("'entry", cadr(car(app)), list("'id", id), cadddr(car(app)))
dashboard = cons(newapp, getdashboard(dashboardid(user), cache))
cache.put(dashboardid(user), dashboard)
return id
# Put an app into the user's dashboard
def put(id, app, user, cache):
def put(id, app, user, cache, apps):
def putapp(app, dashboard):
if isNil(dashboard):
return app
@ -48,12 +38,16 @@ def put(id, app, user, cache):
return cons(car(app), cdr(dashboard))
return cons(car(dashboard), putapp(app, cdr(dashboard)))
dashboard = putapp(app, getdashboard(dashboardid(user), cache))
appentry = (("'entry", cadr(car(app)), ("'id", car(id))),)
dashboard = putapp(appentry, getdashboard(dashboardid(user), cache))
cache.put(dashboardid(user), dashboard)
# Update app in app repository
apps.put(id, app);
return True
# Get apps from the user's dashboard
def get(id, user, cache):
def get(id, user, cache, apps):
def findapp(id, dashboard):
if isNil(dashboard):
return None
@ -66,7 +60,7 @@ def get(id, user, cache):
return findapp(id, getdashboard(dashboardid(user), cache))
# Delete apps from the user's dashboard
def delete(id, user, cache):
def delete(id, user, cache, apps):
if isNil(id):
return cache.delete(dashboardid(user))
@ -79,5 +73,8 @@ def delete(id, user, cache):
dashboard = deleteapp(id, getdashboard(dashboardid(user), cache))
cache.put(dashboardid(user), dashboard)
# Delete app from app repository
apps.delete(id);
return True

View file

@ -44,9 +44,10 @@
<component name="EditWidget">
<t:implementation.widget location="/index.html"/>
<reference name="dashboard" target="Dashboard"/>
<reference name="apps" target="Apps"/>
<reference name="store" target="AppStore"/>
<reference name="palettes" target="Palettes"/>
<reference name="apps" target="Apps"/>
<reference name="composites" target="Composites"/>
<reference name="pages" target="Pages"/>
<reference name="log" target="Log"/>
</component>
@ -58,6 +59,7 @@
</service>
<reference name="user" target="User"/>
<reference name="cache" target="DashboardCache"/>
<reference name="apps" target="Apps"/>
</component>
<component name="AppStore">
@ -74,6 +76,17 @@
<t:binding.http uri="apps"/>
</service>
<reference name="cache" target="AppCache"/>
<reference name="store" target="AppStore"/>
<reference name="composites" target="Composites"/>
<reference name="pages" target="Pages"/>
</component>
<component name="Composites">
<t:implementation.python script="composites.py"/>
<service name="Composites">
<t:binding.http uri="composites"/>
</service>
<reference name="cache" target="AppDocCache"/>
</component>
<component name="Pages">
@ -81,7 +94,7 @@
<service name="Pages">
<t:binding.http uri="pages"/>
</service>
<reference name="cache" target="AppCache"/>
<reference name="cache" target="AppDocCache"/>
</component>
<component name="Palettes">
@ -89,7 +102,7 @@
<service name="Palettes">
<t:binding.http uri="palettes"/>
</service>
<reference name="cache" target="PaletteCache"/>
<reference name="cache" target="PaletteDocCache"/>
</component>
<component name="DashboardCache">
@ -146,29 +159,49 @@
<component name="AppDB">
<implementation.cpp path="../../components/filedb" library="libfiledb"/>
<property name="dbname">apps</property>
<property name="format">xml</property>
<property name="format">scheme</property>
<service name="AppDB">
<t:binding.http uri="appdb"/>
</service>
</component>
<component name="PaletteCache">
<component name="AppDocCache">
<implementation.cpp path="../../components/cache" library="libdatacache"/>
<service name="PaletteCache">
<t:binding.http uri="palettecache"/>
<service name="AppDocCache">
<t:binding.http uri="appdoccache"/>
</service>
<reference name="l1reader" target="Memcache"/>
<reference name="l1writer" target="Memcache"/>
<reference name="l2reader" target="PaletteDB"/>
<reference name="l2writer" target="PaletteDB"/>
<reference name="l2reader" target="AppDocDB"/>
<reference name="l2writer" target="AppDocDB"/>
</component>
<component name="PaletteDB">
<component name="AppDocDB">
<implementation.cpp path="../../components/filedb" library="libfiledb"/>
<property name="dbname">apps</property>
<property name="format">xml</property>
<service name="AppDocDB">
<t:binding.http uri="appdocdb"/>
</service>
</component>
<component name="PaletteDocCache">
<implementation.cpp path="../../components/cache" library="libdatacache"/>
<service name="PaletteDocCache">
<t:binding.http uri="palettedoccache"/>
</service>
<reference name="l1reader" target="Memcache"/>
<reference name="l1writer" target="Memcache"/>
<reference name="l2reader" target="PaletteDocDB"/>
<reference name="l2writer" target="PaletteDocDB"/>
</component>
<component name="PaletteDocDB">
<implementation.cpp path="../../components/filedb" library="libfiledb"/>
<property name="dbname">palettes</property>
<property name="format">xml</property>
<service name="PaletteDB">
<t:binding.http uri="palettedb"/>
<service name="PaletteDocDB">
<t:binding.http uri="palettedocdb"/>
</service>
</component>

View file

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
# User info service component
# Log service component
from sys import stderr
# Log a message

View file

@ -16,21 +16,11 @@
# under the License.
# App pages collection implementation
import uuid
import sys
from sys import stderr
from util import *
# Convert an id to an app id
def appid(id):
return ("'" + car(id), "'app.html")
# Post a new app page to the apps db
def post(collection, app, cache):
id = appid((str(uuid.uuid1()),))
xhtml = cdr(cadddr(car(app)))
cache.put((id,), xhtml)
return id
return ("'" + car(id), "'htdocs", "'app.html")
# Put an app page into the apps db
def put(id, app, cache):

View file

@ -16,8 +16,6 @@
# under the License.
# Palettes collection implementation
import uuid
import sys
from util import *
# Convert an id to a palette id

View file

@ -16,8 +16,6 @@
# under the License.
# stores collection implementation
import uuid
import sys
from util import *
# Convert a particular store tag to a store id
@ -31,15 +29,6 @@ def getstore(id, cache):
return ()
return store
# Post a new app to a store
def post(collection, app, cache):
tag = car(collection)
id = (str(uuid.uuid1()),)
newapp = list("'entry", cadr(car(app)), list("'id", id), cadddr(car(app)))
store = cons(newapp, getstore(storeid(tag), cache))
cache.put(storeid(tag), store)
return id
# Put an app into a store
def put(key, app, cache):
def putapp(app, store):