rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def _processForm(self, data=1, metadata=None): request = self.REQUEST | def _processForm(self, data=1, metadata=None, REQUEST=None): request = REQUEST or self.REQUEST | def _processForm(self, data=1, metadata=None): request = self.REQUEST form = request.form fieldset = form.get('fieldset', None) schema = self.Schema() schemata = self.Schemata() fields = [] |
def processForm(self, data=1, metadata=0): | def processForm(self, data=1, metadata=0, REQUEST=None): | def processForm(self, data=1, metadata=0): """Process the schema looking for data in the form""" self._processForm(data=data, metadata=metadata) |
self._processForm(data=data, metadata=metadata) | self._processForm(data=data, metadata=metadata, REQUEST=REQUEST) | def processForm(self, data=1, metadata=0): """Process the schema looking for data in the form""" self._processForm(data=data, metadata=metadata) |
security.declareProtected(permissions.View, 'getName') | security.declareProtected(CMFCorePermissions.View, 'getName') | def __init__(self, name='default', fields=None): """Initialize Schemata and add optional fields.""" |
security.declareProtected(permissions.View, 'copy') | security.declareProtected(CMFCorePermissions.View, 'copy') | def __add__(self, other): """Returns a new Schemata object that contains all fields and layers from ``self`` and ``other``. """ |
security.declareProtected(permissions.View, 'fields') | security.declareProtected(CMFCorePermissions.View, 'fields') | def copy(self): """Returns a deep copy of this Schemata. """ c = Schemata() for field in self.fields(): c.addField(field.copy()) return c |
security.declareProtected(permissions.View, 'values') | security.declareProtected(CMFCorePermissions.View, 'values') | def fields(self): """Returns a list of my fields in order of their indices.""" return [self._fields[name] for name in self._names] |
security.declareProtected(permissions.View, 'editableFields') | security.declareProtected(CMFCorePermissions.View, 'editableFields') | def fields(self): """Returns a list of my fields in order of their indices.""" return [self._fields[name] for name in self._names] |
security.declareProtected(permissions.View, 'viewableFields') | security.declareProtected(CMFCorePermissions.View, 'viewableFields') | def editableFields(self, instance, visible_only=False): """Returns a list of editable fields for the given instance """ ret = [] for field in self.fields(): if field.writeable(instance, debug=False) and \ (not visible_only or field.widget.isVisible(instance, 'edit')): ret.append(field) return ret |
security.declareProtected(permissions.View, 'widgets') | security.declareProtected(CMFCorePermissions.View, 'widgets') | def viewableFields(self, instance): """Returns a list of viewable fields for the given instance """ return [field for field in self.fields() if field.checkPermission('view', instance)] |
security.declareProtected(permissions.View, | security.declareProtected(CMFCorePermissions.View, | def widgets(self): """Returns a dictionary that contains a widget for each field, using the field name as key.""" |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def __setitem__(self, name, field): assert name == field.getName() self.addField(field) |
raise SchemaException( "Tried to add '%s' with property '%s' set " "to %s but '%s' has the same value." % | deprecated( "Adding '%s' with property '%s' set " "to %s but '%s' has the same value. Re-using the property " "above on different named fields is not allowed anymore." % | def _validateOnAdd(self, field): """Validates fields on adding and bootstrapping """ # interface test if not IField.isImplementedBy(field): raise ValueError, "Object doesn't implement IField: %r" % field name = field.getName() # two primary fields are forbidden if getattr(field, 'primary', False): res = self.hasPrimary... |
security.declareProtected(permissions.View, 'get') | security.declareProtected(CMFCorePermissions.View, 'get') | def __getitem__(self, name): return self._fields[name] |
security.declareProtected(permissions.View, 'has_key') | security.declareProtected(CMFCorePermissions.View, 'has_key') | def get(self, name, default=None): return self._fields.get(name, default) |
security.declareProtected(permissions.View, 'keys') | security.declareProtected(CMFCorePermissions.View, 'keys') | def has_key(self, name): return self._fields.has_key(name) |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def keys(self): return self._names |
security.declareProtected(permissions.View, 'searchable') | security.declareProtected(CMFCorePermissions.View, 'searchable') | def keys(self): return self._names |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def __init__(self): DefaultLayerContainer.__init__(self) #Layer init work marshall = self._props.get('marshall') if marshall: self.registerLayer('marshall', marshall) |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def initializeLayers(self, instance, item=None, container=None): # scan each field looking for registered layers optionally # call its initializeInstance method and then the # initializeField method initializedLayers = [] called = lambda x: x in initializedLayers |
security.declareProtected(permissions.View, 'copy') | security.declareProtected(CMFCorePermissions.View, 'copy') | def __add__(self, other): c = SchemaLayerContainer() layers = {} for k, v in self.registeredLayers(): layers[k] = v for k, v in other.registeredLayers(): layers[k] = v for k, v in layers.items(): c.registerLayer(k, v) return c |
security.declareProtected(permissions.View, 'copy') | security.declareProtected(CMFCorePermissions.View, 'copy') | def __add__(self, other): c = BasicSchema() # We can't use update and keep the order so we do it manually for field in self.fields(): c.addField(field) for field in other.fields(): c.addField(field) # Need to be smarter when joining layers # and internal props c._props.update(self._props) return c |
security.declareProtected(permissions.ModifyPortalContent, 'edit') | security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'edit') | def copy(self): """Returns a deep copy of this Schema. """ c = BasicSchema() for field in self.fields(): c.addField(field.copy()) # Need to be smarter when joining layers # and internal props c._props.update(self._props) return c |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def edit(self, instance, name, value): if self.allow(name): instance[name] = value |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def setDefaults(self, instance): """Only call during object initialization. Sets fields to schema defaults """ ## XXX think about layout/vs dyn defaults for field in self.values(): if field.getName().lower() == 'id': continue if field.type == "reference": continue |
security.declareProtected(permissions.View, 'allow') | security.declareProtected(CMFCorePermissions.View, 'allow') | def updateAll(self, instance, **kwargs): """This method mutates fields in the given instance. |
security.declareProtected(permissions.View, 'validate') | security.declareProtected(CMFCorePermissions.View, 'validate') | def allow(self, name): return self.has_key(name) |
security.declareProtected(permissions.View, | security.declareProtected(CMFCorePermissions.View, | def validate(self, instance=None, REQUEST=None, errors=None, data=None, metadata=None): """Validate the state of the entire object. |
security.declareProtected(permissions.View, | security.declareProtected(CMFCorePermissions.View, | def toString(self): s = '%s: {' % self.__class__.__name__ for f in self.fields(): s = s + '%s,' % (f.toString()) s = s + '}' return s |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def signature(self): from md5 import md5 return md5(self.toString()).digest() |
security.declareProtected(permissions.View, 'getSchemataNames') | security.declareProtected(CMFCorePermissions.View, 'getSchemataNames') | def changeSchemataForField(self, fieldname, schemataname): """ change the schemata for a field """ field = self[fieldname] self.delField(fieldname) field.schemata = schemataname self.addField(field) |
security.declareProtected(permissions.View, 'getSchemataFields') | security.declareProtected(CMFCorePermissions.View, 'getSchemataFields') | def getSchemataNames(self): """Return list of schemata names in order of appearing""" lst = [] for f in self.fields(): if not f.schemata in lst: lst.append(f.schemata) return lst |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def getSchemataFields(self, name): """Return list of fields belong to schema 'name' in order of appearing """ return [f for f in self.fields() if f.schemata == name] |
security.declareProtected(permissions.View, 'copy') | security.declareProtected(CMFCorePermissions.View, 'copy') | def __add__(self, other): c = Schema() # We can't use update and keep the order so we do it manually for field in self.fields(): c.addField(field) for field in other.fields(): c.addField(field) # Need to be smarter when joining layers # and internal props c._props.update(self._props) layers = {} for k, v in self.regist... |
security.declareProtected(permissions.View, 'wrapped') | security.declareProtected(CMFCorePermissions.View, 'wrapped') | def copy(self, factory=None): """Returns a deep copy of this Schema. """ if factory is None: factory = self.__class__ c = factory() for field in self.fields(): c.addField(field.copy()) # Need to be smarter when joining layers # and internal props c._props.update(self._props) layers = {} for k, v in self.registeredLayer... |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def wrapped(self, parent): schema = self.copy(factory=WrappedSchema) return schema.__of__(parent) |
>>> from Products.Archetypes.atapi import StringField as SF | >>> from Products.Archetypes.public import StringField as SF | def moveField(self, name, direction=None, pos=None, after=None, before=None): """Move a field |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def _moveFieldInSchemata(self, name, direction): """Moves a field with the name 'name' inside its schemata """ if not direction in (-1, 1): raise ValueError, "Direction must be either -1 or 1" |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def delSchemata(self, name): """Remove all fields belonging to schemata 'name'""" for f in self.fields(): if f.schemata == name: self.delField(f.getName()) |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def addSchemata(self, name): """Create a new schema by adding a new field with schemata 'name' """ from Products.Archetypes.Field import StringField |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def moveSchemata(self, name, direction): """Move a schemata to left (direction=-1) or to right (direction=1) """ if not direction in (-1, 1): raise ValueError, 'Direction must be either -1 or 1' |
if type_datum is type([]) or type_datum is type(()): | if type_datum is ListType or type_datum is TupleType: | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose""" data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getAccessor(self) try: datum = method(mimetype="text/plain") except TypeError... |
elif type_datum in (type(''), type(u''), ): | elif type_datum in STRING_TYPES: | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose""" data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getAccessor(self) try: datum = method(mimetype="text/plain") except TypeError... |
if type_datum is type(u''): | if type_datum is UnicodeType: | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose""" data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getAccessor(self) try: datum = method(mimetype="text/plain") except TypeError... |
'default_content_type' : 'image/gif', 'allowable_content_types' : ('image/gif','image/jpeg'), | 'default_content_type' : 'image/png', 'allowable_content_types' : ('image/gif','image/jpeg','image/png'), | def isBinary(self): return 1 |
imgdata, 'image/jpeg') | imgdata, 'image/" + lower(pimage.format)) | def createScales(self, instance): """creates the scales and save them """ if not has_pil or not self.sizes: return img = self.getRaw(instance) if not img: return data = str(img.data) for n, size in self.sizes.items(): w, h = size id = self.getName() + "_" + n imgdata = self.scale(data, w, h) image = self.image_class(id... |
pilfilter = 0 | pilfilter = PIL.Image.NEAREST | def scale(self,data,w,h): """ scale image (with material from ImageTag_Hotfix)""" #make sure we have valid int's keys = {'height':int(h), 'width':int(w)} |
pilfilter = 1 | pilfilter = PIL.Image.ANTIALIAS | def scale(self,data,w,h): """ scale image (with material from ImageTag_Hotfix)""" #make sure we have valid int's keys = {'height':int(h), 'width':int(w)} |
image = image.convert('RGB') | original_mode = image.mode if original_mode == '1': image = image.convert('L') elif original_mode == 'P': image = image.convert('RGBA') | def scale(self,data,w,h): """ scale image (with material from ImageTag_Hotfix)""" #make sure we have valid int's keys = {'height':int(h), 'width':int(w)} |
image.save(thumbnail_file, "JPEG", quality=88) | image.save(thumbnail_file, image.format, quality=88) | def scale(self,data,w,h): """ scale image (with material from ImageTag_Hotfix)""" #make sure we have valid int's keys = {'height':int(h), 'width':int(w)} |
target = getattr(self, name, None) | if shasattr(self, name): target = getattr(self, name) else: target = queryMultiAdapter((self, REQUEST), Interface, name) if target is not None: target = None else: target = getattr(self, name, None) | def __bobo_traverse__(self, REQUEST, name): """Allows transparent access to session subobjects. """ # sometimes, the request doesn't have a response, e.g. when # PageTemplates traverse through the object path, they pass in # a phony request (a dict). RESPONSE = getattr(REQUEST, 'RESPONSE', None) |
if (method not in ('GET', 'POST') and not isinstance(RESPONSE, xmlrpc.Response) and REQUEST.maybe_webdav_client): | elif (method not in ('GET', 'POST') and not isinstance(RESPONSE, xmlrpc.Response) and REQUEST.maybe_webdav_client): | def __bobo_traverse__(self, REQUEST, name): """Allows transparent access to session subobjects. """ # sometimes, the request doesn't have a response, e.g. when # PageTemplates traverse through the object path, they pass in # a phony request (a dict). RESPONSE = getattr(REQUEST, 'RESPONSE', None) |
raise AttributeError(name) | else: raise AttributeError(name) | def __bobo_traverse__(self, REQUEST, name): """Allows transparent access to session subobjects. """ # sometimes, the request doesn't have a response, e.g. when # PageTemplates traverse through the object path, they pass in # a phony request (a dict). RESPONSE = getattr(REQUEST, 'RESPONSE', None) |
size += field.get_size() | size += value.get_size() | def get_size( self ): """ Used for FTP and apparently the ZMI now too """ size = 0 for name in self.Schema().keys(): value = self[name] if IBaseUnit.isImplementedBy(value): size += field.get_size() else: try: size += len(field) except TypeError: pass |
size += len(field) | size += len(value) | def get_size( self ): """ Used for FTP and apparently the ZMI now too """ size = 0 for name in self.Schema().keys(): value = self[name] if IBaseUnit.isImplementedBy(value): size += field.get_size() else: try: size += len(field) except TypeError: pass |
value = value + field.widget.divider + field.get(instance) | value = value + field.widget.divider + field.get(instance, mimetype="text/plain") | def process_form(self, instance, field, form, empty_marker=None, emptyReturnsMarker=False): """handle text formatting""" text_format = None value = None # text field with formatting value = form.get(field.getName(), empty_marker) |
return self.EffectiveDate() <= date and not self.isExpired() | eff_date = self.EffectiveDate() if not eff_date: eff_date = FLOOR_DATE return eff_date <= date and not self.isExpired() | def isEffective( self, date ): """ Is the date within the resource's effective range? """ return self.EffectiveDate() <= date and not self.isExpired() |
return self.ExpirationDate() < date | exp_date = self.ExpirationDate() if not exp_date: exp_date = CEILING_DATE return exp_date < date | def isExpired( self, date ): """ Is the date after resource's expiration """ return self.ExpirationDate() < date |
ATFunctionalSiteTestCase.afterSetUp(self) | def afterSetUp(self): ATFunctionalSiteTestCase.afterSetUp(self) | |
self.app.REQUEST.set('REQUEST_METHOD',None) | self.app.REQUEST.set('REQUEST_METHOD', 'nonsense') | def test_createObjectInCodeDoesNotSetFlag(self): # Using invokeFactory from code should not set the creation flag |
'RichWidget', 'FileWidget', 'IdWidget', 'ImageWidget', ) | 'RichWidget', 'FileWidget', 'IdWidget', 'ImageWidget', 'PasswordWidget',) | def findField(self, instance): #This is a sad hack, I don't want widgets to have to take a #reference to a field or its own name for field in instance.Schema().fields(): if not hasattr(field, 'widget'): continue if field.widget is self: return field return None |
print 'lookup', destination_types | def lookupDestinationsFor(self, typeinfo, tool, purl, destination_types=None): """ search where the user can add a typeid instance """ searchFor = [] # first, discover who can contain the type print 'lookup', destination_types if destination_types is not None: if type(destination_types) in (type(()), type([])): search... | |
print searchFor | def lookupDestinationsFor(self, typeinfo, tool, purl, destination_types=None): """ search where the user can add a typeid instance """ searchFor = [] # first, discover who can contain the type print 'lookup', destination_types if destination_types is not None: if type(destination_types) in (type(()), type([])): search... | |
containers.append(brain.relative_url) | rel = purl.getRelativeUrl(brain.getObject()) containers.append(rel) | def lookupDestinationsFor(self, typeinfo, tool, purl, destination_types=None): """ search where the user can add a typeid instance """ searchFor = [] # first, discover who can contain the type print 'lookup', destination_types if destination_types is not None: if type(destination_types) in (type(()), type([])): search... |
print option, 'going to search' | def addableTypes(self, instance, field): """ Returns a list of dictionaries which maps portal_type to a human readable form. """ tool = getToolByName(instance, 'portal_types') purl = getToolByName(instance, 'portal_url') | |
method = ti and ti.getMethodURL('mkdir') or None if method: | try: method = ti and ti.getMethodURL('mkdir') or None except AttributeError: method = None if method is not None: | def manage_addFolder( self , id , title='' , REQUEST=None , type_name = None ): """ Add a new folder-like object with id *id*. |
'visible' : 1, | 'visible' : {'edit':'visible', 'view':'visible'}, | def Description(self, instance): """Returns the description, possibly translated""" |
if not mode.startswith(key): raise KeyError, "Expression must return a valid mode." | if computed.startswith(key): invalid_mode = False break if invalid_mode: raise KeyError, "Expression must return a valid mode. %s is not a valid mode: %s" % (repr(computed), ', '.join(self.visibility.keys())) | def getWidgetMode(self, object, field, mode): """ return the rendering macro used by the widget |
kwargs.setdefault('mimetype', content_type) | if not kwargs.get('mimetype', None): kwargs.update({'mimetype': content_type}) | def demarshall(self, instance, data, **kwargs): from Products.CMFDefault.utils import parseHeadersBody headers, body = parseHeadersBody(data) for k, v in headers.items(): if v.strip() == 'None': v = None field = instance.getField(k) if field is not None: mutator = field.getMutator(instance) if mutator is not None: muta... |
return self.__test_manage_afterAdd__(item, container) | return res | def manage_afterAdd(self, item, container): uid = UID(self) ADD_COUNTER.add(uid) if DEBUG_CALL: warnings.warn("manage_afterAdd called: %s:%s" % (uid, ADD_COUNTER.get(uid)), UserWarning, WARNING_LEVEL) return self.__test_manage_afterAdd__(item, container) |
orig_url = doc.absolute_url() | def test_rename(self): obj_id = 'demodoc' new_id = 'new_demodoc' doc = makeContent(self.folder, portal_type='Fact', id=obj_id) content = 'The book is on the table!' doc.setQuote(content, mimetype="text/plain") orig_url = doc.absolute_url() self.failUnless(str(doc.getQuote()) == str(content)) #make sure we have _p_jar g... | |
self.assertEquals(ADD_COUNTER.get(orig_url), 1) self.assertEquals(ADD_COUNTER.get(uid), 1) | self.assertEquals(ADD_COUNTER.get(uid), 2) | def test_rename(self): obj_id = 'demodoc' new_id = 'new_demodoc' doc = makeContent(self.folder, portal_type='Fact', id=obj_id) content = 'The book is on the table!' doc.setQuote(content, mimetype="text/plain") orig_url = doc.absolute_url() self.failUnless(str(doc.getQuote()) == str(content)) #make sure we have _p_jar g... |
self.assertEquals(DELETE_COUNTER.get(orig_url), 0) | def test_rename(self): obj_id = 'demodoc' new_id = 'new_demodoc' doc = makeContent(self.folder, portal_type='Fact', id=obj_id) content = 'The book is on the table!' doc.setQuote(content, mimetype="text/plain") orig_url = doc.absolute_url() self.failUnless(str(doc.getQuote()) == str(content)) #make sure we have _p_jar g... | |
self.assertEquals(CLONE_COUNTER.get(orig_url), 0) | def test_rename(self): obj_id = 'demodoc' new_id = 'new_demodoc' doc = makeContent(self.folder, portal_type='Fact', id=obj_id) content = 'The book is on the table!' doc.setQuote(content, mimetype="text/plain") orig_url = doc.absolute_url() self.failUnless(str(doc.getQuote()) == str(content)) #make sure we have _p_jar g... | |
orig_url = d.absolute_url() | def test_recursive(self): # Test for recursive calling of manage_after{Add|Clone} # and manage_beforeDelete. (bug #905677) populateFolder(self.folder, 'SimpleFolder', 'DDocument') d = self.folder.folder2.folder22.folder221.doc2211 orig_url = d.absolute_url() uid = UID(d) # Called afterAdd once, when the object didn't h... | |
self.assertEquals(ADD_COUNTER.get(orig_url), 1) self.assertEquals(ADD_COUNTER.get(uid), 0) | self.assertEquals(ADD_COUNTER.get(uid), 1) | def test_recursive(self): # Test for recursive calling of manage_after{Add|Clone} # and manage_beforeDelete. (bug #905677) populateFolder(self.folder, 'SimpleFolder', 'DDocument') d = self.folder.folder2.folder22.folder221.doc2211 orig_url = d.absolute_url() uid = UID(d) # Called afterAdd once, when the object didn't h... |
expected = (d_count[0]+1, d_count[1]+0, d_count[2]+1) | expected = (d_count[0], d_count[1], d_count[2]) | def test_recursive(self): # Test for recursive calling of manage_after{Add|Clone} # and manage_beforeDelete. (bug #905677) populateFolder(self.folder, 'SimpleFolder', 'DDocument') d = self.folder.folder2.folder22.folder221.doc2211 orig_url = d.absolute_url() uid = UID(d) # Called afterAdd once, when the object didn't h... |
self.assertEquals(got, (0, 0, 0)) | self.assertEquals(got, (1, 0, 1)) | def test_recursive(self): # Test for recursive calling of manage_after{Add|Clone} # and manage_beforeDelete. (bug #905677) populateFolder(self.folder, 'SimpleFolder', 'DDocument') d = self.folder.folder2.folder22.folder221.doc2211 orig_url = d.absolute_url() uid = UID(d) # Called afterAdd once, when the object didn't h... |
transforms.initialize(self) | try: transforms.initialize(self) except: pass | def manage_afterAdd(self, item, container): """ overload manage_afterAdd to finish initialization when the transform tool is added """ Folder.manage_afterAdd(self, item, container) # first initialization transforms.initialize(self) |
self.registerTransform(id, transform) | self._mapTransform(transform) | def manage_addTransform(self, id, module, REQUEST=None): """ add a new transform to the tool """ transform = Transform(id, module) self._setObject(id, transform) self.registerTransform(id, transform) if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main') |
self.registerTransform(id, transform) | self._mapTransform(transform) | def manage_addTransformsChain(self, id, description, REQUEST=None): """ add a new transform to the tool """ transform = TransformsChain(id, description) self._setObject(id, transform) self.registerTransform(id, transform) if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main') |
if not name in self.objectIds(): module = "%s" % transform.__module__ transform = Transform(name, module, transform) self._setObject(name, transform) | module = "%s" % transform.__module__ transform = Transform(name, module, transform) self._setObject(name, transform) | def registerTransform(self, name, transform): """ register a new transform """ __traceback_info__ = (name, transform) if not name in self.objectIds(): # needed when call from transform.transforms.initialize which # register non zope transform module = "%s" % transform.__module__ transform = Transform(name, module, tran... |
mimetype = getattr(aq_base(value), 'mimetype', None) | mimetype = getattr(aq_base(raw), 'mimetype', None) | def getContentType(self, instance, fromBaseUnit=True): """Return the mime type of object if known or can be guessed; otherwise, return None.""" value = '' if fromBaseUnit and hasattr(self, 'getBaseUnit'): bu = self.getBaseUnit(instance) if IBaseUnit.isImplementedBy(bu): return str(bu.getContentType()) raw = self.getRaw... |
class BaseObject(Referenceable): | class Log: closeable = 0 fp = None | def __call__(self, name, value): context = aq_parent(self) schema = context.Schema() if not schema.has_key(name): return 1 field = schema[name] if not isinstance(field.getStorage(), AttributeStorage): return 1 perm = field.read_permission if checkPerm(perm, context): return 1 return 0 |
security = ClassSecurityInfo() | def __init__(self, target=sys.stderr): self.target = target self._open() | def __call__(self, name, value): context = aq_parent(self) schema = context.Schema() if not schema.has_key(name): return 1 field = schema[name] if not isinstance(field.getStorage(), AttributeStorage): return 1 perm = field.read_permission if checkPerm(perm, context): return 1 return 0 |
if ATTRIBUTE_SECURITY: attr_security = AttributeValidator() security.setDefaultAccess(attr_security) del attr_security | def _open(self): if self.fp is not None and not self.fp.closed: return self.fp | def __call__(self, name, value): context = aq_parent(self) schema = context.Schema() if not schema.has_key(name): return 1 field = schema[name] if not isinstance(field.getStorage(), AttributeStorage): return 1 perm = field.read_permission if checkPerm(perm, context): return 1 return 0 |
schema = type = content_type _signature = None | if type(self.target) is StringType: fp = open(self.target, "a+") self.closeable = 1 else: fp = self.target | def __call__(self, name, value): context = aq_parent(self) schema = context.Schema() if not schema.has_key(name): return 1 field = schema[name] if not isinstance(field.getStorage(), AttributeStorage): return 1 perm = field.read_permission if checkPerm(perm, context): return 1 return 0 |
installMode = ['type', 'actions', 'indexes'] typeDescMsgId = '' typeDescription = '' _at_rename_after_creation = False __implements__ = (z2IBaseObject, ) + Referenceable.__implements__ implements(IBaseObject, IReferenceable) def __init__(self, oid, **kwargs): self.id = oid security.declareProtected(permissions.Modi... | self.fp = SafeFileWrapper(fp) | def __call__(self, name, value): context = aq_parent(self) schema = context.Schema() if not schema.has_key(name): return 1 field = schema[name] if not isinstance(field.getStorage(), AttributeStorage): return 1 perm = field.read_permission if checkPerm(perm, context): return 1 return 0 |
except (ConflictError, KeyboardInterrupt): raise except: continue if datum: type_datum = type(datum) vocab = field.Vocabulary(self) if type_datum is ListType or type_datum is TupleType: vocab_values = map(lambda value, vocab=vocab: vocab.getValue(value, ''), datum) datum = list(datum) datum.extend(vocab_values) datum ... | def _close(self): if self.closeable: self.fp.close() | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
type_datum = type(datum) if type_datum is UnicodeType: datum = datum.encode(charset) data.append(str(datum)) | def munge_message(self, msg, **kwargs): """Override this to messge with the message for subclasses""" return msg | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
data = ' '.join(data) return data | def log(self, msg, *args, **kwargs): self._open() self.fp.write("%s\n" % (self.munge_message(msg, **kwargs))) for arg in args: self.fp.write("%s\n" % pprint.pformat(arg)) self._close() | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
security.declareProtected(permissions.View, 'getCharset') def getCharset(self): """Returns the site default charset, or utf-8. """ properties = getToolByName(self, 'portal_properties', None) if properties is not None: site_properties = getattr(properties, 'site_properties', None) if site_properties is not None: return ... | def log_exc(self, msg=None, *args, **kwargs): self.log(''.join(traceback.format_exception(*sys.exc_info())), offset=1, color="red") if msg: self.log(msg, collapse=0, deep=0, *args, **kwargs) | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
except (ConflictError, KeyboardInterrupt): raise | def __call__(self, msg): self.log(msg) class NullLog(Log): def __init__(self, target): pass def log(self, msg, **kwargs): pass class ClassLog(Log): last_frame_msg = None def _process_frame(self, frame, color=COLORS['green']): path = frame[1] or '<string>' index = path.find("Products") if index != -1: path = path[in... | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
try: editAccessor = field.getEditAccessor(self) if editAccessor: return editAccessor() | if collapse == 1: if frame == self.last_frame_msg: frame = '' else: self.last_frame_msg = frame msg = "%s%s" %(frame, msg) return msg | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
except (ConflictError, KeyboardInterrupt): raise except: pass | class ZPTLogger(ClassLog): def generateFrames(self, start=None, end=None): frames = inspect.stack() for f in frames: print f return frames | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
try: accessor = field.getAccessor(self) if accessor: return accessor() | class ZLogger(ClassLog): def log(self, msg, *args, **kwargs): level = kwargs.get('level', logging.INFO) msg = "%s\n" % (self.munge_message(msg, **kwargs)) for arg in args: msg += "%s\n" % pprint.pformat(arg) logger.log(level, msg) | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
except (ConflictError, KeyboardInterrupt): raise except: pass return field.get(self) | def warn(msg, level=3): if DEBUG: warnings.warn(msg, UserWarning, level) | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
try: return self[field.getName()] | def deprecated(msg, level=3): if DEBUG: warnings.warn(msg, DeprecationWarning, level) | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
except (ConflictError, KeyboardInterrupt): raise except: pass if new_schema: new_field = new_schema.get(name) try: editAccessor = new_field.getEditAccessor(self) if editAccessor: return editAccessor() except (ConflictError, KeyboardInterrupt): raise except: pass try: accessor = new_field.getAccessor(self) if ac... | log = zlog = _zlogger.log log_exc = _zlogger.log_exc | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
method = getattr(content_instance, self.vocabulary, None) | method = getattr(content_instance, value, None) | def Vocabulary(self, content_instance=None): value = self.vocabulary if not isinstance(value, DisplayList): if content_instance is not None and type(value) is StringType: method = getattr(content_instance, self.vocabulary, None) if method and callable(method): value = method() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.