Saves a reference to a placeable
549350
def _associate_placeable(self, location):
        
        if not location:
            return

        placeable, _ = unpack_location(location)
        self.previous_placeable = placeable
        if not self.placeables or (placeable != self.placeables[-1]):
            self.placeables.append(placeable)
383212
def insert_content(object, location = -1)
      object = { is_reference_only: true, referenced_object: { indirect_reference_id: 0, raw_stream_content: object } } if object.is_a?(String)
      raise TypeError, 'expected a String or Hash object.' unless object.is_a?(Hash)
      prep_content_array
      self[:Contents].insert location, object
      self[:Contents].flatten!
      self
    end
22222
def save_location(self, filename: str, location: PostLocation, mtime: datetime) -> None:
        """"""
        filename += '_location.txt'
        location_string = (location.name + "\n" +
                           "https://maps.google.com/maps?q={0},{1}&ll={0},{1}\n".format(location.lat,
                                                                                        location.lng))
        with open(filename, 'wb') as text_file:
            shutil.copyfileobj(BytesIO(location_string.encode()), text_file)
        os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))
        self.context.log('geo', end=' ', flush=True)
681679
def save_inst(self, obj):
        """"""
        cls = obj.__class__

        # Try the dispatch table (pickle module doesn't do it)
        f = self.dispatch.get(cls)
        if f:
            f(self, obj)  # Call unbound method with explicit self
            return

        memo = self.memo
        write = self.write
        save = self.save

        if hasattr(obj, '__getinitargs__'):
            args = obj.__getinitargs__()
            len(args)  # XXX Assert it's a sequence
            pickle._keep_alive(args, memo)
        else:
            args = ()

        write(pickle.MARK)

        if self.bin:
            save(cls)
            for arg in args:
                save(arg)
            write(pickle.OBJ)
        else:
            for arg in args:
                save(arg)
            write(pickle.INST + cls.__module__ + '\n' + cls.__name__ + '\n')

        self.memoize(obj)

        try:
            getstate = obj.__getstate__
        except AttributeError:
            stuff = obj.__dict__
        else:
            stuff = getstate()
            pickle._keep_alive(stuff, memo)
        save(stuff)
        write(pickle.BUILD)
769343
function() {

          if (common.isUndefined(SAVE_DIALOGUE)) {
            SAVE_DIALOGUE = new CenteredDiv();
            SAVE_DIALOGUE.domElement.innerHTML = saveDialogueContents;
          }

          if (this.parent) {
            throw new Error("You can only call remember on a top level GUI.");
          }

          var _this = this;

          common.each(Array.prototype.slice.call(arguments), function(object) {
            if (_this.__rememberedObjects.length == 0) {
              addSaveMenu(_this);
            }
            if (_this.__rememberedObjects.indexOf(object) == -1) {
              _this.__rememberedObjects.push(object);
            }
          });

          if (this.autoPlace) {
            // Set save row width
            setWidth(this, this.width);
          }

        }
413635
function updateReferences(el) {
		$.each(mtypes, function (i, pos) {
			var id = marker_prefix + pos + '_' + el.id;
			var marker_name = 'marker-'+pos;
			var marker = getLinked(el, marker_name);
			if (!marker || !marker.attributes.se_type) {return;} // not created by this extension
			var url = el.getAttribute(marker_name);
			if (url) {
				var len = el.id.length;
				var linkid = url.substr(-len-1, len);
				if (el.id != linkid) {
					var val = $('#'+pos + '_marker').attr('value');
					addMarker(id, val);
					svgCanvas.changeSelectedAttribute(marker_name, "url(#" + id + ")");
					if (el.tagName === 'line' && pos == 'mid') {el = convertline(el);}
					S.call("changed", selElems);
				}
			}
		});
	}
224230
def _ReferenceFromPairs(pairs, reference=None, app=None, namespace=None):
  
  if reference is None:
    reference = entity_pb.Reference()
  path = reference.mutable_path()
  last = False
  for kind, idorname in pairs:
    if last:
      raise datastore_errors.BadArgumentError(
          'Incomplete Key entry must be last')
    t = type(kind)
    if t is str:
      pass
    elif t is unicode:
      kind = kind.encode('utf8')
    else:
      if issubclass(t, type):
        # Late import to avoid cycles.
        from .model import Model
        modelclass = kind
        if not issubclass(modelclass, Model):
          raise TypeError('Key kind must be either a string or subclass of '
                          'Model; received %r' % modelclass)
        kind = modelclass._get_kind()
        t = type(kind)
      if t is str:
        pass
      elif t is unicode:
        kind = kind.encode('utf8')
      elif issubclass(t, str):
        pass
      elif issubclass(t, unicode):
        kind = kind.encode('utf8')
      else:
        raise TypeError('Key kind must be either a string or subclass of Model;'
                        ' received %r' % kind)
    # pylint: disable=superfluous-parens
    if not (1 <= len(kind) <= _MAX_KEYPART_BYTES):
      raise ValueError('Key kind string must be a non-empty string up to %i'
                       'bytes; received %s' %
                       (_MAX_KEYPART_BYTES, kind))
    elem = path.add_element()
    elem.set_type(kind)
    t = type(idorname)
    if t is int or t is long:
      # pylint: disable=superfluous-parens
      if not (1 <= idorname < _MAX_LONG):
        raise ValueError('Key id number is too long; received %i' % idorname)
      elem.set_id(idorname)
    elif t is str:
      # pylint: disable=superfluous-parens
      if not (1 <= len(idorname) <= _MAX_KEYPART_BYTES):
        raise ValueError('Key name strings must be non-empty strings up to %i '
                         'bytes; received %s' %
                         (_MAX_KEYPART_BYTES, idorname))
      elem.set_name(idorname)
    elif t is unicode:
      idorname = idorname.encode('utf8')
      # pylint: disable=superfluous-parens
      if not (1 <= len(idorname) <= _MAX_KEYPART_BYTES):
        raise ValueError('Key name unicode strings must be non-empty strings up'
                         ' to %i bytes; received %s' %
                         (_MAX_KEYPART_BYTES, idorname))
      elem.set_name(idorname)
    elif idorname is None:
      last = True
    elif issubclass(t, (int, long)):
      # pylint: disable=superfluous-parens
      if not (1 <= idorname < _MAX_LONG):
        raise ValueError('Key id number is too long; received %i' % idorname)
      elem.set_id(idorname)
    elif issubclass(t, basestring):
      if issubclass(t, unicode):
        idorname = idorname.encode('utf8')
      # pylint: disable=superfluous-parens
      if not (1 <= len(idorname) <= _MAX_KEYPART_BYTES):
        raise ValueError('Key name strings must be non-empty strings up to %i '
                         'bytes; received %s' % (_MAX_KEYPART_BYTES, idorname))
      elem.set_name(idorname)
    else:
      raise TypeError('id must be either a numeric id or a string name; '
                      'received %r' % idorname)
  # An empty app id means to use the default app id.
  if not app:
    app = _DefaultAppId()
  # Always set the app id, since it is mandatory.
  reference.set_app(app)
  # An empty namespace overrides the default namespace.
  if namespace is None:
    namespace = _DefaultNamespace()
  # Only set the namespace if it is not empty.
  if namespace:
    reference.set_name_space(namespace)
  return reference
338868
function PropertyReference(parentReference, propertyKey) {
      _classCallCheck(this, PropertyReference);

      _CachedReference.call(this);

      var parentReferenceTag = parentReference.tag;
      var parentObjectTag = new _glimmerReference.UpdatableTag(_glimmerReference.CURRENT_TAG);

      this.tag = _glimmerReference.combine([parentReferenceTag, parentObjectTag]);
      this._parentReference = parentReference;
      this._parentObjectTag = parentObjectTag;
      this._propertyKey = propertyKey;
    }
332936
def save(self):
        
        if self.mode in ("wb+", 'rb+'):
            if not self.is_open:
                raise IOError("file closed")
            self.write_reference_properties()
            self.manager.write_objects()
1243031
def save(self, obj):
        """"""
        if not obj.id:
            obj.id = uuid()

        stored_data = {
            '_id': obj.id,
            'value': json.loads(obj.to_data())
        }

        index_vals = obj.indexes() or {}
        for key in obj.__class__.index_names() or []:
            val = index_vals.get(key, '')
            stored_data[key] = str(val)

        coll = self.get_collection(obj.__class__.get_table_name())
        coll.update({"_id": obj.id}, stored_data, upsert=True)
518063
def save_value(self, name, value):
        """"""
        session_name = 'list_{}_{}_{}'.format(self.kwargs.get('app'), self.kwargs.get('model'), name)
        self.request.session[session_name] = value
        setattr(self, name, value)
        return value
100732
def insertReference(self, reference):
        
        models.Reference.create(
            id=reference.getId(),
            referencesetid=reference.getParentContainer().getId(),
            name=reference.getLocalId(),
            length=reference.getLength(),
            isderived=reference.getIsDerived(),
            species=json.dumps(reference.getSpecies()),
            md5checksum=reference.getMd5Checksum(),
            sourceaccessions=json.dumps(reference.getSourceAccessions()),
            sourceuri=reference.getSourceUri())
989680
function insertAfter(targetElement, targetScope) {
            // Ensure the placeholder is visible in the target (unless it's a table row)
            if (placeHolder.css('display') !== 'table-row') {
              placeHolder.css('display', 'block');
            }
            if (!targetScope.sortableScope.options.clone) {
              targetElement.after(placeHolder);
              dragItemInfo.moveTo(targetScope.sortableScope, targetScope.index() + 1);
            }
          }
605039
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={}, options=None, **kwargs):
        
        if info or key:
            raise Exception('Renderer does not support saving metadata to file.')

        if isinstance(obj, (Plot, NdWidget)):
            plot = obj
        else:
            with StoreOptions.options(obj, options, **kwargs):
                plot = self_or_cls.get_plot(obj)

        if (fmt in list(self_or_cls.widgets.keys())+['auto']) and len(plot) > 1:
            with StoreOptions.options(obj, options, **kwargs):
                if isinstance(basename, basestring):
                    basename = basename+'.html'
                self_or_cls.export_widgets(plot, basename, fmt)
            return

        rendered = self_or_cls(plot, fmt)
        if rendered is None: return
        (data, info) = rendered
        encoded = self_or_cls.encode(rendered)
        prefix = self_or_cls._save_prefix(info['file-ext'])
        if prefix:
            encoded = prefix + encoded
        if isinstance(basename, (BytesIO, StringIO)):
            basename.write(encoded)
            basename.seek(0)
        else:
            filename ='%s.%s' % (basename, info['file-ext'])
            with open(filename, 'wb') as f:
                f.write(encoded)
574250
def _saveDB(self):
        """"""
        # We're a "fresh" copy now
        self._updated = time.time()
        if self._new:
            operation = 'INSERT'
        else:
            operation = 'UPDATE'
        (sql, fields) = self._prepareSQL(operation)
        values = []
        for field in fields:
            value = getattr(self, field)
            if isinstance(value, Forgetter):
                # It's another object, we store only the ID
                if value._new:
                    # It's a new object too, it must be saved!
                    value.save()
                try:
                    (value,) = value._getID()
                except:
                    raise "Can't reference multiple-primary-key: %s" % value
            values.append(value)
        cursor = self.cursor()
        cursor.execute(sql, values)
        # cursor.commit()

        if not self._validID():
            if not len(self._getID()) == 1:
                raise "Can't retrieve auto-inserted ID for multiple-primary-key"
            # Here's the mysql magic to get the new ID
            self._setID(cursor.insert_id())
        cursor.close()
        self._new = False
1249742
protected void insertAtPreferredLocation(Element parent, Element child, Counter counter)
   {
      int contentIndex = 0;
      int elementCounter = 0;
      Iterator it = parent.getContent().iterator();
      Text lastText = null;
      int offset = 0;
      while (it.hasNext() && (elementCounter <= counter.getCurrentIndex()))
      {
         Object next = it.next();
         offset = offset + 1;
         if (next instanceof Element)
         {
            elementCounter = elementCounter + 1;
            contentIndex = contentIndex + offset;
            offset = 0;
         }
         if ((next instanceof Text) && it.hasNext())
         {
            lastText = (Text) next;
         }
      }
      if ((lastText != null) && (lastText.getTextTrim().length() == 0))
      {
         lastText = (Text) lastText.clone();
      }
      else
      {
         StringBuilder starter = new StringBuilder(lineSeparator);
         for (int i = 0; i < counter.getDepth(); i++)
         {
            starter.append("  "); // TODO make settable?
         }
         lastText = factory.text(starter.toString());
      }
      if (parent.getContentSize() == 0)
      {
         Text finalText = (Text) lastText.clone();
         finalText.setText(finalText.getText().substring(0, finalText.getText().length() - "  ".length()));
         parent.addContent(contentIndex, finalText);
      }
      parent.addContent(contentIndex, child);
      parent.addContent(contentIndex, lastText);
   }
382558
function (key, value) {
      store[key] = value
      //not urgent, but save this if we are not doing anything.
      dirty[key] = true
      apply_write(key, value)
    }