当前位置: 首页>>代码示例>>Python>>正文


Python Database.get_seq_next方法代码示例

本文整理汇总了Python中skarphedcore.database.Database.get_seq_next方法的典型用法代码示例。如果您正苦于以下问题:Python Database.get_seq_next方法的具体用法?Python Database.get_seq_next怎么用?Python Database.get_seq_next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skarphedcore.database.Database的用法示例。


在下文中一共展示了Database.get_seq_next方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
    def create(cls, name, internal_name, description, html_body, html_head, css, minimap=None):
        """
        Creates A Page (normally as a part of the installation process of a Template)
        in Database
        """

        placeholders = re.findall(r"<%[^%>]+%>",html_body)
        placeholders = [p.replace("<%","",1) for p in placeholders]
        placeholders = [p.replace("%>","",1) for p in placeholders]
        placeholders = [p.strip() for p in placeholders]

        if len(placeholders) < 1:
            pass # Eventually we need to check for Pages with no spaces. Not an error yet

        minimap_id = None
        if minimap is not None:
            minimap_binary = Binary.create("image/png", minimap)
            minimap_binary.set_filename(internal_name+"_minimap.png")
            minimap_binary.store()
            minimap_id = minimap_binary.get_id()

        css_binary = binary_manager.create("text/css", css)
        css_binary.set_filename(internal_name+".css")
        css_binary.store()
        css_id = css_binary.get_id()

        stmnt = "INSERT INTO SITES (SIT_ID, SIT_HTML, SIT_HTML_HEAD, SIT_DESCRIPTION, SIT_NAME, SIT_BIN_MINIMAP, SIT_BIN_CSS) \
                 VALUES (?,?,?,?,?,?,?) ;"

        db = Database()
        new_sit_id = db.get_seq_next("SIT_GEN")

        db.query(stmnt , (new_sit_id, html_body, html_head, description, name, minimap_id, css_id), commit=True)

        stmnt_space= "INSERT INTO SPACES (SPA_ID, SPA_SIT_ID, SPA_NAME ) VALUES (?,?,?) ; "
        stmnt_box = "INSERT INTO BOXES (BOX_ID, BOX_SIT_ID, BOX_NAME, BOX_ORIENTATION) VALUES (?,?,?,?) ;"

        for placeholder in placeholders:
            splitted = placeholder.split(":")
            typ = splitted[0]
            name = splitted[1]
            if typ == "space":
                new_space_id = db.get_seq_next("SPA_GEN")
                db.query(stmnt_space, (new_space_id, new_sit_id, name), commit=True )
            elif typ == "vbox" or typ == "hbox":
                new_box_id = db.get_seq_next("BOX_GEN")
                orientation = int(typ == "vbox")
                db.query(stmnt_box, (new_box_id, new_sit_id, name, orientation), commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:50,代码来源:view.py

示例2: create_role

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
    def create_role(cls, data=None):
        if data is None:
            raise PermissionException(PermissionException.get_msg(10))
        if data["name"] is None:
            raise PermissionException(PermissionException.get_msg(11))

        db = Database()

        stmnt = "SELECT ROL_ID FROM ROLES WHERE ROL_NAME = ? ;"
        cur = db.query(stmnt,(data["name"],))
        res = cur.fetchonemap()
        if res is not None:
            raise PermissionException(PermissionException.get_msg(13, data["name"]))
        
        role_id = db.get_seq_next("ROL_GEN")
        role = Role()
        role.set_id(role_id)
        role.set_name(data["name"])
        role.store()

        if data.has_key("rights"):
            for permission in data["rights"]:
                if permission["granted"]:
                    role.add_permission(permission["name"])
                else:
                    role.remove_permission(permission["name"])
            role.store()

        return role
开发者ID:skarphed,项目名称:skarphed,代码行数:31,代码来源:permissions.py

示例3: create_permission

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def create_permission(cls, permission, module=""):
     """
     Creates a new permission in database
     """
     db = Database()
     new_id = db.get_seq_next('RIG_GEN')
     stmnt = "INSERT INTO RIGHTS (RIG_ID, RIG_NAME) VALUES (?,?) ;"
     db.query(stmnt,(new_id,module+"."+permission),commit=True)
     PokeManager.add_activity(ActivityType.PERMISSION)
     return module+"."+permission
开发者ID:skarphed,项目名称:skarphed,代码行数:12,代码来源:permissions.py

示例4: create_default_view

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def create_default_view(cls):
     db = Database()
     stmnt = "SELECT VIE_ID FROM VIEWS WHERE VIE_DEFAULT = 1 ;"
     cur = db.query(stmnt)
     row = cur.fetchonemap()
     if row is None:
         view_id = db.get_seq_next("VIE_GEN")
         stmnt = "INSERT INTO VIEWS (VIE_ID, VIE_SIT_ID, VIE_NAME, VIE_DEFAULT) \
                    VALUES (?,1,'default',1) ;"
         db.query(stmnt, (view_id,), commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:12,代码来源:view.py

示例5: _register_module

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def _register_module(manifest):
     """
     registers a module into the database
     """
     db = Database()
     nr = db.get_seq_next("MOD_GEN")
     stmnt = "INSERT INTO MODULES (MOD_ID, MOD_NAME, MOD_DISPLAYNAME, MOD_VERSIONMAJOR, MOD_VERSIONMINOR, MOD_VERSIONREV, MOD_JSMANDATORY) \
                   VALUES (?,?,?,?,?,?,?) ;"
     db.query(stmnt,(nr,manifest["name"],manifest["hrname"],
                                manifest["version_major"],manifest["version_minor"],
                                manifest["revision"],manifest["js_mandatory"]),commit=True)
     return nr
开发者ID:skarphed,项目名称:skarphed,代码行数:14,代码来源:module.py

示例6: create_action_list

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def create_action_list(cls, action_list_name = "new actionlist"):
     """
     This function creates a new ActionList
     """
     action_list = ActionList()
     action_list.set_name(action_list_name)
     db = Database()
     action_list.set_id(db.get_seq_next('ATL_GEN'))
     stmnt = "INSERT INTO ACTIONLISTS VALUES (?,?);"
     db.query(stmnt, (action_list.get_id(), action_list.get_name()),commit=True)
     PokeManager.add_activity(ActivityType.MENU)
     return action_list
开发者ID:skarphed,项目名称:skarphed,代码行数:14,代码来源:action.py

示例7: create_menu

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def create_menu(cls, page, name="new menu"):
     """
     This function creates a menu.
     """
     db = Database()
     menu = Menu()
     menu.set_id(db.get_seq_next('MNU_GEN'))
     menu.set_name(name)
     stmnt = "INSERT INTO MENUS (MNU_ID,MNU_NAME, MNU_SIT_ID) VALUES (?,?, ?) ;"
     db.query(stmnt, (menu.get_id(), menu.get_name(), page.get_id()),commit=True)
     PokeManager.add_activity(ActivityType.MENU)
     return menu 
开发者ID:skarphed,项目名称:skarphed,代码行数:14,代码来源:action.py

示例8: store

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
    def store(self):
        db = Database()

        if self._id is None:
            self._id = db.get_seq_next('WGT_GEN')

        if self._module is None:
            raise ModuleCoreException(ModuleCoreException.get_msg(1))

        stmnt = "UPDATE OR INSERT INTO WIDGETS (WGT_ID, WGT_NAME, WGT_SIT_ID, WGT_MOD_ID, WGT_VIE_BASEVIEW, WGT_SPA_BASESPACE) \
                    VALUES (?,?,?,?,?,?) MATCHING (WGT_ID) ;"
        db.query(stmnt,(self._id,self._name, self._site_id,self._module.get_id(), self._baseview_id, self._baseview_space_id ),commit=True)
        PokeManager.add_activity(ActivityType.WIDGET)
开发者ID:skarphed,项目名称:skarphed,代码行数:15,代码来源:module.py

示例9: create_action

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
    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
开发者ID:skarphed,项目名称:skarphed,代码行数:51,代码来源:action.py

示例10: store

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def store(self):
     """
     stores this user into database
     """
     db = Database()()
     if self._id == None:
         stmnt = "INSERT INTO USERS (USR_ID, USR_NAME, USR_PASSWORD, USR_SALT) \
                   VALUES (?,?,?,?);"
         self.set_id(db.get_seq_next('USR_GEN'))
         db.query(stmnt,(self._id, self._name, self._password, self._salt),commit=True)
     else:
         stmnt =  "UPDATE USERS SET \
                     USR_NAME = ?, \
                     USR_PASSWORD = ?, \
                     USR_SALT = ? \
                   WHERE USR_ID = ?"
         db.query(stmnt,(self._name, self._password, self._salt, self._id),commit=True)
     PokeManager.add_activity(ActivityType.USER)
开发者ID:skarphed,项目名称:skarphed,代码行数:20,代码来源:users.py

示例11: create_menu_item

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def create_menu_item(cls, menu=None, menu_item_parent=None, name="new item"):
     """
     This function creates a new MenuItem based on either:
     1. A parent Menu or
     2. A parent MenuItem
     If none of those is set, the function will abort and return null
     The MenuItem will be spawned with the lowest display order
     """
     if menu is None and menu_item_parent is None:
         return None
     db = Database()
     menu_item = MenuItem()
     menu_item.set_name(name)
     if menu is not None:
         menu_item.set_menu_id(menu.get_id())
         stmnt = "SELECT MAX(MNI_ORDER) AS MAXORDER FROM MENUITEMS WHERE MNI_MNU_ID = ? ;"
         cur = db.query(stmnt, (menu.get_id(),))
     if menu_item_parent is not None:
         menu_item.set_parent_menu_item_id(menu_item_parent.get_id())
         stmnt = "SELECT MAX(MNI_ORDER) AS MAXORDER FROM MENUITEMS WHERE MNI_MNI_ID = ? ;"
         cur = db.query(stmnt, (menu_item_parent.get_id(),))
     menu_item.set_id(db.get_seq_next('MNI_GEN'))
     row = cur.fetchonemap()
     if row["MAXORDER"] is not None:
         new_order = row["MAXORDER"]+1
     else:
         new_order = 0
     menu_item.set_order(new_order)
     stmnt = "INSERT INTO MENUITEMS VALUES (?,?,?,?,?,?) ;"
     db.query(stmnt,(menu_item.get_id(), menu_item.get_name(),
                               menu_item.get_menu_id(), menu_item.get_parent_menu_item_id(),
                               None, menu_item.get_order()),commit=True)
     db.commit()
     action_list = ActionList.create_action_list()
     menu_item.assign_action_list(action_list)
     PokeManager.add_activity(ActivityType.MENU)
     return menu_item
开发者ID:skarphed,项目名称:skarphed,代码行数:39,代码来源:action.py

示例12: store

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
 def store(self):
     db = Database()
     if self._id is None:
         self.set_id(db.get_seq_next("ATV_GEN"))
     stmnt = "UPDATE OR INSERT INTO ACTIVITIES (ATV_ID, ATV_TYPE, ATV_SES_ID) VALUES (?,?,?) MATCHING (ATV_ID) ;"
     db.query(stmnt, (self.get_id(), self.get_activity_type(), self.get_session_id()), commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:8,代码来源:poke.py

示例13: store

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import get_seq_next [as 别名]
    def store(self, onlySpaceWidgetMapping=False, 
              onlyBoxMapping=False, onlyWidgetParamMapping=False):
        """
        stores this view in the database

        the programmer may store only parts of the view by activating several flags
        this is necessary to avoid a race condition between to simultaneous calls
        when editing a view.
        """
        onlyOneOperation = onlySpaceWidgetMapping or onlyBoxMapping or onlyWidgetParamMapping
        db = Database()
        if self._id is None:
            self._id = db.get_seq_next("VIE_GEN")
        
        # update the view itself
        stmnt = "UPDATE OR INSERT INTO VIEWS (VIE_ID, VIE_SIT_ID, VIE_VIE_BASEVIEW, \
                    VIE_NAME, VIE_DEFAULT) \
                 VALUES (?,?,?,?,?) MATCHING (VIE_ID) ;"
        db.query(stmnt, (self._id, self._page, self._baseview_id, self._name, int(self._default)), commit=True)

        if not onlyOneOperation or onlySpaceWidgetMapping:
            # Get current space-widgetmapping to determine, which mappings to delete
            stmnt = "SELECT VIW_SPA_ID, VIW_WGT_ID FROM VIEWWIDGETS WHERE VIW_VIE_ID = ? ;"
            cur = db.query(stmnt, (self.get_id(),))
            dbSpaceWidgetMap = {}
            for row in cur.fetchallmap():
                dbSpaceWidgetMap[row["VIW_SPA_ID"]] = row["VIW_WGT_ID"]

            # get space-widget-mapping of baseview to determine, which allocations are
            # identical to those of the baseview and thus shall not be stored
            if self.is_derived():
                stmnt = "SELECT VIW_SPA_ID, VIW_WGT_ID FROM VIEWWIDGETS \
                         WHERE VIW_VIE_ID = (SELECT VIE_VIE_BASEVIEW FROM VIEWS WHERE VIE_ID=?) ;"
                baseviewSpaceWidgetMap = {}
                cur = db.query(stmnt, (self.get_id(),))
                for row in cur.fetchallmap():
                    baseviewSpaceWidgetMap[row["VIW_SPA_ID"]] = row["VIW_WGT_ID"]

            # update widgets
            stmnt = "UPDATE OR INSERT INTO VIEWWIDGETS (VIW_VIE_ID, VIW_SPA_ID, VIW_WGT_ID) \
                      VALUES (?,?,?) MATCHING (VIW_VIE_ID, VIW_SPA_ID) ;"
            for space_id, widget_id in self._space_widget_mapping.items():
                # ignore allocation if present in baseview
                space_id = int(space_id)
                if self.is_derived() \
                        and baseviewSpaceWidgetMap.has_key(space_id) \
                        and baseviewSpaceWidgetMap[space_id] == widget_id:
                    continue
                db.query(stmnt,(self._id, int(space_id), int(widget_id)),commit=True)
                try:
                    del(dbSpaceWidgetMap[int(space_id)])
                except KeyError: pass

            # delete Removed Widgets
            stmnt = "DELETE FROM VIEWWIDGETS WHERE VIW_VIE_ID = ? AND VIW_SPA_ID = ? ;"
            for space_id in dbSpaceWidgetMap.keys():
                db.query(stmnt, (self.get_id(), space_id), commit=True)

        if not onlyOneOperation or onlyBoxMapping:
            # get current box_widget_mapping to determine which mappings to delete
            stmnt = "SELECT BWT_BOX_ID, BWT_WGT_ID FROM BOXWIDGETS WHERE BWT_VIE_ID = ? ;"
            cur = db.query(stmnt, (self.get_id(),))
            dbBoxMapping = {}
            for row in cur.fetchallmap():
                dbBoxMapping[(row["BWT_BOX_ID"],row["BWT_WGT_ID"])] = 1
            
            # get box widget mapping of baseview to ignore boxmappings that are
            # present in the baseview
            if self.is_derived():
                stmnt = "SELECT BWT_BOX_ID, BWT_WGT_ID, BWT_ORDER FROM BOXWIDGETS \
                         WHERE BWT_VIE_ID = (SELECT VIE_VIE_BASEVIEW FROM VIEWS WHERE VIE_ID=?) ;"
                baseviewBoxMapping = {}
                cur = db.query(stmnt, (self.get_id(),))
                for row in cur.fetchallmap():
                    baseviewBoxMapping[row["BWT_BOX_ID"],row["BWT_ORDER"]] = row["BWT_WGT_ID"]

            # insert new box-related entries and change existing ones
            stmnt = "UPDATE OR INSERT INTO BOXWIDGETS \
                      (BWT_BOX_ID, BWT_WGT_ID, BWT_ORDER, BWT_VIE_ID) \
                      VALUES (?,?,?,?) MATCHING (BWT_BOX_ID, BWT_VIE_ID, BWT_WGT_ID) ;"
            for box_id, boxcontent in self._box_mapping.items():
                order = 0
                for widget_id in boxcontent:
                    # ignore allocation if present in baseview
                    if self.is_derived() \
                            and baseviewBoxMapping.has_key((box_id,order)) \
                            and baseviewBoxMapping[box_id,order] == widget_id:
                        continue
                    db.query(stmnt, (box_id, widget_id, order, self.get_id()), \
                             commit=True)
                    try:
                        del(dbBoxMapping[(int(box_id),int(widget_id))])
                    except KeyError: pass
                    order +=1

            # delete boxwidgets that are not used anymore
            stmnt = "DELETE FROM BOXWIDGETS \
                     WHERE BWT_BOX_ID = ? AND BWT_WGT_ID = ? AND BWT_VIE_ID = ? ;"
            for box_id, widget_id in dbBoxMapping.keys():
                db.query(stmnt, (box_id, widget_id, self.get_id()), commit=True)
#.........这里部分代码省略.........
开发者ID:skarphed,项目名称:skarphed,代码行数:103,代码来源:view.py


注:本文中的skarphedcore.database.Database.get_seq_next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。