Esempio n. 1
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have be able to view the GNU General Public License at
# http://www.gnu.org/copyleft/gpl.html ; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

import shelve
import md5
import common
import config

users_file = config.backing_store_path("users")
sessions_file = config.backing_store_path("sessions")


class user:
    "Represents one user of the system."

    def __init__(self, username):
        self.username = username
        self.metadata = {}
        self.last_sequences = {}
        self.version = 1
        # We no longer use the password field, so set it to '*'
        # so that new accounts won't be usable by older copies
        # of Yarrow.
        self.password = "*"
Esempio n. 2
0
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have be able to view the GNU General Public License at 
# http://www.gnu.org/copyleft/gpl.html ; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

import shelve
import rgtp
import common
import config

indexes_file = config.backing_store_path('indexes')

def index(name, rgtp_server):
	"""Returns an index for the RGTP server |name| (where
	|rgtp_server| is an object representing that server).
	If possible, uses and updates the cache on backing store."""
	
	mutex = common.mutex('indexes.lock')

	mutex.get()
	indexes = shelve.open(indexes_file)

	current = None

	if indexes.has_key(name):
		# AND the datestamp is recent
Esempio n. 3
0
 def __init__(self, filename):
     "Creates a lock based on |filename|."
     self.filename = config.backing_store_path(filename)
Esempio n. 4
0
            item = item[1:]
            for line in item:
                if not line or not line.startswith('&'):
                    break

                if line.startswith('&TAGS='):
                    for tag in [t.strip().replace(' ','-') for t in line[6:].split(',')]:
                        if not self.tags.has_key(tag):
                            self.tags[tag] = []
                        self.tags[tag].append(itemid)
                elif line.startswith('&SLUG='):
                    self.slugs[line[6:]] = itemid

            self.seen[itemid] = 1

metadata_file = config.backing_store_path('metadata')

def get(name, collater, connection):
	mutex = common.mutex('metadata.lock')
	mutex.get()

	meta = shelve.open(metadata_file)

        if meta.has_key(name):
            current = meta[name]
        else:
            current = metadata()

        current.consider(collater, connection)

        meta[name] = current