diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-28 20:01:44 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-28 20:01:44 +0000 |
commit | 8720acd237f415983c5ca2acd4b5135415114758 (patch) | |
tree | 9d736e5fcca561b60e66e5a5e0a59f924326e0c8 /sca-cpp/trunk/modules/wsgi/scdl.py | |
parent | 4a56fb45307de579bf3ee88935c5c22a75c03512 (diff) |
Strawman WSGI integration, allowing Python components to run in a Python WSGI server.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@917286 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/wsgi/scdl.py')
-rw-r--r-- | sca-cpp/trunk/modules/wsgi/scdl.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/sca-cpp/trunk/modules/wsgi/scdl.py b/sca-cpp/trunk/modules/wsgi/scdl.py new file mode 100644 index 0000000000..a6bb48bc65 --- /dev/null +++ b/sca-cpp/trunk/modules/wsgi/scdl.py @@ -0,0 +1,89 @@ +# 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. + +# SCDL parsing functions + +from util import * + +def mkcomponent(name, impl, svcs, refs): + return (name, impl, svcs, refs) + +def implementation(e): + if len(e) == 0 or match(car(e), "end", "component") == True: + return "" + if match(car(e), "start", "implementation.python") == False: + return implementation(cdr(e)) + if "script" in att(car(e)): + s = att(car(e))["script"] + return s[0:len(s) - 3] + return None + +def binding(e): + if len(e) == 0 or match(car(e), "end", "reference") == True or match(car(e), "end", "service") == True: + return () + if match(car(e), "start", "binding.") == False: + return binding(cdr(e)) + return tokens(att(car(e))["uri"]) + +def references(e): + if len(e) == 0 or match(car(e), "end", "component") == True: + return () + if match(car(e), "start", "reference") == False: + return references(cdr(e)) + if "target" in att(car(e)): + return (att(car(e))["target"],) + references(cdr(e)) + return cons(binding(e), references(cdr(e))) + +def services(e): + if len(e) == 0 or match(car(e), "end", "component") == True: + return () + if match(car(e), "start", "service") == False: + return services(cdr(e)) + return cons(binding(e), services(cdr(e))) + +def name(e): + return att(car(e))["name"] + +def components(e): + if len(e) == 0: + return () + if match(car(e), "start", "component") == False: + return components(cdr(e)) + n = name(e) + return cons(mkcomponent(n, implementation(e), cons(("components", n), services(e)), references(e)), components(cdr(e))) + +def nameToComponent(n, c): + if c == (): + return None + if car(car(c)) == n: + return car(c) + return nameToComponent(n, cdr(c)) + +def matchingURI(u, s): + if s == (): + return None + if car(s) == u[0:len(car(s))]: + return car(s) + return matchingURI(u, cdr(s)) + +def uriToComponent(u, c): + if c == (): + return (None, None) + m = matchingURI(u, caddr(car(c))) + if m != None: + return (m, car(c)) + return uriToComponent(u, cdr(c)) |