Sam Hart avatar Sam Hart committed e74c5da

flurry of work... uh... stuff

Comments (0)

Files changed (5)

src/noink/dataModels.py

 from noink import mainDB
 
 class User(mainDB.Model):
+    '''
+    Basic user class.
+
+    Currently, we leave authentication and, indeed, user management up to an
+    external source. By the time a user hits Noink, we assume they are a real,
+    actual user that must be in the database. If they do *not* exist in Noink,
+    then we add it.
+    '''
     __tablename__ = 'users'
 
     id = mainDB.Column(mainDB.Integer, primary_key=True)
     def __repr__(self):
         return "<Tag %s : Entry %s>" % (self.tag, self.entry)
 
+class DataType(mainDB.Model):
+    __tablename__ = 'datatype'
+
+    id = mainDB.Column(mainDB.Integer, primary_key=True)
+    name = mainDB.Column(mainDB.String(20))
+
+    def __init__(self, name):
+        self.name = name
+
+    def __repr__(self):
+        return "<Type %s, id %s>" % (self.name, self.id)
+
 class Entry(mainDB.Model):
     __tablename__ = 'entries'
 

src/noink/defaultConfig.py

 
 # The database URI for whatever DB you would like to use
 SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/noink.db"
+
+# The name of the administrative user - Note that this field SHOULD NOT be
+# changed after the database has been created, as it will not update the admin
+# user in the database!
+ADMIN_USER = "admin"
+
+# The name of the administrative group - Note that this field SHOULD NOT be
+# changed after the database has been created, as it will not update the admin
+# group in the database!
+ADMIN_GROUP = "admin"
+

src/noink/eventLog.py

+'''
+The main interface to the event log.
+
+Everything should use this to interact with the event log, Nothing should work
+with the log in the database directly but this.
+
+##BOILERPLATE_COPYRIGHT
+##BOILERPLATE_COPYRIGHT_END
+'''
+
+from noink import mainDB
+from noink.dataModuls import Event
+from noink.eventsTable import eventTable
+
+class EventLog:
+
+    __borg_state = {}
+
+    def __init__(self):
+        self.__dict__ = self.__borg_state
+
+    def add(self, name, user, processed=False):
+        '''
+        Adds an event to the log.
+
+        @param name: The event name. Should correspond to entry in eventTable
+        @param user: The id of the user generating the event
+        @param processed: If the event should be marked as processed
+        '''
+
+        if eventTable.has_key(name):
+            e = Event(name, eventTable[name],

src/noink/eventsTable.py

+'''
+Defines all the possible events that can be generated.
+
+Note- you can very easily go "off the rails" and come up with your own events
+to add to the event log, but I'd *strongly* recommend just sticking to these
+here (or updating this list as needed) as we reserve the right to actually use
+specific items here in future data parsing, searching, processing, etc.
+
+##BOILERPLATE_COPYRIGHT
+##BOILERPLATE_COPYRIGHT_END
+
+'''
+
+eventTable = {
+    'db_setuo' : 'Initial database creation',
+    'db_finish' : 'Database initialization complete',
+    'add_user' : "User '%s' added"
+}
+#!/usr/bin/env python
+
+'''
+setup_db.py
+-----------
+Initializes the database, setting any default values
+'''
+
+from noink import mainDB
+mainDB.create_all()
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.