Bugfix / update docs for AttributeStorageLite, NickUser
This commit is contained in:
parent
bd1260040f
commit
c89600433d
|
@ -1,7 +1,7 @@
|
||||||
:mod:`AttributeStorageLite` --- Item key/value storage
|
:mod:`AttributeStorageLite` --- Item key/value storage
|
||||||
======================================================
|
======================================================
|
||||||
|
|
||||||
With a SQLite backend.
|
:doc:`AttributeStorage </api/modules/attributestorage>` with a SQLite backend.
|
||||||
|
|
||||||
Class Reference
|
Class Reference
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
:mod:`NickUser` --- A simple authentication service
|
:mod:`NickUser` --- A simple authentication service
|
||||||
===================================================
|
===================================================
|
||||||
|
|
||||||
A module providing a simple login/logout account service
|
A module providing a simple login/logout account service. "Trust" is based upon
|
||||||
|
hostname - logging in autorizes your current hostname for your account data,
|
||||||
|
which is tied to your nick.
|
||||||
|
|
||||||
|
Commands
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. cmdoption:: .setpass <oldpass> <newpass>
|
||||||
|
|
||||||
|
Set or change your password. Users with a password already must provide the
|
||||||
|
old password to set a new one.
|
||||||
|
|
||||||
|
.. cmdoption:: .login <password>
|
||||||
|
|
||||||
|
Log into your account (authorize your current hostname)
|
||||||
|
|
||||||
|
.. cmdoption:: .logout
|
||||||
|
|
||||||
|
Log out of account (deauthorize your current hostname)
|
||||||
|
|
||||||
Class Reference
|
Class Reference
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -17,13 +17,14 @@ class AttributeStorageLite(ModuleBase):
|
||||||
self.db = None
|
self.db = None
|
||||||
serviceProviders = self.bot.getmodulesbyservice("sqlite")
|
serviceProviders = self.bot.getmodulesbyservice("sqlite")
|
||||||
if len(serviceProviders)==0:
|
if len(serviceProviders)==0:
|
||||||
self.log.error("AttributeStorage: Could not find a valid sqlite service provider")
|
self.log.error("Could not find a valid sqlite service provider")
|
||||||
|
raise Exception("No sqlite provider available")
|
||||||
else:
|
else:
|
||||||
self.log.info("AttributeStorage: Selecting sqlite service provider: %s" % serviceProviders[0])
|
self.log.info("Selecting sqlite service provider: %s" % serviceProviders[0])
|
||||||
self.db = serviceProviders[0].opendb("attributes.db")
|
self.db = serviceProviders[0].opendb("attributes.db")
|
||||||
|
|
||||||
if not self.db.tableExists("attribute"):
|
if not self.db.tableExists("attribute"):
|
||||||
self.log.info("AttributeStorage: Creating table: attribute")
|
self.log.info("Creating table: attribute")
|
||||||
c = self.db.query("""CREATE TABLE IF NOT EXISTS `attribute` (
|
c = self.db.query("""CREATE TABLE IF NOT EXISTS `attribute` (
|
||||||
`id` INTEGER PRIMARY KEY,
|
`id` INTEGER PRIMARY KEY,
|
||||||
`attribute` varchar(128) UNIQUE
|
`attribute` varchar(128) UNIQUE
|
||||||
|
@ -31,7 +32,7 @@ class AttributeStorageLite(ModuleBase):
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
if not self.db.tableExists("items"):
|
if not self.db.tableExists("items"):
|
||||||
self.log.info("AttributeStorage: Creating table: items")
|
self.log.info("Creating table: items")
|
||||||
c = self.db.query("""CREATE TABLE IF NOT EXISTS `items` (
|
c = self.db.query("""CREATE TABLE IF NOT EXISTS `items` (
|
||||||
`id` INTEGER PRIMARY KEY,
|
`id` INTEGER PRIMARY KEY,
|
||||||
`item` varchar(512)
|
`item` varchar(512)
|
||||||
|
@ -39,7 +40,7 @@ class AttributeStorageLite(ModuleBase):
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
if not self.db.tableExists("values"):
|
if not self.db.tableExists("values"):
|
||||||
self.log.info("AttributeStorage: Creating table: values")
|
self.log.info("Creating table: values")
|
||||||
c = self.db.query("""CREATE TABLE IF NOT EXISTS `values` (
|
c = self.db.query("""CREATE TABLE IF NOT EXISTS `values` (
|
||||||
`itemid` INTEGER NOT NULL,
|
`itemid` INTEGER NOT NULL,
|
||||||
`attributeid` INTEGER NOT NULL,
|
`attributeid` INTEGER NOT NULL,
|
||||||
|
@ -160,9 +161,9 @@ class AttributeStorageLite(ModuleBase):
|
||||||
if value == None:
|
if value == None:
|
||||||
# delete it
|
# delete it
|
||||||
c = self.db.query("DELETE FROM `values` WHERE `itemid`=? AND `attributeid`=? ;", (itemId, attributeId))
|
c = self.db.query("DELETE FROM `values` WHERE `itemid`=? AND `attributeid`=? ;", (itemId, attributeId))
|
||||||
self.log.debug("AttributeStorage: Stored item %s attribute %s value: %s (Deleted)" % (itemId, attributeId, value))
|
self.log.debug("Stored item %s attribute %s value: %s (Deleted)" % (itemId, attributeId, value))
|
||||||
else:
|
else:
|
||||||
# add attribute
|
# add attribute
|
||||||
c = self.db.query("REPLACE INTO `values` (`itemid`, `attributeid`, `value`) VALUES (?, ?, ?);", (itemId, attributeId, value))
|
c = self.db.query("REPLACE INTO `values` (`itemid`, `attributeid`, `value`) VALUES (?, ?, ?);", (itemId, attributeId, value))
|
||||||
self.log.debug("AttributeStorage: Stored item %s attribute %s value: %s" % (itemId, attributeId, value))
|
self.log.debug("Stored item %s attribute %s value: %s" % (itemId, attributeId, value))
|
||||||
c.close()
|
c.close()
|
||||||
|
|
Loading…
Reference in New Issue