当前位置: 首页>>代码示例>>Python>>正文


Python pb.setUnjellyableForClass函数代码示例

本文整理汇总了Python中twisted.spread.pb.setUnjellyableForClass函数的典型用法代码示例。如果您正苦于以下问题:Python setUnjellyableForClass函数的具体用法?Python setUnjellyableForClass怎么用?Python setUnjellyableForClass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setUnjellyableForClass函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remote_registerClasses

    def remote_registerClasses(self, *args):
        """
        Instructs my broker to register the classes specified by the
        argument(s).

        The classes will be registered for B{all} jobs, and are specified by
        their string representations::
        
            <package(s).module.class>
        
        """
        modules = []
        for stringRep in args:
            # Load the class for the string representation
            cls = reflect.namedObject(stringRep)
            # Register instances of the class, including its type and module
            pb.setUnjellyableForClass(stringRep, cls)
            if cls.__module__ not in modules:
                modules.append(cls.__module__)
        # Try to build the modules for the classes in case they've changed
        # since the last run
        for module in modules:
            try:
                rebuild(reflect.namedModule(module), doLog=False)
            except:
                pass
开发者ID:D3f0,项目名称:txscada,代码行数:26,代码来源:jobs.py

示例2: discover

def discover():
    for m in __all__:
        for name, obj in inspect.getmembers(sys.modules[m]):
            if inspect.isclass(obj) and \
                    issubclass(obj, operators.Operator):
                if  hasattr(obj, "operator_name"):
                    installed_ops[obj.operator_name] = obj

                # register all operators with the perspective broker
                # so we can remote-call them if we want to.
                pb.setUnjellyableForClass(obj, obj)
开发者ID:ahaas,项目名称:smap,代码行数:11,代码来源:__init__.py

示例3: getTimeStamp

    def getTimeStamp(self):
        """Get the timestamp for the message
        @returns: the timestamp or None
        @rtype: int
        """
        # F0.4: timestamp was added in 0.4.2
        return getattr(self, 'timestamp', None)

    def getDescription(self):
        """Get the description for the message
        @returns: the description or None
        @rtype: str
        """
        return getattr(self, 'description', None)

pb.setUnjellyableForClass(Message, Message)

# these are implemented as factory functions instead of classes because
# properly proxying to the correct subclass is hard with Copyable/RemoteCopy


def Error(*args, **kwargs):
    """
    Create a L{Message} at ERROR level, indicating a failure that needs
    intervention to be resolved.
    """
    return Message(ERROR, *args, **kwargs)

# FIXME: figure out a way to not be shadowing the Warning builtin without
# breaking all other code
__pychecker__ = 'no-shadowbuiltin'
开发者ID:flyapen,项目名称:UgFlu,代码行数:31,代码来源:messages.py

示例4: SynchronousError

class SynchronousError(pb.Error):
    """
    Helper used to test remote methods which raise exceptions which are
    L{pb.Error} subclasses.
    """


#class JellyError(flavors.Jellyable, pb.Error): pass
class JellyError(flavors.Jellyable, pb.Error, pb.RemoteCopy):
    pass


class SecurityError(pb.Error, pb.RemoteCopy):
    pass

pb.setUnjellyableForClass(JellyError, JellyError)
pb.setUnjellyableForClass(SecurityError, SecurityError)
pb.globalSecurity.allowInstancesOf(SecurityError)


####
# server-side
####
class SimpleRoot(pb.Root):
    def remote_asynchronousException(self):
        """
        Fail asynchronously with a non-pb.Error exception.
        """
        return defer.fail(AsynchronousException("remote asynchronous exception"))

    def remote_synchronousException(self):
开发者ID:Architektor,项目名称:PySnip,代码行数:31,代码来源:test_pbfailure.py

示例5: __init__

"""
Created on 2015-4-24

@author: kong.lihua

This module is used to send complex object between sever and client.
"""
from twisted.spread import pb


class Request:
    def __init__(self, name, paraDict):
        self.name = name
        self.paraDict = paraDict


class ClientRequest(Request, pb.Copyable):
    pass


class ServerRequest(pb.RemoteCopy, Request):
    pass


pb.setUnjellyableForClass(ClientRequest, ServerRequest)
开发者ID:cici0647,项目名称:SFIT_TradeSystemEngine,代码行数:25,代码来源:reqClazz.py

示例6: RemoteException

    'message':4096
}


class RemoteException(Exception, pb.Copyable, pb.RemoteCopy):
    """Exception that can cross the PB barrier"""

    def __init__(self, msg, tb):
        Exception.__init__(self, msg)
        self.traceback = tb

    def __str__(self):
        return "%s: %s" % (
            Exception.__str__(self), self.traceback or '<no traceback>')

pb.setUnjellyableForClass(RemoteException, RemoteException)


# ZODB conflicts
class RemoteConflictError(RemoteException): pass
pb.setUnjellyableForClass(RemoteConflictError, RemoteConflictError)


# Invalid monitor specified
class RemoteBadMonitor(RemoteException): pass


def translateError(callable):
    """
    Decorator function to wrap remote exceptions into something
    understandable by our daemon.
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:31,代码来源:PBDaemon.py

示例7: __repr__

        Subclasses should override to add additional information.
        """
        return {'id': self.id,
                'requester': self.requesterId,
                'domain': self.domain}

    def __repr__(self):
        return "<%s for requesterId %r in state %s>" % (
            self.__class__.__name__,
            self.requesterId, _statesEnum[self.state])


class KeycardGeneric(Keycard, object):
    pass

pb.setUnjellyableForClass(KeycardGeneric, KeycardGeneric)
# class KeycardUACCP: username, address, crypt password
#       from UsernameCryptPasswordCrypt


UCPP = credentials.UsernameCryptPasswordPlaintext


class KeycardUACPP(Keycard, UCPP):
    """
    I am a keycard with a username, plaintext password and IP address.
    I get authenticated against a crypt password.
    """

    def __init__(self, username, password, address):
        UCPP.__init__(self, username, password)
开发者ID:ylatuya,项目名称:Flumotion,代码行数:31,代码来源:keycards.py

示例8: __init__

    def __init__(self):
        pass

    def __str__(self):
        """
        Override the Python default to represent ourselves as a string
        """
        return str(self.name)
    __repr__ = __str__

    def processClassPrimaryUrlPath(self):
        return self.primaryUrlPath


pb.setUnjellyableForClass(ProcessProxy, ProcessProxy)


class ProcessConfig(CollectorConfigService):

    def __init__(self, dmd, instance):
        deviceProxyAttributes = ('zMaxOIDPerRequest',)
        CollectorConfigService.__init__(self, dmd, instance, deviceProxyAttributes)

    def _filterDevice(self, device):
        include = CollectorConfigService._filterDevice(self, device)
        include = include and device.snmpMonitorDevice()

        return include

    def _createDeviceProxy(self, device, proxy=None):
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:30,代码来源:ProcessConfig.py

示例9: MetricId

class MetricId(pb.Copyable, pb.RemoteCopy):

    instance = ""

    def __init__(self, counterId, instance=""):
        self.counterId = counterId
        self.instance = instance

    def __str__(self):
        retString = str(self.counterId)
        if self.instance and len(self.instance) > 0:
            retString += "|" + self.instance
        return retString


pb.setUnjellyableForClass(MetricId, MetricId)

clientCache = {}


def createGAEClient(username, password, printTrace=False, nocache=False, logseverity=logging.INFO):
    client = None
    if not nocache and clientCache.has_key(username):
        client = clientCache[username]
        if not client.loggedIn:
            client = None
    if not client:
        client = GAEClient(username, password, printTrace, logseverity)
    if not nocache:
        clientCache[username] = client
开发者ID:anksp21,项目名称:Community-Zenpacks,代码行数:30,代码来源:gaeclient.py

示例10: ManagerComponentUIState


class ManagerComponentUIState(flavors.StateCacheable,
                              flavors.StateRemoteCache):

    def processUniqueID(self):
        # Make sure proxies for the same object are the same, if we are
        # later cached by someone else. See bug #519.
        return id(self.__dict__)


class AdminComponentUIState(flavors.StateRemoteCache):
    pass


pb.setUnjellyableForClass(WorkerComponentUIState, ManagerComponentUIState)
pb.setUnjellyableForClass(ManagerComponentUIState, AdminComponentUIState)


class WizardEntryState(pb.RemoteCopy):

    def getAcceptedMediaTypes(self):
        """
        Fetches a list of media types this components accepts.
        @returns: a list of strings
        """
        return [format.media_type for format in self.accepts]

    def getProvidedMediaTypes(self):
        """
        Fetches a list of media types this components provides.
开发者ID:flyapen,项目名称:UgFlu,代码行数:29,代码来源:componentui.py

示例11: updateConfig

        """
        if pid in self.pids:
            del self.pids[pid]

    def updateConfig(self, update):
        """
        """
        if self is update:
            return
        self.name = update.name
        self.originalName = update.originalName
        self.ignoreParameters = update.ignoreParameters
        self.restart = update.restart
        self.severity = update.severity

pb.setUnjellyableForClass(Process, Process)


class Device(pb.Copyable, pb.RemoteCopy):
    """
    Track device data
    """
    name = ''
    snmpConnInfo = None
    proxy = None
    lastScan = 0.
    snmpStatus = 0
    lastChange = 0
    maxOidsPerRequest = 40

    def __init__(self):
开发者ID:alecsandrb,项目名称:Community-Zenpacks,代码行数:31,代码来源:zensunprocess.py

示例12: Observer

        self.d = d
        return d


class Observer(pb.Referenceable):
    notified = 0
    obj = None
    def remote_notify(self, other, obj):
        self.obj = obj
        self.notified = self.notified + 1
        other.callRemote('unobserve',self)

class NewStyleCopy(pb.Copyable, pb.RemoteCopy, object):
    def __init__(self, s):
        self.s = s
pb.setUnjellyableForClass(NewStyleCopy, NewStyleCopy)

class NewStyleCopy2(pb.Copyable, pb.RemoteCopy, object):
    allocated = 0
    initialized = 0
    value = 1
    def __new__(self):
        NewStyleCopy2.allocated += 1
        inst = object.__new__(self)
        inst.value = 2
        return inst
    def __init__(self):
        NewStyleCopy2.initialized += 1

pb.setUnjellyableForClass(NewStyleCopy2, NewStyleCopy2)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:30,代码来源:test_pb.py

示例13: __init__

#! /usr/bin/python

from twisted.spread import pb

class FrogPond:
    def __init__(self, numFrogs, numToads):
        self.numFrogs = numFrogs
        self.numToads = numToads
    def count(self):
        return self.numFrogs + self.numToads

class SenderPond(FrogPond, pb.Copyable):
    def getStateToCopy(self):
        d = self.__dict__.copy()
        d['frogsAndToads'] = d['numFrogs'] + d['numToads']
        del d['numFrogs']
        del d['numToads']
        return d

class ReceiverPond(pb.RemoteCopy):
    def setCopyableState(self, state):
        self.__dict__ = state
    def count(self):
        return self.frogsAndToads

pb.setUnjellyableForClass(SenderPond, ReceiverPond)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:26,代码来源:copy2_classes.py

示例14: __init__

    (interfacegl.DrawMenu, RemoteDrawMenu),
    (interfacegl.DrawObjectPick, RemoteDrawObjectPick),
    (interfacegl.DrawObjectHilight, RemoteDrawObjectHilight),
    (interfacegl.DrawObjectHighLight, RemoteDrawObjectHighLight),
    (interfacegl.DrawTmpVertex, RemoteDrawTmpVertex),
    (interfacegl.DrawTmpEdge, RemoteDrawTmpEdge),
    (camera.Camera, RemoteCamera),
    (camera.OrthoCamera, RemoteCamera),
    (graph.Graph, RemoteGraph),
    (graph.Vertex, RemoteVertex),
    (graph.DummyVertex, RemoteDummyVertex),
    (graph.Edge, RemoteEdge),
    (graph.SuperEdge, RemoteSuperEdge),
]
for src, tgt in mappings:
    pb.setUnjellyableForClass(src, tgt)


class Handler:
    def __init__(self, reactor, deliver):
        self.serverRef = None
        self.reactor = reactor
        self.deliver = deliver

    def error(self, obj):
        print "error:", str(obj)
        self.reactor.stop()

    def getmaker(self, obj):
        print "got maker:", obj
        self.serverRef = obj
开发者ID:ulethHCI,项目名称:GLuskap,代码行数:31,代码来源:remoteobjs.py

示例15:

from twisted.spread import pb
import engine.Light
import engine.Map
import engine.Unit
import engine.Ability
import engine.Class
import engine.Scenario
import engine.Range
import engine.Effect
import engine.Light
import engine.Equipment
import engine.Battle

pb.setUnjellyableForClass(engine.Light.Light, engine.Light.Light)
pb.setUnjellyableForClass(engine.Map.MapSquare, engine.Map.MapSquare)
pb.setUnjellyableForClass(engine.Map.Map, engine.Map.Map)
pb.setUnjellyableForClass(engine.Unit.Unit, engine.Unit.Unit)
pb.setUnjellyableForClass(engine.Unit.StatusEffects, engine.Unit.StatusEffects)
pb.setUnjellyableForClass(engine.Ability.Ability, engine.Ability.Ability)
pb.setUnjellyableForClass(engine.Class.Class, engine.Class.Class)
pb.setUnjellyableForClass(engine.Scenario.Scenario, engine.Scenario.Scenario)
pb.setUnjellyableForClass(engine.Range.Line, engine.Range.Line)
pb.setUnjellyableForClass(engine.Range.Cross, engine.Range.Cross)
pb.setUnjellyableForClass(engine.Range.Diamond, engine.Range.Diamond)
pb.setUnjellyableForClass(engine.Range.DiamondExtend, engine.Range.DiamondExtend)
pb.setUnjellyableForClass(engine.Range.Single, engine.Range.Single)

pb.setUnjellyableForClass(engine.Effect.Damage, engine.Effect.Damage)
pb.setUnjellyableForClass(engine.Effect.DamageSP, engine.Effect.DamageSP)
pb.setUnjellyableForClass(engine.Effect.DrainLife, engine.Effect.DrainLife)
pb.setUnjellyableForClass(engine.Effect.HealFriendlyDamageHostile, engine.Effect.HealFriendlyDamageHostile)
开发者ID:jemofthewest,项目名称:GalaxyMage,代码行数:31,代码来源:netsupport.py


注:本文中的twisted.spread.pb.setUnjellyableForClass函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。