示例#1
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add(self, string_code):
     sql = 'INSERT INTO string(string_code) VALUES (' + wsq(string_code) + ')'
     db.runsql(sql)
     db.commit()
     astring = String(string_code)
     self[astring.code] = astring
     return astring
示例#2
0
文件: Sessions.py 项目: Fat-Zer/LDP
 def delete(self, username):
     sql = 'DELETE FROM session WHERE username=' + wsq(username)
     db.runsql(sql)
     db.commit()
     del self[username]
     state.session = None
     state.user = None
示例#3
0
    def start(self):

        # Sit up robot whenever available
        psm.go_to_state(StandBy())

        # Try and get the user from the user manager
        user_manager.get_user()

        # When user is available, we'll greet the user, otherwise start introduction
        if user_manager.has_user() is True:
            debug("Has a user")
            conversation_manager.conversation = Greetings.Greetings
        else:
            debug("Does not have a user")
            conversation_manager.conversation = Introduction.Introduction

        # Get the conversation handler
        conversation = conversation_manager.get_conversation()

        # Start the conversation
        conversation_handler.start(conversation)

        # Commit changes to prevent data loss whilst listening to the user in the commandcentre
        db.commit()

        command_listener = CommandListener()
        command_listener.start()

        # Commit changes to the database
        db.commit()
示例#4
0
文件: Sessions.py 项目: Fat-Zer/LDP
 def add(self, username, ip_address, uri=''):
     sql = 'INSERT INTO session(username, ip_address, uri) VALUES (' + wsq(username) + ', ' + wsq(ip_address) + ', ' + wsq(uri) + ')'
     db.runsql(sql)
     db.commit()
     self[username] = Session(username)
     state.session = self[username]
     state.user = dms.username.get_by_id(username)
示例#5
0
文件: Sessions.py 项目: dnessorga/LDP
 def delete(self, username):
     sql = 'DELETE FROM session WHERE username=' + wsq(username)
     db.runsql(sql)
     db.commit()
     del self[username]
     state.session = None
     state.user = None
示例#6
0
文件: WebLayer.py 项目: dnessorga/LDP
 def save(self):
     sql = 'UPDATE page SET section_code=' + wsq(self.section_code) + ', sort_order=' + str(self.sort_order) + ', template_code=' + wsq(self.template_code) + ', data=' + wsq(string.join(self.data)) + ', only_dynamic=' + wsq(bool2tf(self.only_dynamic)) + ', only_registered=' + wsq(bool2tf(self.only_registered)) + ', only_admin=' + wsq(bool2tf(self.only_admin)) + ', only_sysadmin=' + wsq(bool2tf(self.only_sysadmin)) + ' WHERE page_code=' + wsq(self.code)
     db.runsql(sql)
     db.commit()
     for lang in self.title.keys():
         sql = 'UPDATE page_i18n SET title=' + wsq(self.title[lang]) + ', menu_name=' + wsq(self.menu_name[lang]) + ', page=' + wsq(self.page[lang]) + ', version=' + wsq(self.version[lang]) + ' WHERE page_code=' + wsq(self.code) + ' AND lang=' + wsq(lang)
         db.runsql(sql)
         db.commit()
示例#7
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add_lang(self, lang, title, menu_name, page, version):
     sql = 'INSERT INTO page_i18n(page_code, lang, title, menu_name, page, version) VALUES (' + wsq(self.code) + ', ' + wsq(lang) + ', ' + wsq(title) + ', ' + wsq(menu_name) + ', ' + wsq(page) + ', ' + wsq(version) + ')'
     db.runsql(sql)
     db.commit()
     self.title[lang] = title
     self.menu_name[lang] = menu_name
     self.page[lang] = page
     self.version[lang] = version
示例#8
0
文件: WebLayer.py 项目: dnessorga/LDP
 def save(self):
     sql = 'UPDATE news SET pub_date=' + wsq(self.pub_date) + ' WHERE news_id=' + str(self.id)
     db.runsql(sql)
     db.commit()
     for lang in self.news.keys():
         sql = 'UPDATE news_i18n SET headline=' + wsq(self.headline[lang]) + ', news=' + wsq(self.news[lang]) + ', version=' + wsq(self.version[lang]) + ' WHERE news_id=' + str(self.id) + ' AND lang=' + wsq(lang)
         db.runsql(sql)
         db.commit()
示例#9
0
文件: Sessions.py 项目: dnessorga/LDP
 def add(self, username, ip_address, uri=''):
     sql = 'INSERT INTO session(username, ip_address, uri) VALUES (' + wsq(
         username) + ', ' + wsq(ip_address) + ', ' + wsq(uri) + ')'
     db.runsql(sql)
     db.commit()
     self[username] = Session(username)
     state.session = self[username]
     state.user = dms.username.get_by_id(username)
示例#10
0
文件: Sessions.py 项目: Fat-Zer/LDP
 def refresh(self, ip_address, uri=''):
     sql = 'UPDATE session SET updated=now(), ip_address=' + wsq(ip_address) + ', uri=' + wsq(uri) + ' WHERE username='******'\'s session expired, recreating it.')
         sql = 'INSERT INTO session(username) VALUES (' + wsq(self.username) + ')'
         db.runsql(sql)
         db.commit()
示例#11
0
文件: Sessions.py 项目: dnessorga/LDP
 def refresh(self, ip_address, uri=''):
     sql = 'UPDATE session SET updated=now(), ip_address=' + wsq(
         ip_address) + ', uri=' + wsq(uri) + ' WHERE username='******'\'s session expired, recreating it.')
         sql = 'INSERT INTO session(username) VALUES (' + wsq(
             self.username) + ')'
         db.runsql(sql)
         db.commit()
示例#12
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add(self, pub_date=None):
     news = NewsItem()
     news.id = db.next_id('news', 'news_id')
     if pub_date==None:
         news.pub_date = now_string()
     else:
         news.pub_date = pub_date
     self[news.id] = news
     sql = 'INSERT INTO news(news_id, pub_date) VALUES (' + str(news.id) + ', ' + wsq(news.pub_date) + ')'
     db.runsql(sql)
     db.commit()
     return news
示例#13
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add(self, page_code, section_code, template_code, only_dynamic, only_registered, only_admin, only_sysadmin, data):
     if section_code=='':
         sort_order = 0
     else:
         sort_order = self.max_sort_order(section_code) + 1
         
     sql = 'INSERT INTO page(page_code, sort_order, section_code, template_code, only_dynamic, only_registered, only_admin, only_sysadmin, data) '
     sql += 'VALUES (' + wsq(page_code) + ', ' + str(sort_order) + ', ' + wsq(section_code) + ', ' + wsq(template_code) + ', ' + wsq(bool2tf(only_dynamic)) + ', ' + wsq(bool2tf(only_registered)) + ', ' + wsq(bool2tf(only_admin)) + ', ' + wsq(bool2tf(only_sysadmin)) + ', ' + wsq(string.join(data)) + ')'
     db.runsql(sql)
     db.commit()
     page = Page(page_code)
     self[page.code] = page
     return page
示例#14
0
文件: base.py 项目: Fat-Zer/LDP
 def delete(self, object):
     if object.in_database==0:
         return
     self.cache.delete(object)
     wheres = []
     for key in self.table.key_list:
         data_field = self.table.fields[key]
         value = data_field.attr_to_field(getattr(object, data_field.attribute))
         wheres.append(data_field.field_name + '=' + value)
     where = ' WHERE ' + string.join(wheres, ' AND ')
     sql = 'DELETE FROM %s %s' % (self.table.name, where)
     db.runsql(sql)
     db.commit()
     sql = 'INSERT INTO deleted (table_name, identifier) VALUES (%s, %s)' % (wsq(self.table.name), wsq(str(object.key)))
     db.runsql(sql)
     db.commit()
示例#15
0
    def save(self, object):
        object.key = self.table.get_key(
            object)  # New objects need their key calculated.
        if object.changed == 0 and object.in_database == 0:
            return
        if object.in_database == 0:
            field_list = []
            value_list = []
            for key in self.table.field_list:
                field = self.table.fields[key]
                if field.data_type == 'created':  # The database is responsible for setting the timestamp.
                    continue
                if field.data_type == 'sequence':  # When inserting, always increment the value.
                    new_id = db.next_id(self.name, field.field_name)
                    setattr(object, field.attribute, new_id)
                value = field.attr_to_field(getattr(object, field.attribute))
                field_list.append(field.field_name)
                value_list.append(value)
            sql = 'INSERT INTO %s (%s) VALUES (%s)' % (
                self.table.name, string.join(
                    field_list, ', '), string.join(value_list, ', '))
        else:
            update_list = []
            where_list = []
            for key in self.table.field_list:
                field = self.table.fields[key]
                if field.data_type == 'created':
                    continue
                if field.data_type == 'updated':
                    value = wsq(now_string())
                else:
                    value = field.attr_to_field(
                        getattr(object, field.attribute))
                update_list.append(field.field_name + '=' + value)
                if field.key_field == 1:
                    where_list.append(field.field_name + '=' + value)
            sql = 'UPDATE %s SET %s WHERE %s' % (
                self.table.name, string.join(
                    update_list, ', '), string.join(where_list, ' AND '))
#            print sql
        db.runsql(sql)
        db.commit()
        self.cache.add(object)
        object.in_database = 1
        object.changed = 0
示例#16
0
 def delete(self, object):
     if object.in_database == 0:
         return
     self.cache.delete(object)
     wheres = []
     for key in self.table.key_list:
         data_field = self.table.fields[key]
         value = data_field.attr_to_field(
             getattr(object, data_field.attribute))
         wheres.append(data_field.field_name + '=' + value)
     where = ' WHERE ' + string.join(wheres, ' AND ')
     sql = 'DELETE FROM %s %s' % (self.table.name, where)
     db.runsql(sql)
     db.commit()
     sql = 'INSERT INTO deleted (table_name, identifier) VALUES (%s, %s)' % (
         wsq(self.table.name), wsq(str(object.key)))
     db.runsql(sql)
     db.commit()
示例#17
0
文件: base.py 项目: Fat-Zer/LDP
    def save(self, object):
        object.key = self.table.get_key(object) # New objects need their key calculated.
        if object.changed==0 and object.in_database==0:
            return
        if object.in_database==0:
            field_list = []
            value_list = []
            for key in self.table.field_list:
                field = self.table.fields[key]
                if field.data_type=='created':  # The database is responsible for setting the timestamp.
                    continue
                if field.data_type=='sequence': # When inserting, always increment the value.
                    new_id = db.next_id(self.name, field.field_name)
                    setattr(object, field.attribute, new_id)
                value = field.attr_to_field(getattr(object, field.attribute))
                field_list.append(field.field_name)
                value_list.append(value)
            sql = 'INSERT INTO %s (%s) VALUES (%s)' % (self.table.name, string.join(field_list, ', '), string.join(value_list, ', '))
        else:
            update_list = []
            where_list = []
            for key in self.table.field_list:
                field = self.table.fields[key]
                if field.data_type=='created':
                    continue
                if field.data_type=='updated':
                    value = wsq(now_string())
                else:
                    value = field.attr_to_field(getattr(object, field.attribute))
                update_list.append(field.field_name + '=' + value)
                if field.key_field==1:
                    where_list.append(field.field_name + '=' + value)
            sql = 'UPDATE %s SET %s WHERE %s' % (self.table.name, string.join(update_list, ', '), string.join(where_list, ' AND '))
#            print sql
        db.runsql(sql)
        db.commit()
        self.cache.add(object)
        object.in_database = 1
        object.changed = 0
示例#18
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add_lang(self, lang, webstring, version):
     sql = 'INSERT INTO string_i18n(string_code, lang, string, version) VALUES (' + wsq(self.code) + ', ' + wsq(lang) + ', ' + wsq(webstring) + ', ' + wsq(version) + ')'
     db.runsql(sql)
     db.commit()
     self.string[lang]  = webstring
     self.version[lang] = version
示例#19
0
文件: WebLayer.py 项目: dnessorga/LDP
 def save(self):
     for lang in self.string.keys():
         sql = 'UPDATE string_i18n SET string=' + wsq(self.string[lang]) + ' WHERE string_code=' + wsq(self.code)
         db.runsql(sql)
         db.commit()
示例#20
0
文件: WebLayer.py 项目: dnessorga/LDP
 def add_lang(self, lang, headline, news, version):
     sql = 'INSERT INTO news_i18n(news_id, lang, headline, news, version) VALUES (' + str(self.id) + ', ' + wsq(lang) + ', ' + wsq(headline) + ', ' + wsq(news) + ', ' + wsq(version) + ')'
     db.runsql(sql)
     db.commit()
     self.news[lang] = news