예제 #1
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def updateModule(self, params):
        nr = str(params[0])

        module = ModuleManager.get_module(nr)
        module_meta = ModuleManager.get_meta_from_module(module)
        ModuleManager.invoke_update(module_meta)
        return True
예제 #2
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def getWidgetsOfModule(self, params):
        module_id = int(params[0])

        module = ModuleManager.get_module(module_id)
        widgets = module.get_widgets()

        return [{'id':widget.get_id(), 'name':widget.get_name(), 'gviews':widget.is_generating_views(), 'baseview':widget.get_baseview_id(), 'basespace':widget.get_baseview_space_id()} for widget in widgets]
예제 #3
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def createWidget(self,params):
        module_id = int(params[0])
        new_widget_name = unicode(params[1])

        module = ModuleManager.get_module(module_id)
        module.create_widget(new_widget_name)
        return
예제 #4
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def getModules(self,params):
        get_installed_only = bool(params[0])

        repo_state = True
        repo_state = module_manager.get_repository().ping()
        
        modules = ModuleManager.get_module_info(get_installed_only or not repo_state)
        return {'modules':modules,'repostate':repo_state}
예제 #5
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def executeModuleMethod(self, params):
        module_id = params[0]
        method_name = params[1]
        parameter = params[2]

        module = ModuleManager.get_module(module_id)
        exec "res = module.%s(*parameter)"%method_name
        return res
예제 #6
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def widgetActivateViewGeneration(self, params):
        widget_id = int(params[0])
        view_id = int(params[1])
        space_id = int(params[2])

        view = View.get_from_id(view_id)
        widget = ModuleManager.get_widget(widget_id)
        widget.activate_viewgeneration(view, space_id)
        return
예제 #7
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def getGuiForModule(self, params):
        module_id = int(params[0])

        module = ModuleManager.get_module(module_id)
        moduleguidata = base64.b64encode(module.get_guidata())
        signature = Pki.sign(moduleguidata)

        return {'data':moduleguidata,
                'signature':base64.b64encode(signature),
                'libstring':Configuration.get_entry('global.modpath')}
예제 #8
0
파일: ajax.py 프로젝트: skarphed/skarphed
 def get_answer(self):
     """
     Handles an AJAX call
     """
     widget = ModuleManager.get_widget(self._widget_id)
     html = widget.render_html(self._params)
     js   = widget.render_javascript(self._params)
     answer = {'h':html, 'j':js}
     answer = json.dumps(answer)
     return answer
예제 #9
0
파일: action.py 프로젝트: skarphed/skarphed
    def create_action(cls, actionlist=None, view_id=None, url=None, widget_id = None, space_id = None):
        """
        This method creates a new Action and returns it.
        You can create an action based on either:
        1. A Page Id 
        2. An URL
        3. A widgetId combined with a SpaceId (Both applies to the site the menu is showed in)
        If the combination is not valid this function will return null and not do anything in db
        The action will be inserted with the lowest order (execution priority)
        """
        if actionlist is None:
            return None
        action = Action()
        action.set_action_list_id(actionlist.get_id())
        if view_id is not None:
            view = View.get_from_id(view_id)
            if view is not None:
                action.set_view_id(view_id)
            else:
                return None
        elif url is not None:
            action.set_url(str(url),True)
        elif widget_id is not None and space_id is not None:
            widget = ModuleManager.get_widget(widget_id)
            if widget is not None:
                action.set_widget_space_constellation(widget_id,space_id,True)
        else:
            return None

        action.set_name("new action",True)
        db = Database()
        new_id = db.get_seq_next("ACT_GEN")
        stmnt = "SELECT MAX(ACT_ORDER) AS MAXORDER FROM ACTIONS WHERE ACT_ATL_ID = ? ;"
        cur = db.query(stmnt, (action.get_action_list_id(),))
        row = cur.fetchonemap()
        if row["MAXORDER"] is not None:
            new_order = row["MAXORDER"]+1
        else:
            new_order = 0
        action.set_id(new_id)
        action.set_order(new_order)
        stmnt = "INSERT INTO ACTIONS (ACT_ID, ACT_NAME, ACT_ATL_ID, \
                                      ACT_VIE_ID, ACT_SPA_ID, ACT_WGT_ID, ACT_URL, ACT_ORDER) \
                              VALUES (?,?,?,?,?,?,?,?) ;"
        db.query(stmnt, (action.get_id(), action.get_name(), action.get_action_list_id(),
                                     action.get_view_id(), action.get_space(), action.get_widget_id(),
                                     action.get_url(), action.get_order()),commit=True)
        PokeManager.add_activity(ActivityType.MENU)
        return action
예제 #10
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def widgetDeactivateViewGeneration(self, params):
        widget_id = int(params[0])

        widget = ModuleManager.get_widget(widget_id)
        widget.deactivate_viewgeneration()
        return
예제 #11
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def deleteWidget(self, params):
        widget_id = int(params[0])

        widget = ModuleManager.get_widget(widget_id)
        widget.delete()
        return
예제 #12
0
파일: view.py 프로젝트: skarphed/skarphed
    def render(self, environ):
        View.set_currently_rendering_view(self)
        frame = """
        <!DOCTYPE html>
        <html>
          <head>
            <title>%(title)s</title>
            <link href="/static/%(page_css)s" rel="stylesheet" type="text/css">
            <link href="%(scv_css)s" rel="stylesheet" type="text/css">
            %(head)s
            <script type="text/javascript">%(ajax_script)s</script>
          </head>
          <body>
            %(body)s
          </body>
        </html>
        """
        js_frame = """<script type="text/javascript" id="%d_scr">%s</script>"""
        page = Page.get_page(self._page) 

        head = page.get_html_head()
        body = page.get_html_body()

        # Find placeholders to substitute
        
        space_name_map = page.get_space_names()
        for space, widget_id in self._space_widget_mapping.items():
            space_name = space_name_map[space]
            widget = ModuleManager.get_widget(widget_id)

            args = {} 
            if self._widget_param_mapping.has_key(widget_id):
                args.update(self._widget_param_mapping[widget_id])
            elif self._widget_param_mapping.has_key(str(widget_id)):
                args.update(self._widget_param_mapping[str(widget_id)])
            
            if self._post_widget_id == widget_id:
                # Check whether the viewjson-string is included here, too:
                # if so, eliminate it.
                post_args = FieldStorage(fp=environ['wsgi.input'],environ=environ)
                for key in post_args.keys():
                    args[key] = post_args[key].value

            widget_html = widget.render_html(args)
            widget_js = widget.render_javascript(args)
            widget_html += js_frame%(widget.get_id(), widget_js)
            body = re.sub(r"<%%\s?space:%s\s?%%>"%space_name,widget_html,body)

        for box, boxcontent in self._box_mapping.items():
            box_orientation, box_name = self.get_box_info(box)
            box_html = StringIO.StringIO()
            for widget_id in boxcontent:
                widget = ModuleManager.get_widget(widget_id)

                args = {} 
                if self._widget_param_mapping.has_key(widget_id):
                    args.update(self._widget_param_mapping[widget_id])
                elif self._widget_param_mapping.has_key(str(widget_id)):
                    args.update(self._widget_param_mapping[str(widget_id)])

                if self._post_widget_id == widget_id:
                    # Check whether the viewjson-string is included here, too:
                    # if so, eliminate it.
                    post_args = FieldStorage(fp=environ['wsgi.input'],environ=environ)
                    for key in post_args.keys():
                        args[key] = post_args[key].value
            
                widget_html = widget.render_html(args)
                widget_js = widget.render_javascript(args)
                widget_html += js_frame%(widget.get_id(), widget_js)
                box_html.write(widget_html)
                if box_orientation == BoxOrientation.VERTICAL:
                    box_html.write("<br>")

            if box_orientation == BoxOrientation.HORIZONTAL:
                body = re.sub(r"<%%\s?hbox:%s\s?%%>"%box_name,box_html.getvalue(),body)
            elif box_orientation == BoxOrientation.VERTICAL:
                body = re.sub(r"<%%\s?vbox:%s\s?%%>"%box_name,box_html.getvalue(),body)

        body = re.sub(r"<%[^%>]+%>","",body) #Replace all unused spaces with emptystring

        css_manager = CSSManager()
        css_url = css_manager.get_css_url()

        configuration = Configuration()
        title = configuration.get_entry("core.name")

        page_css = page.get_css_filename()
        View.set_currently_rendering_view(None)
        return frame%{'title':title,
                      'scv_css':css_url,
                      'page_css':page_css,
                      'ajax_script':AJAXScript,
                      'head':head,
                      'body':body}
예제 #13
0
 def install_from_repo(cls, nr):
     repository = ModuleManager.get_repository()
     data = repository.download_template(nr)
     return cls.install_from_data(data)
예제 #14
0
파일: rpc.py 프로젝트: skarphed/skarphed
 def retrieveRepository(self, params):
     repo = ModuleManager.get_repository()
     return {"id":repo.get_id(), "ip":repo.get_ip(), 
             "port":repo.get_port(), "name": repo.get_name()}
예제 #15
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def changeRepository(self, params):
        ip = str(params[0])
        port = int(params[1])

        ModuleManager.set_repository(ip, port, '(default)')
예제 #16
0
 def fetch_templates_for_gui(cls):
     repository = ModuleManager.get_repository()
     data = repository.get_all_templates()
     return data
예제 #17
0
파일: rpc.py 프로젝트: skarphed/skarphed
 def invokeUpdateModules(self, params):
     ModuleManager.updateModules()
     return 0
예제 #18
0
파일: css.py 프로젝트: skarphed/skarphed
    def render(self):
        """
        renders a CSS propertyset
        """
        css = ""
        if self._typ == CSSPropertySet.GENERAL:
            selectorlist = {}
            for key, value in self.get_non_inherited().items():
                splitselector = key.split(CSSPropertySet.SPLIT)
                if len(splitselector) == 1:
                    splitselector.insert(0, "")
                selector, tag = splitselector
                if not selectorlist.has_key(selector):
                    selectorlist[selector] = []
                selectorlist[selector].append({"t": tag, "v": value["v"]})

            for selector, values in selectorlist.items():
                css += selector + "{\n"
                for value in values:
                    css += value["t"] + ":" + value["v"] + ";\n"
                css += "}\n\n"

        elif self._typ == CSSPropertySet.MODULE:
            selectorlist = {}
            module_name = ModuleManager.get_module(self._module_id).get_name()
            # TODO: Assert That modulenames do not contain dots
            for key, value in self.get_non_inherited().items():
                splitselector = key.split(CSSPropertySet.SPLIT)
                if len(splitselector) == 1:
                    splitselector.insert(0, "")
                selector, tag = splitselector
                if not selectorlist.has_key(selector):
                    selectorlist[selector] = []
                selectorlist[selector].append({"t": tag, "v": value["v"]})

            for selector, values in selectorlist.items():
                css += "." + module_name + " " + selector + " {\n"
                for value in values:
                    css += value["t"] + ":" + value["v"] + ";\n"
                css += "}\n\n"

        elif self._typ == CSSPropertySet.WIDGET:
            selectorlist = {}

            for key, value in self.get_non_inherited().items():
                splitselector = key.split(CSSPropertySet.SPLIT)
                if len(splitselector) == 1:
                    splitselector.insert(0, "")
                selector, tag = splitselector
                if not selectorlist.has_key(selector):
                    selectorlist[selector] = []
                selectorlist[selector].append({"t": tag, "v": value["v"]})

            for selector, values in selectorlist.items():
                css += ".w" + str(self.get_widget_id()) + " " + selector + " {\n"
                for value in values:
                    css += value["t"] + ":" + value["v"] + ";\n"
                css += "}\n\n"

        elif self._typ == CSSPropertySet.SESSION:
            pass  # TODO Implement sessiondependent behaviour

        return css
예제 #19
0
파일: rpc.py 프로젝트: skarphed/skarphed
    def installModule(self, params):
        module_meta = params[0]

        ModuleManager.invoke_install(module_meta)
        return 0