混合SSL证书(Mix SSL certificates)
我想为从域B加载图像的domainA获得SSL证书(我从另一个无cookie域加载它们以提高页面速度)。 我知道来自domainB的所有元素都应该通过SSL,但是我需要使用来自同一提供者的证书来保护第二个域吗? 我的意思是,我可以混合一个网页与一个ie verisign证书与图像来自另一个域名与另一个不同的 - 更便宜的证书SSL?
I'd like to have a SSL certificate for domainA that load images from domainB (I load them from another cookieless domain to improve page speed). I know that all elements coming from domainB should be over SSL, but do i need to secure this second domain with a certificate coming from the same provider? I mean, could I mix a page with a ie verisign certificate with images coming over SSL from another domain with a different - and cheaper - certificate?
原文:https://stackoverflow.com/questions/6408125
最满意答案
你正在寻找
classmethod
,而不是staticmethod
。 如果使用@classmethod
修饰方法,它将隐式接收该类作为第一个参数。You are looking for
classmethod
, notstaticmethod
. If you decorate a method with@classmethod
, it will implicitly receive the class as first parameter.See also the related question Meaning of @classmethod and @staticmethod for beginner?
相关问答
更多-
你想用这种staticmethod实现什么? 如果你不知道它是什么,你如何期待它解决你的问题? 或者你只是在玩耍,看看staticmethod做什么? 在这种情况下, 阅读文档可能会更有成效,而不是随意应用它,并试图从行为中猜测它的功能。 无论如何,将@staticmethod应用到类中的函数定义中会产生一个“静态方法”。 不幸的是,“静态”是编程中最容易混淆的重载术语之一; 这意味着该方法不依赖于或改变对象的状态 。 如果我在类Bar定义了一个静态方法foo ,那么调用bar.foo(...) (其中ba ...
-
在玩了一会儿之后,我找到了一个比SO中的其他方法更好的解决方案。 也许这对某人有帮助。 基本上这个想法如下: 检测类或静态方法的成员 获取包含在这些方法中的函数对象 将装饰器应用于此功能 将装饰函数包装在classmethod或staticmethod实例中 再次将它存储在课堂上 代码如下所示: def class_decorator(cls): for name, member in vars(cls).items(): # Good old function object, ju ...
-
你正在寻找classmethod ,而不是staticmethod 。 如果使用@classmethod修饰方法,它将隐式接收该类作为第一个参数。 另请参阅相关问题@classmethod和@staticmethod对初学者的意义? You are looking for classmethod, not staticmethod. If you decorate a method with @classmethod, it will implicitly receive the class as firs ...
-
给你几点想法: 静态方法的操作与类装饰器的运算符完全正交。 将函数变为静态方法仅影响在属性查找过程中发生的情况。 类装饰器是对类的编译时转换。 functools.wraps中没有“bug”。 它所做的就是将函数属性从一个函数复制到另一个函数。 正如目前所写,您的记忆工具不会考虑类方法和静态方法的不同调用签名。 这是在记忆中的一个弱点,而不是在课堂工具本身。 我认为你已经想像了类装饰器,静态方法,类方法和functools等工具具有某种相互整合的智能。 相反,所有这些工具都非常简单,需要程序员有意识地设计他 ...
-
python中的单元测试,用于类文件的大__init__代码(unit tests in python with large __init__ code for class file)[2024-02-29]
如果实例化类需要很长时间,并且多个测试可以使用相同的实例,那么可以使用setUpClass import unittest class MyTests(unittest.TestCase): @classmethod def setUpClass(cls): cls.obj = MyClass() def test_stuff(self): self.assertEqual(self.obj.thing, 10) If instantiating ... -
python class []函数(python class [] function)[2022-03-27]
欢迎光临;-) 它看起来像你的意思是__getitem__(self, key) 。 和__setitem__(self, key, value) 。 尝试: class my_class(object): def __getitem__(self, key): return some_value_based_upon(key) #You decide the implementation here! def __setitem__(self, key, value): ... -
基本的Python类(Basic Python Class)[2023-03-12]
只需访问属性: class BodyMassIndex(object): #Inheriting from object in 2.x ensures a new-style class. count = 0 def __init__(self, name, weight, height): self.name = name self.weight = 14 * weight self.height = 12 * height self.notes = None ... -
Python魔术元类创建(Python magic meta class creation)[2022-12-05]
我不知道如何使用元类来完成此操作,但这是使用mixin类的可能解决方案。 你可以使用这样的东西。 from inspect import signature from functools import partialmethod, partial class Naked: @staticmethod def echo1(foo): return f"echo1: {foo}" @staticmethod def echo2 ... -
在Python3中注释static方法的返回类型[复制](Annotating the return type of a staticmethod in Python3 [duplicate])[2022-09-18]
发布后我发现了正确的答案 - 前向引用可以定义为字符串。 因此,正确答案相当简单,并且PyCharm会获得奖励: @staticmethod def from_other_datastructure(json_data: str) -> 'MyThing': return MyThing( [int(d) for d in json_data.split(',')] ) https://www.python.org/dev/peps/pep-0484/#forward-re ... -
我会尝试解释它是如何工作的。 首先,这是运行: a_game = Game("central_corridor") 这称为Game.__init__("central_corridor") 。 在__init__方法中, self.start取值“central_corridor”。 然后我们回到主体。 到目前为止,我们有一个名为a_game的变量。 这个变量实际上是Game类的一个实例,它有一些属性,比如a_game.start , a_game.quips , a_game.death()等。 接下来 ...