• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python modelsinspector.add_introspection_rules函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(self, *args, **kwargs):
     kwargs.setdefault('max_length', 7)
     kwargs.setdefault('choices', [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES])
     add_introspection_rules([], ["^languages\.fields\.LanguageField"])
     
     
     super(LanguageField, self).__init__(*args, **kwargs)
开发者ID:seanherron,项目名称:data-inventory,代码行数:7,代码来源:fields.py


示例2: try_initialize_south

def try_initialize_south():
    try:
        import south
    except ImportError:
        # No south in pypath
        return
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^current_user\.models\.CurrentUserField"])
开发者ID:wnt-zhp,项目名称:hufce,代码行数:8,代码来源:_south.py


示例3: register_south_field

def register_south_field(field_class):
    # make the fields work in South
    from south.modelsinspector import add_introspection_rules
    module = field_class.__module__
    regex = r'^%s\.%s' % (re.escape(module), field_class.__name__)

    add_introspection_rules([], [regex])
    return field_class
开发者ID:opennewzealand,项目名称:linz2osm,代码行数:8,代码来源:db_fields.py


示例4: add_to_introspection_rule

 def add_to_introspection_rule(self):
     try:
         from south.modelsinspector import add_introspection_rules
     except ImportError:
         pass
     else:
         add_introspection_rules(
             [([JsonDataField], [], {}), ],
             ["^gtoolkit\.db\.fields\.JsonDataField"])
开发者ID:subc,项目名称:anchovy,代码行数:9,代码来源:fields.py


示例5: add_south_rules

def add_south_rules():
    from south.modelsinspector import add_introspection_rules

    add_introspection_rules([
        (
            (VersionField,),
            [],
            {'partial': ('partial', {'default': False})},
        ),
    ], ["semantic_version\.django_fields"])
开发者ID:leekchan,项目名称:python-semanticversion,代码行数:10,代码来源:django_fields.py


示例6: add_south_rules

def add_south_rules():
    from south.modelsinspector import add_introspection_rules

    add_introspection_rules([
        (
            (VersionField,),
            [],
            {},
        ),
    ], ["whatsnew\.fields"])
开发者ID:pombredanne,项目名称:django-whatsnew,代码行数:10,代码来源:fields.py


示例7: ready

    def ready(self):
        from south.modelsinspector import add_introspection_rules
        add_introspection_rules([], ["^markupfield\.fields\.MarkupField"])

        # ping_details = {'blogango_details': pingback_blog_handler}
        from pingback import register_pingback, ping_func
        from . import pingback_blog_handler
        from django_xmlrpc import xmlrpcdispatcher

        register_pingback('blogango.views.details', pingback_blog_handler)

        xmlrpcdispatcher.register_function(ping_func, 'pingback.ping')
开发者ID:gsinovsky,项目名称:django-blogango,代码行数:12,代码来源:apps.py


示例8: load_object_field

def load_object_field():
    try:
        from south.modelsinspector import add_introspection_rules
    except ImportError:
        pass
    else:
        add_introspection_rules(
            [([ObjectField], [], {}),],
            ["^gtoolkit\.db\.fields\.ObjectField"])
        add_introspection_rules(
            [([UniqueIDField], [], {}),],
            ["^gtoolkit\.db\.fields\.UniqueIDField"])
开发者ID:subc,项目名称:anchovy,代码行数:12,代码来源:fields.py


示例9: add_south_introspector_rules

def add_south_introspector_rules():
    from south.modelsinspector import add_introspection_rules

    rules = [
        (
            (StateFlowField, ),
            [],
            {
                "flow": ["flow_path", {}],
            }
        ),
    ]

    add_introspection_rules(rules, ["^stateflow\.statefields"])
开发者ID:Deepwalker,项目名称:django-stateflow,代码行数:14,代码来源:statefields.py


示例10: try_initialize_south

def try_initialize_south():
    try:
        import south
    except ImportError:
        # No south in pypath
        return
    from south.modelsinspector import add_introspection_rules

    from .fields import DictionaryField
    rules = [(
         (DictionaryField,),
         [],
             {
             'type': ['type', {}],
#             'render_pattern': ['render_pattern', {'default', None}],
             },
         )]
    add_introspection_rules(rules, ["^django_dict\.fields\.DictionaryField"])
开发者ID:jbzdak,项目名称:django-dict,代码行数:18,代码来源:_south.py


示例11: super

        self._dbtype = dbtype

        kwargs.setdefault('blank', True)
        kwargs.setdefault('null', True)
        kwargs.setdefault('default', None)

        super(GeometricField, self).__init__(*args, **kwargs)

    def db_type(self, connection):
        return self._dbtype.db_type(connection)

    def get_db_prep_value(self, value, connection, prepared=False):
        value = value if prepared else self.get_prep_value(value)
        return value

    def to_python(self, value):
        return value

try:
    from south.modelsinspector import add_introspection_rules
    from .objects import Point
    add_introspection_rules([
        (
            [GeometricField], # class
            [],               # positional params
            {'dbtype': ["_dbtype", {"default": Point}]}, # kwargs
        )
    ], ['django_orm\.postgresql\.geometric\.fields\.GeometricField'])
except ImportError:
    pass
开发者ID:cr8ivecodesmith,项目名称:django-orm-extensions-save22,代码行数:30,代码来源:fields.py


示例12: __init__

    """
    The image field based on django-filebrowser, SORL thumbnail or any other image library.
    It's a drop-in replacement for the django :class:`~django.db.models.ImageField`

    When *django-filebrowser* is not installed, it will display the
    standard :class:`~django.db.models.ImageField` with a preview attached to it.
    """
    def __init__(self, *args, **kwargs):
        # django-filebrowser has no concept of a 'width_field',
        # only Django's ImageField has this feature.
        if 'width_field' in kwargs:
            raise NotImplementedError("Unable to use 'width_field' in AnyImageField, not all backends support this feature.")
        if 'height_field' in kwargs:
            raise NotImplementedError("Unable to use 'height_field' in AnyImageField, not all backends support this feature.")

        super(AnyImageField, self).__init__(*args, **kwargs)



# Tell South how to create custom fields
try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], [
        "^any_imagefield\.models\.fields\.AnyFileField",
        "^any_imagefield\.models\.fields\.AnyImageField",
        "^any_imagefield\.models\.fields\.backends\.([^.]+)\.AnyFileField",
        "^any_imagefield\.models\.fields\.backends\.([^.]+)\.AnyImageField",
    ])
except ImportError:
    pass
开发者ID:rantecki,项目名称:django-any-imagefield,代码行数:30,代码来源:fields.py


示例13: AddressPickerField

from django.db import models
from django import forms
from .widjets import AddressPickerWidget


class AddressPickerField(models.CharField):
    def __init__(self, *args, **kwargs):
        super(AddressPickerField, self).__init__(*args, **kwargs)

    def formfield(self, **kwargs):
        defaults = {
            'form_class': AddressPickerFormField,
        }
        defaults.update(kwargs)
        return super(AddressPickerField, self).formfield(**defaults)


class AddressPickerFormField(forms.fields.CharField):
    def __init__(self, *args, **kwargs):
        kwargs.update({'widget': AddressPickerWidget()})
        super(AddressPickerFormField, self).__init__(*args, **kwargs)


try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^addresspicker\.fields\.AddressPickerField"])
except ImportError:
    pass
开发者ID:Wildhind,项目名称:django-addresspicker,代码行数:28,代码来源:fields.py


示例14: add_introspection_rules

from django.db.models import FileField
from django import forms
from django.utils.translation import ugettext as _
import pyfits
from specreduce.specreduce import OneDimensionalSpectrumValidator
from specreduce.specreduce import ValidationError

from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^spectra\.extra\.OneDimensionalSpectrumFileField"])
class OneDimensionalSpectrumFileField(FileField):

    def clean(self, *args, **kwargs):
        data = super(OneDimensionalSpectrumFileField, self).clean(*args, **kwargs)
        # This will raise IOError if there is a parse failure
        try:
            hdulist = pyfits.open(data.file)
        except IOError as e:
            raise forms.ValidationError(_('Unable to parse FITS file: %s' % e))

        try:
            OneDimensionalSpectrumValidator(hdulist).validate()
        except ValidationError as e:
            raise forms.ValidationError(_('FITS validation failed: %s' % e))

        return data
开发者ID:malclocke,项目名称:idas,代码行数:25,代码来源:extra.py


示例15: callable

        if self.has_default():
            if callable(self.default):
                return self.default()
            return copy.deepcopy(self.default)
        # If the field doesn't have a default, then we punt to models.Field.
        return super(JSONFieldBase, self).get_default()


class JSONField(JSONFieldBase, models.TextField):
    """JSONField is a generic textfield that serializes/deserializes JSON objects"""
    form_class = JSONFormField

    def dumps_for_display(self, value):
        kwargs = {"indent": 2}
        kwargs.update(self.dump_kwargs)
        return json.dumps(value, ensure_ascii=False, **kwargs)


class JSONCharField(JSONFieldBase, models.CharField):
    """JSONCharField is a generic textfield that serializes/deserializes JSON objects,
    stored in the database like a CharField, which enables it to be used
    e.g. in unique keys"""
    form_class = JSONCharFormField


try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^jsonfield\.fields\.(JSONField|JSONCharField)"])
except ImportError:
    pass
开发者ID:bradjasper,项目名称:django-jsonfield,代码行数:30,代码来源:fields.py


示例16: introspector

        # We'll just introspect the _actual_ field.
        try:
            from south.modelsinspector import introspector
            field_class = self.__class__.__module__ + "." + self.__class__.__name__
            args, kwargs = introspector(self)
            # That's our definition!
            kwargs.update({
                'start_query': repr(self.start_query),
                'size_width': repr(self.size_width),
                'size_height': repr(self.size_height),
            })
            return ('django_ymap.fields.YmapCoord', args, kwargs)
        except ImportError:
            pass


    def deconstruct(self):
        name, path, args, kwargs = super(YmapCoord, self).deconstruct()
        if "start_query" in kwargs:
            del kwargs["start_query"]
        if 'size_width' in kwargs:
            del kwargs["size_width"]
        if 'size_height' in kwargs:
            del kwargs["size_height"]
        return name, path, args, kwargs

try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^django_ymap\.fields\.YmapCoord"])
except ImportError:
    pass
开发者ID:dukeimg,项目名称:django-simple-yandex-map,代码行数:31,代码来源:fields.py


示例17: FieldFile

class FieldFile(FieldFileMixin, BaseFieldFile):
    pass


class FileField(FileFieldMixin, BaseFileField):
    attr_class = FieldFile


add_introspection_rules([(
        (FileField, ),
        [],
        {
            'private': ['private', {}],
            'attachment': ['attachment', {}],
            'content_types': ['content_types', {}],
            'max_upload_size': ['max_upload_size', {}],
            'strong_caching': ['strong_caching', {}],
            'path_generator': ['path_generator', {}],
            'contents_generator': ['original_contents_generator', {}],
            # These args accept a callable and therefore can
            # not be included in south introspection rules:
            # attachment_filename, condition, upload_to.
        },
    )], ["^varnish_bans_manager\.filesystem\.models\.FileField"])


###############################################################################


class ImageFieldFile(FieldFileMixin, BaseImageFieldFile):
    """
    Adds our custom mixin as well as support for resizing the image if it
开发者ID:marianogg9,项目名称:varnish-bans-manager,代码行数:32,代码来源:models.py


示例18: FormValue

            for item in self._data:
                value = FormValue()
                value.field_name = item['name']
                value.value = item['value']
                self.values.add(value)
            self._data = None


class FormValue(models.Model):
    form_log = models.ForeignKey(FormLog, related_name='values')
    field_name = models.SlugField(_('field name'), max_length=255)
    if settings.VALUE_PICKLEFIELD:
        # use PickledObjectField if available because it preserves the
        # original data type
        value = PickledObjectField(_('value'), null=True, blank=True)
    else:
        # otherwise just use a TextField, with the drawback that
        # all values will just be stored as unicode strings, 
        # but you can easily query the database for form results.
        value = models.TextField(_('value'), null=True, blank=True)

    def __unicode__(self):
        return u'%s = %s' % (self.field_name, self.value)


if 'south' in django_settings.INSTALLED_APPS:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^form_designer\.fields\..*"])


开发者ID:7mp,项目名称:django-form-designer,代码行数:28,代码来源:models.py


示例19: delete_version_package

    #operating_system= models.CharField(_('Operating system'), max_length=15)
    #ip_address      = models.CharField(_('IP Address'), max_length=15)
    #backtrace       = models.TextField(_('Python backtrace'))


def delete_version_package(sender, instance, **kw):
    """
    Removes the zip package
    """
    try:
        os.remove(instance.package.path)
    except:
        pass

def delete_plugin_icon(sender, instance, **kw):
    """
    Removes the plugin icon
    """
    try:
        os.remove(instance.icon.path)
    except:
        pass

models.signals.post_delete.connect(delete_version_package, sender=PluginVersion)
models.signals.post_delete.connect(delete_plugin_icon, sender=Plugin)


from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^plugins\.models\.QGVersionZeroForcedField"])
add_introspection_rules([], ["^plugins\.models\.VersionField"])
开发者ID:SaghroGuy,项目名称:QGIS-Django,代码行数:30,代码来源:models.py


示例20: add_introspection_rules

from django.db import models
from stdimage import StdImageField
from south.modelsinspector import add_introspection_rules
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError


# Rules for South to migrate the custom StdImageField, don't touch
rules = [
    (
        (StdImageField,),
        [],
        {"size": ["size", {"default": None}], "thumbnail_size": ["thumbnail_size", {"default": None}]},
    )
]
add_introspection_rules(rules, ["^stdimage\.fields"])


class Dictionary(models.Model):
    subject = models.CharField(max_length=20)
    owner = models.ForeignKey(User)

    def __unicode__(self):
        return "%s" % (self.subject)


class WordEntry(models.Model):
    PART_CHOICES = (
        ("noun", "Noun"),
        ("verb", "Verb"),
        ("adjective", "Adjective"),
开发者ID:gctaa,项目名称:ourdictionary,代码行数:31,代码来源:models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python modelsinspector.introspector函数代码示例发布时间:2022-05-27
下一篇:
Python modelsinspector.add_ignored_fields函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap