免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2381 | 回复: 0
打印 上一主题 下一主题

twisted.spread 中pb.setUnjellyableForClass怎么用 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-07 09:25 |只看该作者 |倒序浏览
本帖最后由 307183927 于 2011-09-07 09:32 编辑

部分代码zenoss-api_2.5.0\api\Products.ZenStatus.zenstatus-module.html
  1. import sys
  2. import os
  3. import time
  4. import socket
  5. import ip
  6. import icmp
  7. import errno
  8. import logging
  9. log = logging.getLogger("zen.Ping")

  10. from twisted.internet import reactor, defer
  11. from twisted.spread import pb

  12. class PermissionError(Exception):
  13.     """Not permitted to access resource."""

  14. class IpConflict(Exception):
  15.     """Pinging two jobs simultaneously with different hostnames but the same IP"""

  16. class PingJob(pb.Copyable, pb.RemoteCopy):
  17.     """
  18.     Class representing a single target to be pinged.
  19.     """
  20.     def __init__(self, ipaddr, hostname="", status=0, unused_cycle=60):
  21.         self.parent = False
  22.         self.ipaddr = ipaddr
  23.         self.hostname = hostname
  24.         self.status = status
  25.         self.reset()


  26.     def reset(self):
  27.         self.deferred = defer.Deferred()
  28.         self.rrt = 0
  29.         self.start = 0
  30.         self.sent = 0
  31.         self.message = ""
  32.         self.severity = 5
  33.         self.inprocess = False
  34.         self.pathcheck = 0
  35.         self.eventState = 0


  36.     def checkpath(self):
  37.         if self.parent:
  38.             return self.parent.checkpath()   

  39.     def routerpj(self):
  40.         if self.parent:
  41.             return self.parent.routerpj()

  42. pb.setUnjellyableForClass(PingJob, PingJob)
复制代码
from twisted.spread import pb
pb.setUnjellyableForClass(PingJob, PingJob)



setUnjellyableForClass是什么意识,什么作用啊,看英文不大懂
  1. def setUnjellyableForClass(classname, unjellyable):
  2.     """
  3.     Set which local class will represent a remote type.

  4.     If you have written a Copyable class that you expect your client to be
  5.     receiving, write a local "copy" class to represent it, then call::

  6.         jellier.setUnjellyableForClass('module.package.Class', MyCopier).

  7.     Call this at the module level immediately after its class
  8.     definition. MyCopier should be a subclass of RemoteCopy.

  9.     The classname may be a special tag returned by
  10.     'Copyable.getTypeToCopyFor' rather than an actual classname.

  11.     This call is also for cached classes, since there will be no
  12.     overlap.  The rules are the same.
  13.     """

  14.     global unjellyableRegistry
  15.     classname = _maybeClass(classname)
  16.     unjellyableRegistry[classname] = unjellyable
  17.     globalSecurity.allowTypes(classname)
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP