/usr/share/pyshared/axiom/iaxiom.py is in python-axiom 0.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | from zope.interface import Interface, Attribute
class IStatEvent(Interface):
"""
Marker for a log message that is useful as a statistic.
Log messages with 'interface' set to this class will be made available to
external observers. This is useful for tracking the rate of events such as
page views.
"""
class IAtomicFile(Interface):
def __init__(tempname, destdir):
"""Create a new atomic file.
The file will exist temporarily at C{tempname} and be relocated to
C{destdir} when it is closed.
"""
def tell():
"""Return the current offset into the file, in bytes.
"""
def write(bytes):
"""Write some bytes to this file.
"""
def close(callback):
"""Close this file. Move it to its final location.
@param callback: A no-argument callable which will be invoked
when this file is ready to be moved to its final location. It
must return the segment of the path relative to per-user
storage of the owner of this file. Alternatively, a string
with semantics the same as those previously described for the
return value of the callable.
@rtype: C{axiom.store.StoreRelativePath}
@return: A Deferred which fires with the full path to the file
when it has been closed, or which fails if there is some error
closing the file.
"""
def abort():
"""Give up on this file. Discard its contents.
"""
class IAxiomaticCommand(Interface):
"""
Subcommand for 'axiomatic' and 'tell-axiom' command line programs.
Should subclass twisted.python.usage.Options and provide a command to run.
'.parent' attribute will be set to an object with a getStore method.
"""
name = Attribute("""
""")
description = Attribute("""
""")
class IBeneficiary(Interface):
"""
Interface to adapt to when looking for an appropriate application-level
object to install powerups on.
"""
def powerUp(implementor, interface):
""" Install a powerup on this object. There is not necessarily any inverse
powerupsFor on a beneficiary, although there may be; installations may
be forwarded to a different implementation object, or deferred.
"""
class IPowerupIndirector(Interface):
"""
Implement this interface if you want to change what is returned from
powerupsFor for a particular interface.
"""
def indirect(interface):
"""
When an item which implements IPowerupIndirector is returned from a
powerupsFor query, this method will be called on it to give it the
opportunity to return something other than itself from powerupsFor.
@param interface: the interface passed to powerupsFor
@type interface: L{zope.interface.Interface}
"""
class IScheduler(Interface):
"""
An interface for scheduling tasks. Quite often the store will be adaptable
to this; in any Mantissa application, for example; so it is reasonable to
assume that it is if your application needs to schedule timed events or
queue tasks.
"""
def schedule(runnable, when):
"""
@param runnable: any Item with a 'run' method.
@param when: a Time instance describing when the runnable's run()
method will be called. See extime.Time's documentation for more
details.
"""
class IQuery(Interface):
"""
An object that represents a query that can be performed against a database.
"""
limit = Attribute(
"""
An integer representing the maximum number of rows to be returned from
this query, or None, if the query is unlimited.
""")
store = Attribute(
"""
The Axiom store that this query will return results from.
""")
def __iter__():
"""
Retrieve an iterator for the results of this query.
The query is performed whenever this is called.
"""
def count():
"""
Return the number of results in this query.
NOTE: In most cases, this will have to load all of the rows in this
query. It is therefore very slow and should generally be considered
discouraged. Call with caution!
"""
def cloneQuery(limit):
"""
Create a similar-but-not-identical copy of this query with certain
attributes changed.
(Currently this only supports the manipulation of the "limit"
parameter, but it is the intent that with a richer query-introspection
interface, this signature could be expanded to support many different
attributes.)
@param limit: an integer, representing the maximum number of rows that
this query should return.
@return: an L{IQuery} provider with the new limit.
"""
class IColumn(Interface):
"""
An object that represents a column in the database.
"""
def getShortColumnName(store):
"""
@rtype: C{str}
@return: Just the name of this column.
"""
def getColumnName(store):
"""
@rtype: C{str}
@return: The fully qualified name of this object as a column within the
database, eg, C{"main_database.some_table.[this_column]"}.
"""
def fullyQualifiedName():
"""
@rtype: C{str}
@return: The fully qualfied name of this object as an attribute in
Python code, eg, C{myproject.mymodule.MyClass.myAttribute}. If this
attribute is represented by an actual Python code object, it will be a
dot-separated sequence of Python identifiers; otherwise, it will
contain invalid identifier characters other than '.'.
"""
def __get__(row):
"""
@param row: an item that has this column.
@type row: L{axiom.item.Item}
@return: The value of the column described by this object, for the given
row.
@rtype: depends on the underlying type of the column.
"""
class IOrdering(Interface):
"""
An object suitable for passing to the 'sort' argument of a query method.
"""
def orderColumns():
"""
Return a list of two-tuples of IColumn providers and either C{'ASC'} or
C{'DESC'} defining this ordering.
"""
class IComparison(Interface):
"""
An object that represents an in-database comparison. A predicate that may
apply to certain items in a store. Passed as an argument to
attributes.AND, .OR, and Store.query(...)
"""
def getInvolvedTables():
"""
Return a sequence of L{Item} subclasses which are referenced by this
comparison. A class may appear at most once.
"""
def getQuery(store):
"""
Return an SQL string with ?-style bind parameter syntax thingies.
"""
def getArgs(store):
"""
Return a sequence of arguments suitable for use to satisfy the bind
parameters in the result of L{getQuery}.
"""
class IReliableListener(Interface):
"""
Receives notification of the existence of Items of a particular type.
{IReliableListener} providers are given to
L{IBatchProcessor.addReliableListener} and will then have L{processItem}
called with items handled by that processor.
"""
def processItem(item):
"""
Callback notifying this listener of the existence of the given item.
"""
def suspend():
"""
Invoked when notification for this listener is being temporarily
suspended.
This should clean up any ephemeral resources held by this listener and
generally prepare to not do anything for a while.
"""
def resume():
"""
Invoked when notification for this listener is being resumed.
Any actions taken by L{suspend} may be reversed by this method.
"""
LOCAL, REMOTE = range(2)
class IBatchProcessor(Interface):
def addReliableListener(listener, style=LOCAL):
"""
Add the given Item to the set which will be notified of Items
available for processing.
Note: Each Item is processed synchronously. Adding too many
listeners to a single batch processor will cause the L{step}
method to block while it sends notification to each listener.
@type listener: L{IReliableListener}
@param listener: The item to which listened-for items will be passed
for processing.
"""
def removeReliableListener(listener):
"""
Remove a previously added listener.
"""
def getReliableListeners():
"""
Return an iterable of the listeners which have been added to
this batch processor.
"""
class IBatchService(Interface):
"""
Object which allows minimal communication with L{IReliableListener}
providers which are running remotely (that is, with the L{REMOTE} style).
"""
def suspend(storeID):
"""
@type storeID: C{int}
@param storeID: The storeID of the listener to suspend.
@rtype: L{twisted.internet.defer.Deferred}
@return: A Deferred which fires when the listener has been suspended.
"""
def resume(storeID):
"""
@type storeID: C{int}
@param storeID: The storeID of the listener to resume.
@rtype: L{twisted.internet.defer.Deferred}
@return: A Deferred which fires when the listener has been resumed.
"""
class IVersion(Interface):
"""
Object with version information for a package that creates Axiom
items, most likely a L{twisted.python.versions.Version}. Used to
track which versions of a package have been used to load a store.
"""
package = Attribute("""
Name of a Python package.
""")
major = Attribute("""
Major version number.
""")
minor = Attribute("""
Minor version number.
""")
micro = Attribute("""
Micro version number.
""")
|