Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_and_add_dirty_flag_for_persistent_context(self, inst):
from persistent.mapping import PersistentMapping
inst.context = PersistentMapping()
inst.context._p_jar = Mock()
inst.set({'count': 2})
assert inst.context._p_changed is True
# else:
# print "inside else"
storage = FileStorage('./storage/userdb.fs')
conn = DB(storage)
print "Type start:",conn, type(conn)
dbroot = conn.open().root()
#db() # to check if the DB is already initialized
# this part is commented as it is moved up in db()
try:
for val in ['userdb','graphdb','datadb','dsdb']:
if val in dbroot.keys():
pass
except:
if not val in dbroot.keys():
print " donot create this always"
dbroot[val] = Dict()
print "TRY user db dbroot:",dbroot['userdb'], type (dbroot['userdb'])
print "else:::::-->", request.form , form.email.data
u=mod.User(form.name.data,form.email.data,\
sha256(form.password.data).hexdigest(), \
form.password.data,form.institution.data,\
form.security_question.data, form.security_answer.data
)
print "User:--->", u, "form.name.data",form.name.data
dbroot['userdb'][u.name] = u
session['username'] = u.name
transaction.commit()
print "Database added successfully", dbroot['userdb'][u.name], u.name, u
flash('Registered successfuly')
return redirect(url_for('login'))
return render_template('forms/register.html', form = form)
def clone(self, registrationForm):
acf = AccommodationForm(registrationForm)
acf.setValues(self.getValues())
acf.setEnabled(self.isEnabled())
acf._accommodationTypes = PersistentMapping()
for at in self.getAccommodationTypesList() :
acf.addAccommodationType(at.clone(registrationForm))
return acf
def set_path(self, sid, newpath):
"""maps path to object with soupdata annotations for given soup id.
it does not check if there is already a soup before nor does it warn if
there was a soup at the old location.
"""
self.traverse(newpath) # check if newpath is ok
paths = IAnnotations(self.root).get(SOUPPATHS, None)
if paths is None:
paths = PersistentMapping()
IAnnotations(self.root)[SOUPPATHS] = paths
paths[sid] = newpath
self._invalidate_cache(sid)
self.histsInFile = BTrees.OOBTree.BTree()
# All hists, including those which were created, along with those in the file
self.histsAvailable = BTrees.OOBTree.BTree()
# Hists list that should be used
self.hists = BTrees.OOBTree.BTree()
# True if we received a new file, therefore leading to reprocessing
# If the subsystem is being created, we likely need reprocessing, so defaults to true
self.newFile = True
# Number of events in the subsystem. The processing will attempt to determine the number of events,
# but it is a subsystem dependent quantity. It needs explicit support.
self.nEvents = 1
# Processing options
self.processingOptions = persistent.mapping.PersistentMapping()
import BTrees
from persistent.mapping import PersistentMapping
import transaction
from zope.interface import implementer
from repoze.catalog.interfaces import ICatalog
from repoze.catalog.interfaces import ICatalogIndex
from repoze.catalog.compat import text_type
@implementer(ICatalog)
class Catalog(PersistentMapping):
family = BTrees.family32
def __init__(self, family=None):
PersistentMapping.__init__(self)
if family is not None:
self.family = family
def clear(self):
""" Clear all indexes in this catalog. """
for index in self.values():
index.clear()
def index_doc(self, docid, obj):
"""Register the document represented by ``obj`` in indexes of
this catalog using docid ``docid``."""
def setVar(self, key, value):
try:
self.datadict[key] = value
except AttributeError:
self.datadict = PersistentMapping()
self.datadict[key] = value
self._v_modified = True
def newer(self, latest_gen, latest_index, follows):
iterable = self.checked(follows)
for gen, index, mapping in iterable:
if (gen, index) > (latest_gen, latest_index):
yield gen, index, mapping
def older(self, earliest_gen, earliest_index, follows):
iterable = self.checked(follows)
for gen, index, mapping in iterable:
if (gen, index) < (earliest_gen, earliest_index):
yield gen, index, mapping
def push(self, **kw):
self._stack.push(PersistentMapping(kw),)
class Users(PersistentMapping):
def check(self, userid, password):
if userid in self:
hashed_password = self[userid].password
if crypt.check(hashed_password, password):
return True
return False
class User(object):
def __init__(self, users, userid, password, fullname, about):
self.userid = userid
self.password = crypt.encode(password)
self.fullname = fullname
self.about = about
self.avatar = "/static/avatar.jpg"
self.follows = PersistentList()
self.followers = PersistentList()