rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
PortalFolder.manage_afterClone(self, item) | Folder.manage_afterClone(self, item) | def manage_afterClone(self, item): Referenceable.manage_afterClone(self, item) BaseObject.manage_afterClone(self, item) PortalFolder.manage_afterClone(self, item) CatalogMultiplex.manage_afterClone(self, item) |
PortalFolder.manage_beforeDelete(self, item, container) | Folder.manage_beforeDelete(self, item, container) | def manage_beforeDelete(self, item, container): Referenceable.manage_beforeDelete(self, item, container) BaseObject.manage_beforeDelete(self, item, container) PortalFolder.manage_beforeDelete(self, item, container) CatalogMultiplex.manage_beforeDelete(self, item, container) |
accessor = self.Schema()[key].getAccessor(self) return accessor() | try: f = self.Schema()[key] return f.get(self, raw=1) except: return self.Schema()[key].getAccessor(self)() | def __getitem__(self, key): """play nice with externaleditor again""" if key not in self.Schema().keys() and key[:1] != "_": #XXX 2.2 return getattr(self, key, None) or getattr(aq_parent(aq_inner(self)), key, None) accessor = self.Schema()[key].getAccessor(self) return accessor() |
value.replace(',','.') | value = value.replace(',','.') | def _to_tuple(self, instance, value): """ COMMENT TO-DO """ if not value: value = self.getDefault(instance) |
target = self._getTarget(target) | target = self._getObject(target) | def addReference(self, source, target, relationship=None, referenceClass=None, **kwargs): source = self._getObject(source) target = self._getTarget(target) ref_source = IReferenceSource(source) new_ref = ref_source.addReference(source=source, target=target, relationship=(relationship, referenceClass)) meta_set = IRefer... |
rc = getToolByName(container, REFERENCE_CATALOG) url = getRelURL(container, self.getPhysicalPath()) | base = container try: rc = getToolByName(base, REFERENCE_CATALOG) except: base = item rc = getToolByName(base, REFERENCE_CATALOG) url = getRelURL(base, self.getPhysicalPath()) | def manage_afterAdd(self, item, container): Referenceable.manage_afterAdd(self, item, container) |
kw['mimetype'] = f.getContentType(self) | def _updateSchema(self, excluded_fields=[], out=None): """Update an object's schema when the class schema changes. | |
out = ('h\xc3\xa9h\xc3\xa9h\xc3\xa9') | out = ('h\xc3\xa9h\xc3\xa9h\xc3\xa9',) iso = ('hhh',) | def test_set1(self): f = LinesField('test') f.set(instance, 'h\xc3\xa9h\xc3\xa9h\xc3\xa9') if ZOPE_LINES_IS_TUPLE_TYPE: out = ('h\xc3\xa9h\xc3\xa9h\xc3\xa9') else: out = ['h\xc3\xa9h\xc3\xa9h\xc3\xa9'] self.failUnlessEqual(f.get(instance), out) self.failUnlessEqual(f.get(instance, encoding="ISO-8859-1"), ['hhh']) f.set... |
out = ['h\xc3\xa9h\xc3\xa9h\xc3\xa9'] | out = ['h\xc3\xa9h\xc3\xa9h\xc3\xa9',] iso = ['hhh',] | def test_set1(self): f = LinesField('test') f.set(instance, 'h\xc3\xa9h\xc3\xa9h\xc3\xa9') if ZOPE_LINES_IS_TUPLE_TYPE: out = ('h\xc3\xa9h\xc3\xa9h\xc3\xa9') else: out = ['h\xc3\xa9h\xc3\xa9h\xc3\xa9'] self.failUnlessEqual(f.get(instance), out) self.failUnlessEqual(f.get(instance, encoding="ISO-8859-1"), ['hhh']) f.set... |
self.failUnlessEqual(f.get(instance, encoding="ISO-8859-1"), ['hhh']) | self.failUnlessEqual(f.get(instance, encoding="ISO-8859-1"), iso) | def test_set1(self): f = LinesField('test') f.set(instance, 'h\xc3\xa9h\xc3\xa9h\xc3\xa9') if ZOPE_LINES_IS_TUPLE_TYPE: out = ('h\xc3\xa9h\xc3\xa9h\xc3\xa9') else: out = ['h\xc3\xa9h\xc3\xa9h\xc3\xa9'] self.failUnlessEqual(f.get(instance), out) self.failUnlessEqual(f.get(instance, encoding="ISO-8859-1"), ['hhh']) f.set... |
instantiate the widget if a class was given and call widget.populateProps """ if hasattr(self, 'widget'): if type(self.widget) == ClassType: self.widget = self.widget() self.widget.populateProps(self) | instantiate the widget if a class was given """ if hasattr(self, 'widget') and type(self.widget) == ClassType: self.widget = self.widget() | def _widgetLayer(self): """ instantiate the widget if a class was given and call widget.populateProps """ if hasattr(self, 'widget'): if type(self.widget) == ClassType: self.widget = self.widget() self.widget.populateProps(self) |
def validate(self, value, instance, errors={}, **kwargs): | def validate(self, value, **kwargs): | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() if errors and errors.has_key(name): return 1 |
name = self.getName() if errors and errors.has_key(name): return 1 if self.required: res = self.validate_required(instance, value, errors) if res is not None: return res if self.enforceVocabulary: res = self.validate_vocabulary(instance, value, errors) if res is not None: return res res = instance.validate_field(nam... | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() if errors and errors.has_key(name): return 1 | |
res = validation.validate(v, value, instance=instance, errors=errors, **kwargs) | res = validation.validate(v, value, **kwargs) | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() if errors and errors.has_key(name): return 1 |
def validate_required(self, instance, value, errors): if not value: label = self.widget.Label(instance) name = self.getName() error = translate( 'archetypes', 'error_required', {'name': label}, instance, default = "%s is required, please correct." % label, ) errors[name] = error return error return None def validate_v... | return None | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() if errors and errors.has_key(name): return 1 |
__traceback_info__ = (self.getName(), instance, kwargs) | def get(self, instance, **kwargs): __traceback_info__ = (self.getName(), instance, kwargs) try: kwargs['field'] = self return self.storage.get(self.getName(), instance, **kwargs) except AttributeError: # happens if new Atts are added and not yet stored in the instance if not kwargs.get('_initializing_', 0): self.set(in... | |
kwargs.update({'field': self.__name__}) | def getRaw(self, instance, **kwargs): if self.accessor is not None: accessor = self.getAccessor(instance) else: # self.accessor is None for fields wrapped by an I18NMixIn accessor = None kwargs.update({'field': self.__name__}) if accessor is None: args = [instance,] return mapply(self.get, *args, **kwargs) return mappl... | |
__traceback_info__ = (self.getName(), instance, value, kwargs) | def set(self, instance, value, **kwargs): kwargs['field'] = self # Remove acquisition wrappers value = aq_base(value) __traceback_info__ = (self.getName(), instance, value, kwargs) self.storage.set(self.getName(), instance, value, **kwargs) | |
__traceback_info__ = (self.getName(), instance, kwargs) | def unset(self, instance, **kwargs): kwargs['field'] = self __traceback_info__ = (self.getName(), instance, kwargs) self.storage.unset(self.getName(), instance, **kwargs) | |
value, mimetype = self._process_input(value, default=self.default, **kwargs) kwargs['mimetype'] = mimetype | def set(self, instance, value, **kwargs): """ Assign input value to object. If mimetype is not specified, pass to processing method without one and add mimetype returned to kwargs. Assign kwargs to instance. """ | |
if value is None: value = '' | def set(self, instance, value, **kwargs): """ Assign input value to object. If mimetype is not specified, pass to processing method without one and add mimetype returned to kwargs. Assign kwargs to instance. """ | |
def validate_required(self, instance, value, errors): value = getattr(value, 'get_size', lambda: str(value))() return ObjectField.validate_required(self, instance, value, errors) | def set(self, instance, value, **kwargs): """ Assign input value to object. If mimetype is not specified, pass to processing method without one and add mimetype returned to kwargs. Assign kwargs to instance. """ | |
If raw, return the base unit object, else return encoded raw data | if raw, return the base unit object, else return encoded raw data | def getRaw(self, instance, raw=0, **kwargs): """ If raw, return the base unit object, else return encoded raw data """ value = self.get(instance, raw=1, **kwargs) if raw or not IBaseUnit.isImplementedBy(value): return value kw = {'encoding':kwargs.get('encoding'), 'instance':instance} args = [] return mapply(value.getR... |
'default' : (), | 'default' : [], | def set(self, instance, value, **kwargs): """ Check if value is an actual date/time value. If not, attempt to convert it to one; otherwise, set to None. Assign all properties passed as kwargs to object. """ if not value: value = None elif not isinstance(value, DateTime): try: value = DateTime(value) except: value = Non... |
if config.ZOPE_LINES_IS_TUPLE_TYPE: value = tuple(value) | def set(self, instance, value, **kwargs): """ If passed-in value is a string, split at line breaks and remove leading and trailing white space before storing in object with rest of properties. """ __traceback_info__ = value, type(value) if type(value) in STRING_TYPES: value = value.split('\n') value = [decode(v.strip(... | |
value = ObjectField.get(self, instance, **kwargs) or () if config.ZOPE_LINES_IS_TUPLE_TYPE: return tuple([encode(v, instance, **kwargs) for v in value]) else: return [encode(v, instance, **kwargs) for v in value] | value = ObjectField.get(self, instance, **kwargs) return [encode(v, instance, **kwargs) for v in value] | def get(self, instance, **kwargs): value = ObjectField.get(self, instance, **kwargs) or () if config.ZOPE_LINES_IS_TUPLE_TYPE: return tuple([encode(v, instance, **kwargs) for v in value]) else: return [encode(v, instance, **kwargs) for v in value] |
'default' : '0.00', | 'default' : '0.0', | def set(self, instance, value, **kwargs): """Convert passed-in value to a float. If failure, set value to None.""" if value=='': value=None elif value is not None: # should really blow if value is not valid __traceback_info__ = (self.getName(), instance, value, kwargs) value = float(value) |
def validate_required(self, instance, value, errors): value = sum(self._to_tuple(value)) return ObjectField.validate_required(self, instance, value, errors) | def validate_required(self, instance, value, errors): value = sum(self._to_tuple(value)) return ObjectField.validate_required(self, instance, value, errors) | |
'relationship' : None, 'allowed_types' : (), 'referenceClass' : Reference, | 'allowed_types' : (), 'allowed_type_column' : 'portal_type', 'addable': 0, 'destination': None, 'relationship':None | def validate_required(self, instance, value, errors): value = sum(self._to_tuple(value)) return ObjectField.validate_required(self, instance, value, errors) |
def get(self, instance, **kwargs): """Not really publicly useful. See IReferenceable for more convenient ways.""" tool = getToolByName(instance, REFERENCE_CATALOG) value = [ref.targetUID for ref in tool.getReferences(instance, self.relationship)] if not self.multiValued: if len(value) > 1: log('%s of %s is single val... | def containsValueAsString(self, value, attrval): """ checks wether the attribute contains a value if the field is a scalar -> comparison if it is multiValued -> check for 'in' """ if self.multiValued: return str(value) in [str(a) for a in attrval] else: return str(value) == str(attrval) def set(self, instance, val... | def validate_required(self, instance, value, errors): value = sum(self._to_tuple(value)) return ObjectField.validate_required(self, instance, value, errors) |
value = value[0] return value def set(self, instance, value, **kwargs): """Mutator. ``value`` is a list of UIDs or one UID string to which I will add a reference to. None and [] are equal. Keyword arguments may be passed directly to addReference(), thereby creating properties on the reference objects. """ tool = g... | kw = {'Type':self.allowed_types} results = catalog(**kw) | def get(self, instance, **kwargs): """Not really publicly useful. |
return self._Vocabulary(content_instance).sortedByValue() def _Vocabulary(self, content_instance): catalog = getToolByName(content_instance, config.UID_CATALOG) index = 'portal_type' in catalog.indexes() and 'portal_type' or 'Type' brains = catalog.searchResults(**{index: self.allowed_types}) pairs = [(b.UID, b.Titl... | archetype_tool = getToolByName(content_instance, TOOL_NAME) results = archetype_tool.Content() results = [(r, r.getObject()) for r in results] value = [(r.UID, obj and (str(obj.Title().strip()) or \ str(obj.getId()).strip()) or \ log('Field %r: Object at %r could not be found' % \ (self.getName(), r.getURL())) or \ r.... | def Vocabulary(self, content_instance=None): """Use vocabulary property if it's been defined.""" if self.vocabulary: return ObjectField.Vocabulary(self, content_instance) else: return self._Vocabulary(content_instance).sortedByValue() |
pairs.insert(0, ('', '<no reference>')) return DisplayList(pairs) | value.insert(0, ('', '<no reference>')) return DisplayList(value) | def _Vocabulary(self, content_instance): catalog = getToolByName(content_instance, config.UID_CATALOG) # should be obsolete soon: index = 'portal_type' in catalog.indexes() and 'portal_type' or 'Type' brains = catalog.searchResults(**{index: self.allowed_types}) |
if value=="DELETE_IMAGE": | if value=="DELETE_IMAGE" and self.sizes: | def set(self, instance, value, **kwargs): # Do we have to delete the image? if value=="DELETE_IMAGE": # unset different sizes for n, size in self.sizes.items(): id = self.getName() + "_" + n self.storage.unset(id, instance, **kwargs) # unset main field too ObjectField.unset(self, instance, **kwargs) return |
def validate_required(self, instance, value, errors): value = getattr(value, 'get_size', lambda: str(value))() return ObjectField.validate_required(self, instance, value, errors) | def validate_required(self, instance, value, errors): value = getattr(value, 'get_size', lambda: str(value))() return ObjectField.validate_required(self, instance, value, errors) | |
image = ScalableImage(self.getName(), file=value, displays=self.displays) | image = ScalableImage(self.name, file=value, displays=self.displays) | def set(self, instance, value, **kw): if isinstance(value, StringType): value = StringIO(value) image = ScalableImage(self.getName(), file=value, displays=self.displays) ObjectField.set(self, instance, image, **kw) |
def validate_required(self, instance, value, errors): value = getattr(value, 'get_size', lambda: str(value))() return ObjectField.validate_required(self, instance, value, errors) | def set(self, instance, value, **kw): if isinstance(value, StringType): value = StringIO(value) image = ScalableImage(self.getName(), file=value, displays=self.displays) ObjectField.set(self, instance, image, **kw) | |
'CMFObjectField', 'ImageField', 'PhotoField', | 'CMFObjectField', 'ImageField', | def validate_required(self, instance, value, errors): value = getattr(value, 'get_size', lambda: str(value))() return ObjectField.validate_required(self, instance, value, errors) |
Remove warning hook >>> w.uninstall(); del w | def unique(s): """Return a list of the elements in s, but without duplicates. For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique("abcabc") some permutation of ["a", "b", "c"], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]]. For best speed, all sequence elements should... | |
return DisplayList.getValue(self, key, default) | v = self._keys.get(key, None) if v: return v[1] for k, v in self._keys.items(): if repr(key) == repr(k): return v[1] return default | def getValue(self, key, default=None): """get value""" if type(key) in (StringType, UnicodeType): key = int(key) elif type(key) is IntType: pass else: raise TypeError("Key must be string or int") return DisplayList.getValue(self, key, default) |
def toReferenceCatalog(portal, out): | def migrateReferences(portal, out): at = getToolByName(portal, TOOL_NAME) rc = getToolByName(portal, REFERENCE_CATALOG) uc = getToolByName(portal, UID_CATALOG) | def toReferenceCatalog(portal, out): if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) #Now map the old references on AT to the RC at = portal.archetype_tool refs = getattr(a... |
if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) at = portal.archetype_tool refs = getattr(at, 'refs', None) if not refs: return allbrains = portal.portal_catalog() ... | refs = getattr(at, 'refs', None) if refs: count=0 print >>out, "Old references are stored in %s, so migrating them to new style reference annotations." % (TOOL_NAME) allbrains = uc() | def toReferenceCatalog(portal, out): if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) #Now map the old references on AT to the RC at = portal.archetype_tool refs = getattr(a... |
sourceUID = getattr(sourceObj.aq_base, '_uid', None) | sourceUID = getattr(sourceObj.aq_base, olduididx, None) | def toReferenceCatalog(portal, out): if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) #Now map the old references on AT to the RC at = portal.archetype_tool refs = getattr(a... |
for targetUID, relationship in refs.get(sourceUID, []): tObj = uc(UID=targetUID)[0].getObject() rc.addReference(sourceObj, tObj, relationship) | sids = rc.uniqueValuesFor('sourceUID') for sid in sids: set = rc(sourceUID=sid) sourceObject = uc(UID=sid)[0].getObject() if not sourceObject: continue annotations = sourceObject._getReferenceAnnotations() for brain in set: path = brain.getPath() ref = getattr(rc, path, None) if ref is None: continue if path.find('r... | def toReferenceCatalog(portal, out): if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) #Now map the old references on AT to the RC at = portal.archetype_tool refs = getattr(a... |
for brain in allbrains: sObject = brain.getObject() if hasattr(sObject, '_uid'): delattr(sObject, '_uid') uc.manage_reindexIndex() rc.manage_reindexIndex() else: rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) sids = rc.uniqueValuesFor('sourceUID') for sid in sids: set = rc(sourceUID... | setattr(ref, UUID_ATTR, make_uuid()) ref.id = ref.UID() ref = aq_base(ref) annotations[ref.UID()] = ref rc._delOb(path) sourceObject._catalogRefs(portal) | def toReferenceCatalog(portal, out): if not hasattr(portal, REFERENCE_CATALOG): install_referenceCatalog(portal, out) print >>out, "Added Reference Catalog" rc = getattr(portal, REFERENCE_CATALOG) uc = getattr(portal, UID_CATALOG) #Now map the old references on AT to the RC at = portal.archetype_tool refs = getattr(a... |
class DublinCoreMarshaller(Marshaller): def marshall(self, instance, **kwargs): pass | class PrimaryFieldMarshaller(Marshaller): | def cleanupInstance(self, instance, item=None, container=None): if hasattr(aq_base(instance), 'demarshall_hook'): delattr(instance, 'demarshall_hook') if hasattr(aq_base(instance), 'marshall_hook'): delattr(instance, 'marshall_hook') |
def demarshall(self, instance, data, **kwargs): pass class PrimaryFieldMarshaller(Marshaller): | def demarshall(self, instance, data, **kwargs): pass | |
data = p.get(instance) | data = p and p.get(instance) or '' | def marshall(self, instance, **kwargs): p = instance.getPrimaryField() data = p.get(instance) content_type = length = None # Gather/Guess content type if IBaseUnit.isImplementedBy(data): content_type = data.getContentType() length = data.get_size() data = data.getRaw() |
if length is None: return None | else: log("WARNING: PrimaryFieldMarshaller(%r): field %r does not return a IBaseUnit instance." % (instance, p.getName())) content_type = guess_content_type(data) length = len(data) data = str(data) | def marshall(self, instance, **kwargs): p = instance.getPrimaryField() data = p.get(instance) content_type = length = None # Gather/Guess content type if IBaseUnit.isImplementedBy(data): content_type = data.getContentType() length = data.get_size() data = data.getRaw() |
security.declarePublic('getSize') | security.declarePublic('get_size') | 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... |
security.declarePublic('getSize') | security.declarePublic('get_size') | def download(self, instance): """Kicks download [PRIVATE] |
security.declarePublic('getSize') | security.declarePublic('get_size') | def set(self, instance, value, **kwargs): """ Assign input value to object. If mimetype is not specified, pass to processing method without one and add mimetype returned to kwargs. Assign kwargs to instance. """ if value is None: # nothing to do return |
security.declarePublic('getSize') | security.declarePublic('get_size') | def get(self, instance, **kwargs): value = ObjectField.get(self, instance, **kwargs) or () if config.ZOPE_LINES_IS_TUPLE_TYPE: return tuple([encode(v, instance, **kwargs) for v in value]) else: return [encode(v, instance, **kwargs) for v in value] |
security.declarePublic('getSize') | security.declarePublic('get_size') | def assign(x, y): abs_paths[x]=y |
security.declarePublic('getSize') | security.declarePublic('get_size') | def get(self, instance, **kwargs): """Return computed value""" return eval(self.expression, {'context': instance, 'here' : instance}) |
security.declarePublic('getSize') | security.declarePublic('get_size') | def set(self, instance, value, **kwargs): """If value is not defined or equal to 0, set field to false; otherwise, set to true.""" if not value or value == '0': value = None ## False else: value = 1 |
""" | """get size of scale or original | def getSize(self, instance, scale=None): """ """ if scale is None: img = self.get(instance) return img.width, img.height else: sizes = self.getAvailableSizes(instance) size = sizes.get(scale) return size[0], size[1] |
security.declarePublic('getSize') | security.declareProtected(CMFCorePermissions.View, 'getScale') def getScale(self, instance, scale=None, **kwargs): """Get scale by name or original """ if scale is None: return self.get(instance, **kwargs) else: assert(scale in self.getAvailableSizes(instance).keys(), 'Unknown scale %s for %s' % (scale, self.getName())... | def getSize(self, instance, scale=None): """ """ if scale is None: img = self.get(instance) return img.width, img.height else: sizes = self.getAvailableSizes(instance) size = sizes.get(scale) return size[0], size[1] |
'assertion': lambda result:result == 'v1: bass'} | 'assertion': lambda result:result.startswith('v1: bass')} | def __call__(self, value, instance, field, *args, **kwargs): return self.fun(value) |
skw = self.allowed_types and {'portal_type':self.allowed_types} or {} brains = pc.searchResults(**skw) | brains = pc.searchResults(portal_type=self.allowed_types) | def _Vocabulary(self, content_instance): pairs = [] pc = getToolByName(content_instance, 'portal_catalog') uc = getToolByName(content_instance, config.UID_CATALOG) |
try: uid = uc.getMetadataForUID(b.getPath())['UID'] pairs.append((uid, label(b))) except KeyError: pass | path=b.getPath()[len(getToolByName(content_instance,'portal_url').getPortalPath())+1:] uid = uc.getMetadataForUID(path)['UID'] pairs.append((uid, label(b))) | def _Vocabulary(self, content_instance): pairs = [] pc = getToolByName(content_instance, 'portal_catalog') uc = getToolByName(content_instance, config.UID_CATALOG) |
value, format = self.scale(data,w,h) | value = self.scale(data,w,h) | def rescaleOriginal(self, value, **kwargs): """rescales the original image and sets the data |
name = field.getName() method = None | def makeMethod(self, klass, field, mode, methodName): name = field.getName() method = None if mode == "r": def generatedAccessor(self, **kw): """Default Accessor.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].get(self, **kw) method = generatedAc... | |
def generatedAccessor(self, **kw): """Default Accessor.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].get(self, **kw) method = generatedAccessor | method = lambda self, field=field.getName(), **kw: \ self.Schema()[field].get(self, **kw) | def generatedAccessor(self, **kw): """Default Accessor.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].get(self, **kw) |
def generatedEditAccessor(self, **kw): """Default Edit Accessor.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].getRaw(self, **kw) method = generatedEditAccessor | method = lambda self, field=field.getName(), **kw: \ self.Schema()[field].getRaw(self, **kw) | def generatedEditAccessor(self, **kw): """Default Edit Accessor.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].getRaw(self, **kw) |
def generatedMutator(self, value, **kw): """Default Mutator.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].set(self, value, **kw) method = generatedMutator | method = lambda self, value, field=field.getName(), **kw: \ self.Schema()[field].set(self, value, **kw) | def generatedMutator(self, value, **kw): """Default Mutator.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].set(self, value, **kw) |
name, | field.getName(), | def generatedMutator(self, value, **kw): """Default Mutator.""" if kw.has_key('schema'): schema = kw['schema'] else: schema = self.Schema() kw['schema'] = schema return schema[name].set(self, value, **kw) |
if not klass.__dict__.has_key('security'): | if not hasattr(klass, "security"): | def updateSecurity(self, klass, field, mode, methodName): if not klass.__dict__.has_key('security'): security = klass.security = ClassSecurityInfo() else: security = klass.security |
def Schema(self): """Return a (wrapped) schema instance for this object instance.""" return ImplicitAcquisitionWrapper(self.schema, self) klass.Schema = Schema | klass.Schema = lambda self: \ ImplicitAcquisitionWrapper(self.schema, self) | def Schema(self): """Return a (wrapped) schema instance for this object instance.""" return ImplicitAcquisitionWrapper(self.schema, self) |
if (not getattr(klass, 'meta_type', None) or 'meta_type' not in klass.__dict__.keys()): klass.meta_type = klass.__name__ if (not getattr(klass, 'portal_type', None) or 'portal_type' not in klass.__dict__.keys()): klass.portal_type = klass.__name__ | klass.meta_type = klass.__name__ klass.portal_type = klass.__name__ | def generateClass(self, klass): # We are going to assert a few things about the class here # before we start, set meta_type, portal_type based on class # name, but only if they are not set yet if (not getattr(klass, 'meta_type', None) or 'meta_type' not in klass.__dict__.keys()): klass.meta_type = klass.__name__ if (no... |
self.generateMethods(klass, fields) def generateMethods(self, klass, fields): | def generateClass(self, klass): # We are going to assert a few things about the class here # before we start, set meta_type, portal_type based on class # name, but only if they are not set yet if (not getattr(klass, 'meta_type', None) or 'meta_type' not in klass.__dict__.keys()): klass.meta_type = klass.__name__ if (no... | |
if not hasattr(klass, methodName) \ or getattr(klass, methodName) is AT_GENERATE_METHOD: | if not hasattr(klass, methodName): | def handle_mode(self, klass, generator, type, field, mode): attr = _modes[mode]['attr'] # Did the field request a specific method name? methodName = getattr(field, attr, None) if not methodName: methodName = generator.computeMethodName(field, mode) |
def generateCtor(name, module): | def generateCtor(type, module): name = capitalize(type) | def generateCtor(name, module): ctor = """ |
def add%(name)s(self, id, **kwargs): o = %(name)s(id) | def add%s(self, id, **kwargs): o = %s(id) | def add%(name)s(self, id, **kwargs): o = %(name)s(id) self._setObject(id, o) o = getattr(self, id) o.initializeArchetype(**kwargs) return id |
""" % {'name':name} | """ % (name, type) | def add%(name)s(self, id, **kwargs): o = %(name)s(id) self._setObject(id, o) o = getattr(self, id) o.initializeArchetype(**kwargs) return id |
def generateZMICtor(name, module): zmi_ctor = """ def manage_add%(name)s(self, id, REQUEST=None): ''' Constructor for %(name)s ''' kwargs = {} if REQUEST is not None: kwargs = REQUEST.form.copy() del kwargs['id'] id = add%(name)s(self, id, **kwargs) obj = self._getOb(id) manage_tabs_message = 'Successfully added %(name... | def generateZMICtor(name, module): zmi_ctor = """ | |
generateMethods = _cg.generateMethods | def manage_add%(name)s(self, id, REQUEST=None): ''' Constructor for %(name)s ''' kwargs = {} if REQUEST is not None: kwargs = REQUEST.form.copy() del kwargs['id'] id = add%(name)s(self, id, **kwargs) obj = self._getOb(id) manage_tabs_message = 'Successfully added %(name)s' if REQUEST is not None: return obj.manage_edit... | |
return inspect.stack()[start:end] | try: return inspect.stack()[start:end] except TypeError: return [] | def generateFrames(self, start=None, end=None): return inspect.stack()[start:end] |
wrapped = instance.__of__(context) | def getWidgets(self, instance=None, package=None, type=None, context=None, mode='edit', fields=None, schemata=None, nosort=None): """Empty widgets for standalone rendering""" | |
REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, '')) | if hasattr(REQUEST, 'RESPONSE'): REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, '')) | def __bobo_traverse__(self, REQUEST, name, RESPONSE=None): """ transparent access to session subobjects """ # is it a registered sub object data = self.getSubObject(name, REQUEST, RESPONSE) if data is not None: return data # or a standard attribute (maybe acquired...) target = getattr(self, name, None) if target is not... |
security.declareProtected(CMFCorePermissions.View, 'index_html') index_html = SkinnedFolder.index_html | def index_html(self): """ Allow creation of . """ if self.has_key('index_html'): return self._getOb('index_html') request = getattr(self, 'REQUEST', None) if request and request.has_key('REQUEST_METHOD'): if (request.maybe_webdav_client and request['REQUEST_METHOD'] in ['PUT']): nr = NullResource(self, 'index_html') ... | def __getitem__(self, key): """ Override BTreeFolder __getitem__ """ if key in self.Schema().keys() and key[:1] != "_": #XXX 2.2 accessor = self.Schema()[key].getAccessor(self) if accessor is not None: return accessor() return CMFBTreeFolder.__getitem__(self, key) |
deprecated("Please use Archetypes.skins") installPathsFromDir(self, product_skins_dir, globals=globals) | deprecated("install_subskin: Please use Archetypes.skins") installPathsFromDir(self, product_skins_dir, globals=globals, position='custom') | def install_subskin(self, out, globals=types_globals, product_skins_dir='skins'): """Deprecated. Please use Archetypes.skins. """ deprecated("Please use Archetypes.skins") installPathsFromDir(self, product_skins_dir, globals=globals) |
def validate(self, value, instance, errors={}, **kwargs): | def validate(self, value, instance, errors=None, **kwargs): | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() if errors and errors.has_key(name): return True |
return str(value.data) | return data | def rescaleOriginal(self, value, **kwargs): """rescales the original image and sets the data |
fvalue, format = self.scale(value, w, h) | fvalue, format = self.scale(data, w, h) | def rescaleOriginal(self, value, **kwargs): """rescales the original image and sets the data |
mutator = field.getMutator(instance) if mutator is None: continue | 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': # always set defaults #if not hasattr(aq_base(instance), field.getName()) and \ # getattr(instance, f... | |
mutator = field.getMutator(instance) | 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': # always set defaults #if not hasattr(aq_base(instance), field.getName()) and \ # getattr(instance, f... | |
length = len(data) | if hasattr(p, 'get_size'): length = p.get_size(instance) else: length = len(data) | def marshall(self, instance, **kwargs): p = instance.getPrimaryField() data = p and instance[p.getName()] or '' content_type = length = None # Gather/Guess content type if IBaseUnit.isImplementedBy(data): content_type = data.getContentType() length = data.get_size() data = data.getRaw() else: log("WARNING: PrimaryFie... |
if hasattr(data, 'data'): | if shasattr(data, 'data'): | def marshall(self, instance, **kwargs): p = instance.getPrimaryField() data = p and instance[p.getName()] or '' content_type = length = None # Gather/Guess content type if IBaseUnit.isImplementedBy(data): content_type = data.getContentType() length = data.get_size() data = data.getRaw() else: log("WARNING: PrimaryFie... |
res = validation.validate(v, value, **kwargs) | res = validation.validate(v, value, instance=instance, errors=errors, **kwargs) | def validate(self, value, instance, errors={}, **kwargs): """ Validate passed-in value using all field validators. Return None if all validations pass; otherwise, return failed result returned by validator """ name = self.getName() |
if res is not False: | if res is not False and name != res.getName(): | def addField(self, field): """Adds a given field to my dictionary of fields.""" field = aq_base(field) if IField.isImplementedBy(field): if getattr(field, 'primary', False): res = self.hasPrimary() if res is not False: raise SchemaException("Tried to add '%s' as primary field "\ "but %s already has the primary field '%... |
(field.getName(), repr(self), res.getName()) | (name, repr(self), res.getName()) | def addField(self, field): """Adds a given field to my dictionary of fields.""" field = aq_base(field) if IField.isImplementedBy(field): if getattr(field, 'primary', False): res = self.hasPrimary() if res is not False: raise SchemaException("Tried to add '%s' as primary field "\ "but %s already has the primary field '%... |
name = field.getName() | def addField(self, field): """Adds a given field to my dictionary of fields.""" field = aq_base(field) if IField.isImplementedBy(field): if getattr(field, 'primary', False): res = self.hasPrimary() if res is not False: raise SchemaException("Tried to add '%s' as primary field "\ "but %s already has the primary field '%... | |
def isDiscussable(self): | def isDiscussable(self, encoding=None): | def isDiscussable(self): result = None try: result = getToolByName(self, 'portal_discussion').isDiscussionAllowedFor(self) except: pass return result |
if type(allowDiscussion) == StringType: allowDiscussion = allowDiscussion.lower().strip() allowDiscussion = {'on' : 1, 'off': 0, 'none':None}.get(allowDiscussion, None) try: getToolByName(self, 'portal_discussion').overrideDiscussionFor(self, allowDiscussion) except: log_exc() pass | allowDiscussion = allowDiscussion.lower().strip() allowDiscussion = {'on' : 1, 'off': 0, 'none':None, '':None}.get(allowDiscussion, None) getToolByName(self, 'portal_discussion').overrideDiscussionFor(self, allowDiscussion) | def allowDiscussion(self, allowDiscussion=None): if allowDiscussion is not None: try: allowDiscussion = int(allowDiscussion) except: if type(allowDiscussion) == StringType: allowDiscussion = allowDiscussion.lower().strip() allowDiscussion = {'on' : 1, 'off': 0, 'none':None}.get(allowDiscussion, None) |
def unset(name, instance, value, **kwargs): | def unset(name, instance, **kwargs): | def unset(name, instance, value, **kwargs): """unset a value under the key 'name'. used when changing storage for a field.""" |
if not validators[0][0].name == 'isEmpty': validators.insertSufficient('isEmpty') | if not validators[0][0].name.startswith('isEmpty'): validators.insertSufficient('isEmptyNoError') | def _validationLayer(self): """ Resolve that each validator is in the service. If validator is not, log a warning. |
security.declarePrivate( '_datify' ) def _datify( self, attrib ): """FIXME: overriden from DublinCore to deal with blank value...""" if attrib == 'None' or not attrib: attrib = None elif not isinstance( attrib, DateTime ) and attrib is not None: attrib = DateTime( attrib ) return attrib | def Schemata(self): from Products.Archetypes.Schema import getSchemata return getSchemata(self) | |
mimetype = 'image/%s' % format | mimetype = 'image/%s' % format.lower() | def createScales(self, instance): """creates the scales and save them """ sizes = self.getAvailableSizes(instance) if not HAS_PIL or not sizes: return img = self.getRaw(instance) if not img: return filename = self.getFilename(instance) #dot = filename.rfind('.') #filename, ext = filename[:dot], filename[dot:] data = st... |
def scale(self, data, w, h): | def scale(self, data, w, h, default_format = 'PNG'): | def scale(self, data, w, h): """ scale image (with material from ImageTag_Hotfix)""" #make sure we have valid int's size = int(w), int(h) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.