Ticket #399: diff-ru-1.patch

File diff-ru-1.patch, 16.2 kB (added by tekNico, 3 years ago)

Patch for #398 and #399

  • trunk/Axiom/axiom/examples/bucket.py

    old new  
    11from axiom import item, attributes 
    22 
    33class Bucket(item.Item): 
    4     typeName = 'bucket' 
    5     schemaVersion = 1 
    6  
    74    name = attributes.text() 
    85 
    96    def getstuff(self): 
     
    1411 
    1512 
    1613class FoodItem(item.Item): 
    17     typeName = 'food' 
    18     schemaVersion = 1 
    19  
    2014    bucket = attributes.reference() 
    2115    extra = attributes.reference() 
    2216    deliciousness = attributes.integer(indexed=True) 
    2317 
    2418class Chicken(item.Item): 
    25     typeName = 'chicken' 
    26     schemaVersion = 1 
    27  
    2819    epistemologicalBasisForCrossingTheRoad = attributes.text() 
    2920    def what(self): 
    3021        print 'chicken!' 
    3122 
    3223class Biscuit(item.Item): 
    33     typeName = 'biscuit' 
    34     schemaVersion = 1 
    35  
    3624    fluffiness = attributes.integer() 
    3725    def what(self): 
    3826        print 'biscuits!' 
  • trunk/Axiom/axiom/examples/library.py

    old new  
    1919 
    2020 
    2121class Borrower(Item): 
    22     typeName = 'borrower' 
    23     schemaVersion = 1 
    2422    name = text(indexed=True) 
    2523 
    2624class Book(Item): 
    27     typeName = 'book' 
    28     schemaVersion = 1 
    29  
    3025    title = text() 
    3126    author = text() 
    3227    isbn = text() 
     
    3732    library = reference() 
    3833 
    3934class LendingLibrary(Item): 
    40     typeName = 'lending_library' 
    41     schemaVersion = 1 
    42  
    4335    name = text() 
    4436 
    4537    def books(self): 
  • trunk/Axiom/axiom/item.py

    old new  
    1111 
    1212_typeNameToMostRecentClass = {} 
    1313 
     14def normalize(qualName): 
     15    return qualName.lower().replace('.', '_') 
     16 
    1417class NoInheritance(RuntimeError): 
    1518    """ 
    1619    Inheritance is as-yet unsupported by XAtop. 
     
    3841            raise NoInheritance("already inherited from item once: " 
    3942                                "in-database inheritance not yet supported") 
    4043        if T.typeName is None: 
    41             raise NotImplementedError( 
    42                 "%s did not specify a typeName attribute" % (qual(T),)) 
     44            T.typeName = normalize(qual(T)) 
    4345        if T.schemaVersion is None: 
    44             raise NotImplementedError( 
    45                 "%s did not specify a schemaVersion attribute" % (qual(T),)) 
     46            T.schemaVersion = 1 
    4647        if T.typeName in _typeNameToMostRecentClass: 
    4748            if T.__legacy__: 
    4849                return T 
     
    513514        if self.store.autocommit: 
    514515            self.checkpoint() 
    515516 
    516     # You _MUST_ specify version in subclasses 
     517    # You may specify schemaVersion and typeName in subclasses 
    517518    schemaVersion = None 
    518519    typeName = None 
    519520 
     
    614615    """ 
    615616    I am a connector between the store and a powerup. 
    616617    """ 
    617     typeName = 'axiom_powerup_connector' 
    618     schemaVersion = 1 
    619  
    620618    powerup = reference() 
    621619    item = reference() 
    622620    interface = text() 
  • trunk/Axiom/axiom/test/itemtest.py

    old new  
    22from axiom import item, attributes 
    33 
    44class PlainItem(item.Item): 
    5     typeName = 'axiom_test_plain_item' 
    6     schemaVersion = 1 
    75 
    86    plain = attributes.text() 
  • trunk/Axiom/axiom/test/test_attributes.py

    old new  
    88import random 
    99 
    1010class Number(Item): 
    11     typeName = 'test_number' 
    12     schemaVersion = 1 
    13  
    1411    value = ieee754_double() 
    1512 
    1613 
     
    3229        self.assertRaises(TypeError, s.getItemByID, unicode(sid)) 
    3330 
    3431class SortedItem(Item): 
    35     typeName = 'test_sorted_thing' 
    36     schemaVersion = 1 
    37  
    3832    goingUp = integer() 
    3933    goingDown = integer() 
    4034    theSame = integer() 
  • trunk/Axiom/axiom/test/test_count.py

    old new  
    55from axiom.attributes import integer, AND, OR 
    66 
    77class ThingsWithIntegers(Item): 
    8     schemaVersion = 1 
    9     typeName = 'axiom_test_thing_with_integers' 
    10  
    118    a = integer() 
    129    b = integer() 
    1310 
    1411 
    1512class NotARealThing(Item): 
    16     schemaVersion = 1 
    17     typeName = 'axiom_test_never_created_item' 
    18  
    1913    irrelevantAttribute = integer() 
    2014 
    2115    def __init__(self, **kw): 
  • trunk/Axiom/axiom/test/test_files.py

    old new  
    99from axiom.attributes import path 
    1010 
    1111class PathTesterItem(Item): 
    12     schemaVersion = 1 
    13     typeName = 'test_path_thing' 
    14  
    1512    relpath = path() 
    1613    abspath = path(relative=False) 
    1714 
  • trunk/Axiom/axiom/test/test_inheritance.py

    old new  
    1212 
    1313    def testNoInheritance(self): 
    1414        class XA(Item): 
    15             schemaVersion = 1 
    16             typeName = 'inheritance_test_xa' 
    1715            a = integer() 
    1816 
    1917        try: 
    2018            class XB(XA): 
    21                 schemaVersion = 1 
    22                 typeName = 'inheritance_test_xb' 
    2319                b = integer() 
    2420        except NoInheritance: 
    2521            pass 
  • trunk/Axiom/axiom/test/test_item.py

    old new  
    4949 
    5050 
    5151class NoAttrsItem(item.Item): 
    52     typeName = 'noattrsitem' 
    53     schemaVersion = 1 
     52    pass 
    5453 
    5554class TestItem(unittest.TestCase): 
    5655    def testCreateItem(self): 
  • trunk/Axiom/axiom/test/test_mixin.py

    old new  
    3535    pass 
    3636 
    3737class ItemXYZ(Item, XYZ): 
    38     typeName = 'item_xyz' 
    39     schemaVersion = 1 
    40  
    4138    xm = integer(default=0) 
    4239    ym = integer(default=0) 
    4340    zm = integer(default=0) 
  • trunk/Axiom/axiom/test/test_powerup.py

    old new  
    2222 
    2323 
    2424class SumContributor(Item): 
    25     schemaVersion = 1 
    26     typeName = 'test_sum_contributor' 
    27  
    2825    value = integer() 
    2926 
    3027 
    3128class Summer(Item): 
    32     schemaVersion = 1 
    33     typeName = 'test_sum_doer' 
    34  
    3529    sumTimes = integer() 
    3630    sumTotal = integer() 
    3731 
     
    8781from twisted.application.service import IService, Service 
    8882 
    8983class SillyService(Item, Service): 
    90     typeName = 'test_silly_service' 
    91     schemaVersion = 1 
    92  
    9384    started = integer(default=0) 
    9485    stopped = integer(default=0) 
    9586    running = integer(default=0) 
  • trunk/Axiom/axiom/test/test_query.py

    old new  
    77from axiom.attributes import reference, text, bytes, integer, AND, OR 
    88 
    99class A(Item): 
    10     schemaVersion = 1 
    11     typeName = 'a' 
    12  
    1310    reftoc = reference() 
    1411    type = text(indexed=True) 
    1512 
    1613 
    1714class B(Item): 
    18     schemaVersion = 1 
    19     typeName = 'b' 
    20  
    2115    cref = reference() 
    2216    name = text(indexed=True) 
    2317 
    2418class C(Item): 
    25     schemaVersion = 1 
    26     typeName = 'c' 
    27  
    2819    name = text(indexed=True) 
    2920 
    3021class D(Item): 
    31     schemaVersion = 1 
    32     typeName = 'd' 
    3322    id = bytes() 
    3423    one = bytes() 
    3524    two = bytes() 
    3625    three = bytes() 
    3726 
    3827class E(Item): 
    39     schemaVersion = 1 
    40     typeName = 'e' 
    4128    name = text() 
    4229    transaction = text() 
    4330    amount = integer() 
    4431 
    4532 
    4633class ThingWithCharacterAndByteStrings(Item): 
    47     schemaVersion = 1 
    48  
    49     typeName = 'ThingWithCharacterAndByteStrings' 
    50  
    5134    characterString = text(caseSensitive=True) 
    5235    caseInsensitiveCharString = text(caseSensitive=False) 
    5336 
  • trunk/Axiom/axiom/test/test_queryutil.py

    old new  
    1111from axiom.queryutil import overlapping, AttributeTuple 
    1212 
    1313class Segment(Item): 
    14     typeName = 'test_overlap_segment' 
    15     schemaVersion = 1 
    16  
    1714    x = integer() 
    1815    y = integer() 
    1916 
     
    2118        return 'Segment<%d,%d>' % (self.x, self.y) 
    2219 
    2320class ABC(Item): 
    24     typeName = 'test_tuple_queries' 
    25     schemaVersion = 1 
    26  
    2721    a = integer(allowNone=False) 
    2822    b = integer(allowNone=False) 
    2923    c = integer(allowNone=False) 
  • trunk/Axiom/axiom/test/test_reference.py

    old new  
    55from axiom.attributes import integer, reference 
    66 
    77class Referee(Item): 
    8     schemaVersion = 1 
    9     typeName = "test_reference_referee" 
    10  
    118    topSecret = integer() 
    129 
    1310class SimpleReferent(Item): 
    14     schemaVersion = 1 
    15     typeName = "test_reference_referent" 
    16  
    1711    ref = reference() 
    1812 
    1913class SomeException(Exception): 
     
    3832 
    3933    def _makeReferentItem(self, whenDeleted, unique): 
    4034        class _Referent(Item): 
    41             schemaVersion = 1 
    42             typeName = "test_reference_referent_%r" % unique 
    43  
    4435            ref = reference(whenDeleted=whenDeleted) 
    4536 
    4637        return _Referent 
  • trunk/Axiom/axiom/test/test_scheduler.py

    old new  
    1919 
    2020class TestEvent(Item): 
    2121 
    22     typeName = 'test_event' 
    23     schemaVersion = 1 
    24  
    2522    deferred = inmemory()       # these won't fall out of memory due to 
    2623                                # caching, thanks. 
    2724    testCase = inmemory() 
  • trunk/Axiom/axiom/test/test_sequence.py

    old new  
    88 
    99 
    1010class SomeItem(Item): 
    11     schemaVersion = 1 
    12     typeName = 'test_sequence_some_item' 
    1311    foo = integer() 
    1412 
    1513    def __repr__(self): 
  • trunk/Axiom/axiom/test/test_substore.py

    old new  
    1010 
    1111class SubStored(Item): 
    1212 
    13     schemaVersion = 1 
    14     typeName = 'substoredthing' 
    1513    a = text() 
    1614    b = bytes() 
    1715 
  • trunk/Axiom/axiom/test/test_tablecreate.py

    old new  
    66from twisted.trial.unittest import TestCase 
    77 
    88class A(item.Item): 
    9     typeName = 'test_table_creator' 
    10     schemaVersion = 1 
    11  
    129    attr = attributes.integer(default=3) 
    1310 
    1411def setup(s): 
  • trunk/Axiom/axiom/test/test_tags.py

    old new  
    88from axiom.attributes import text 
    99 
    1010class Gizmo(Item): 
    11     typeName = 'test_gizmo' 
    12     schemaVersion = 1 
    1311    name = text() 
    1412 
    1513 
  • trunk/Axiom/axiom/test/test_unavailable_type.py

    old new  
    77        def makeItem(): 
    88            class MyItem(item.Item): 
    99 
    10                 typeName = 'test_deadtype_myitem' 
    11                 schemaVersion = 1 
    12  
    1310                hello = attributes.integer() 
    1411 
    1512            return MyItem 
  • trunk/Axiom/axiom/test/test_userbase.py

    old new  
    1919    pass 
    2020 
    2121class GarbageProtocolHandler(Item): 
    22     schemaVersion = 1 
    23     typeName = 'test_login_garbage' 
    24  
    2522    garbage = integer() 
    2623 
    2724    implements(IGarbage) 
     
    116113            [('nameuser', 'ain.dom'), ('username', 'dom.ain')]) 
    117114 
    118115class ThingThatMovesAround(Item): 
    119     typeName = 'test_thing_that_moves_around' 
    120     schemaVersion = 1 
    121  
    122116    superValue = integer() 
    123117 
    124118class SubStoreMigrationTestCase(unittest.TestCase): 
  • trunk/Axiom/axiom/test/test_xatop.py

    old new  
    2222 
    2323 
    2424class TestItem(item.Item): 
    25     schemaVersion = 1 
    26     typeName = 'TestItem' 
    2725    foo = attributes.integer(indexed=True) 
    2826    bar = attributes.text() 
    2927    baz = attributes.timestamp() 
     
    164162 
    165163 
    166164class AttributefulItem(item.Item): 
    167     schemaVersion = 1 
    168     typeName = 'test_attributeful_item' 
    169  
    170165    withDefault = attributes.integer(default=42) 
    171166    withoutDefault = attributes.integer() 
    172167 
     
    175170            self.storeID, self.withDefault, self.withoutDefault) 
    176171 
    177172class StricterItem(item.Item): 
    178     schemaVersion = 1 
    179     typeName = 'test_stricter_item' 
    180  
    181173    aRef = attributes.reference(allowNone=False) 
    182174 
    183175 
jethro@divmod.org