Beispiel #1
0
def object_hook(class_name, data):
    reg = {'Album': Album, 'AlbumItem': AlbumItem, 'Image': Image}
    clazz = reg.get(class_name)
    if not clazz:
        return phpobject(class_name, data)

    return clazz(**data)
Beispiel #2
0
def object_hook(class_name, data):
    reg = {'Album': Album, 'AlbumItem': AlbumItem, 'Image': Image}
    clazz = reg.get(class_name)
    if not clazz:
        return phpobject(class_name, data)

    return clazz(**data)
Beispiel #3
0
 def object_hook(obj):
     if isinstance(obj, Logger):
         return phpobject(
             'Logger', {
                 b'\x00Logger\x00initMsg': obj.initMsg,
                 b'\x00Logger\x00exitMsg': obj.exitMsg,
                 b'\x00Logger\x00logFile': obj.logFile
             })
Beispiel #4
0
    def to_php(self):
        """
        PHP representation
        :return:
        """
        js = collections.OrderedDict()
        js['socket'] = None
        obj = phpserialize.phpobject('App\\Events\\TesterJobProgress', js)
        util.php_set_protected(obj, 'json_data', json.dumps(self.json_data))

        return obj
Beispiel #5
0
    def to_php(self):
        """
        php serialization
        :return: 
        """
        js = collections.OrderedDict()
        js['class'] = self.cls
        js['method'] = self.method
        js['data'] = [util.phpize(x) for x in self.data]
        js['tries'] = self.tries
        js['timeout'] = self.timeout

        obj = phpserialize.phpobject(self.invoker, js)
        util.php_set_protected(obj, 'job', None)

        return obj
Beispiel #6
0
 def dump_object_hook(obj):
     if isinstance(obj, User):
         return phpserialize.phpobject('WP_User', {'username': obj.username})
     raise LookupError('unknown object')
Beispiel #7
0
 def dump_object_hook(obj):
     if isinstance(obj, User):
         return phpserialize.phpobject('WP_User',
                                       {'username': obj.username})
     raise LookupError('unknown object')