nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
################################################################################
#
# Four Worlds
# Copyright (c) 2009-????
#
# Package: polc
#    File: data.py
#
# The automatic Python OLC system, capable of generating an online content editor
# for a given Python class or dict by using dictionaries to discover properties.
#
# OLC Data Storage
#
# Author: Stendec
#
################################################################################

import mudsys, auxiliary, storage, copy

################################################################################
# Variables
################################################################################

menukeys = "1234567890ABCDEFGHIJKLMNOPRSTUVWXYZ"
fancy_keys = {
	'desc'        : 'Description',
	'rdesc'       : 'Room Description',
	'mdesc' 			: 'Room Description for Multiple Occurences',
	'edesc'       : 'Extra Descriptions',
	'mname'				: 'Name for Multiple Occurences',
}

################################################################################
# Storage Class
################################################################################
class OLCAuxData:
	def __init__(self, set = None):
		self.working	= None
		self.key			= None
	
	def copy(self):
		c = OLCAuxData()
		self.copyTo(c)
		return c
	
	def copyTo(self, to):
		to.working	= self.working
		to.key			= self.key
	
	def store(self):
		set = storage.StorageSet()
		return set

class OLCData:
	def __init__(self, set = None):
		self.reset()
	
	def reset(self):
		self.object		= None
		self.saver		= None
		self.key			= None
		self.opts			= None
		self.sock			= None
		self.ekey			= None
	
	def hk(self, key, okey = None):
		'''Determines if we have a key. No value.'''
		key = "_" + key
		return self.opts.has_key(key) and self.opts[key].has_key(okey)
	
	def k(self, key, okey = None):
		'''Get the value of the option in key, or None if it doesn't exist.'''
		if self.hk(key,okey): return self.opts['_'+key][okey]
		return None
	
	def copy(self):
		newdata = OLCData()
		self.copyTo(newdata)
		return newdata
	
	def copyTo(self, to):
		to.object		= self.object
		to.saver    = self.saver
		to.key			= self.key
		to.opts			= self.opts
		to.sock			= self.sock
		to.ekey			= self.ekey
	
	def store(self):
		set = storage.StorageSet()
		return set

################################################################################
# Initialization
################################################################################
auxiliary.install("olc", OLCAuxData, "socket")