[CalendarServer-changes] [7582] CalendarServer/trunk/calendarserver/tools/dbinspect.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 13 12:27:10 PDT 2011
Revision: 7582
http://trac.macosforge.org/projects/calendarserver/changeset/7582
Author: cdaboo at apple.com
Date: 2011-06-13 12:27:10 -0700 (Mon, 13 Jun 2011)
Log Message:
-----------
Add command to display all events with matching iCalendar UID.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/dbinspect.py
Modified: CalendarServer/trunk/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dbinspect.py 2011-06-13 18:01:27 UTC (rev 7581)
+++ CalendarServer/trunk/calendarserver/tools/dbinspect.py 2011-06-13 19:27:10 UTC (rev 7582)
@@ -90,7 +90,7 @@
class CalendarHomes(Cmd):
- _name = "calendar homes"
+ _name = "List Calendar Homes"
@inlineCallbacks
def doIt(self, txn):
@@ -127,7 +127,7 @@
class Calendars(Cmd):
- _name = "calendars"
+ _name = "List Calendars"
@inlineCallbacks
def doIt(self, txn):
@@ -173,7 +173,7 @@
class Events(Cmd):
- _name = "events"
+ _name = "List Events"
@inlineCallbacks
def doIt(self, txn):
@@ -221,7 +221,7 @@
class Event(Cmd):
- _name = "event"
+ _name = "Get Event Data by Resource-ID"
@inlineCallbacks
def doIt(self, txn):
@@ -252,7 +252,48 @@
).on(txn, **{"ResourceID": rid}))
returnValue(rows[0][0] if rows else None)
+class EventsByUID(Cmd):
+
+ _name = "Get Event Data by iCalendar UID"
+
+ @inlineCallbacks
+ def doIt(self, txn):
+
+
+ uid = raw_input("UID: ")
+ rows = yield self.getData(txn, uid)
+ if rows:
+ for owner, calendar, data in rows:
+ record = txn._directory.recordWithGUID(owner)
+ shortname = record.shortNames[0] if record else "-"
+ table = tables.Table()
+ table.addRow((shortname, calendar,))
+ print "\n"
+ table.printTable()
+ print data
+ else:
+ print "Could not find icalendar data"
+ @inlineCallbacks
+ def getData(self, txn, uid):
+ ch = schema.CALENDAR_HOME
+ cb = schema.CALENDAR_BIND
+ co = schema.CALENDAR_OBJECT
+ rows = (yield Select(
+ [
+ ch.OWNER_UID,
+ cb.CALENDAR_RESOURCE_NAME,
+ co.ICALENDAR_TEXT,
+ ],
+ From=ch.join(
+ cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
+ cb.BIND_MODE == _BIND_MODE_OWN)).join(
+ co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
+ Where=(co.ICALENDAR_UID == Parameter("UID")),
+ ).on(txn, **{"UID": uid}))
+ returnValue(tuple(rows))
+
+
class DBInspectService(Service, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
@@ -280,6 +321,7 @@
self.registerCommand(Calendars)
self.registerCommand(Events)
self.registerCommand(Event)
+ self.registerCommand(EventsByUID)
self.doDBInspect()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110613/d3f2f692/attachment.html>
More information about the calendarserver-changes
mailing list