def get_jythonEditObject(uri, base, invid, editset, original):
    '''Cached, dynamic class loading by uri
  '''
    global class_hash

    # First, we'll look for this class in the cache
    if class_hash.has_key(uri):
        Ganymede.debug("Loaded " + uri + " from the Jython class cache.")
        return class_hash[uri](base, invid, editset, original)

    # Okay, since the class isn't in the cache, we need to slurp
    # it from the specified location
    JythonURIClassLoader.load(uri)

    # Snag the class definition from the default module that
    # JythonURIClassLoader created for us
    from ganymede_hot_code import EditObject

    # Store this class in the hash. This doesn't involve any
    # synchronization because the caller should already be
    # synchronized
    Ganymede.debug("Adding " + uri + " to the Jython class cache.")
    class_hash[uri] = EditObject

    # And return an instantiation of the class
    return EditObject(base, invid, editset, original)
def get_jythonEditObject( uri, base, invid, editset, original ):
  '''Cached, dynamic class loading by uri
  '''
  global class_hash

  # First, we'll look for this class in the cache
  if class_hash.has_key(uri):
    Ganymede.debug( "Loaded " + uri + " from the Jython class cache." )
    return class_hash[uri]( base, invid, editset, original );
  
  # Okay, since the class isn't in the cache, we need to slurp 
  # it from the specified location
  JythonURIClassLoader.load( uri )

  # Snag the class definition from the default module that
  # JythonURIClassLoader created for us
  from ganymede_hot_code import EditObject

  # Store this class in the hash. This doesn't involve any
  # synchronization because the caller should already be
  # synchronized
  Ganymede.debug( "Adding " + uri + " to the Jython class cache." )
  class_hash[ uri ] = EditObject

  # And return an instantiation of the class
  return EditObject( base, invid, editset, original )
Ejemplo n.º 3
0
  def builderPhase2( self ):
    Ganymede.debug( "LDAPBuilderTask builderPhase2 running" )

    build_script = System.getProperty( "ganymede.biulder.scriptlocation" )
    if not build_script:
      raise RuntimeException( "Unable to determine builder script location" )
    else:
      build_script = PathComplete.completePath( build_script ) + "ldapbuilder"

    if not os.path.is_file( build_script ):
      raise RuntimeException( build_script + " doesn't exist, not running external LDAP build script" )

    os.system( build_script )

    Ganymede.debug( "LDAPBuilderTask builderPhase2 complete" )
    return 1
Ejemplo n.º 4
0
  def finalizeAddElements( self, field, submittedValues ):
    '''
    This method allows the DBEditObject to have executive approval of any
    vector-vector add operation, and to take any special actions in reaction to
    the add.. if this method returns null or a success code in its ReturnVal,
    the DBField that called us is guaranteed to proceed to make the change to
    its vector.  If this method returns a non-success code in its ReturnVal,
    the DBField that called us will not make the change, and the field will be
    left unchanged.
   
    The <field> parameter identifies the field that is requesting approval for
    item deletion, and the <submittedValues> parameter carries the values to be
    added.
   
    The DBField that called us will take care of all standard checks on the
    operation (including vector bounds, etc.) before calling this method.
    Under normal circumstances, we wont need to do anything here.
    '''
    if field.getID() not in [self.MEMBERS_FIELD_ID, self.EXTERNALTARGETS_FIELD_ID]:
      return None

    if not self.fitsInNIS(submittedValues):
      return Ganymede.createErrorDialog("Overflow error", \
		"The " + str(len(submittedValues)) + \
                " items that you are attempting to add to the " + self.getTypeName() + \
		" email list cannot fit.  No NIS email list in the laboratory's " + \
		"network can be longer than 1024 characters when converted to an " + \
		"NIS email alias definition.\n\n" + \
		"If you need this list to be expanded, you should create a new sublist " + \
		"for the overflow items, move some items from this list to the new sublist, " + \
		" and then add the new sublist to this list.")

    return None
def unload_class(uri=None):
    '''Remove a URI => Class mapping from the cache

  NOTE: If we aren't passed in an argument, or if the
  argument is None, we wipe out the entire cache.
  '''
    global class_hash

    # This doesn't involve any synchronization because the
    # caller should already be synchronized
    if not uri:
        Ganymede.debug("Zeroing out the Jython class cache.")
        class_hash = {}
    else:
        if class_hash.has_key(uri):
            Ganymede.debug("Removing " + uri + " from the Jython class cache.")
            del class_hash[uri]
def unload_class( uri=None ):
  '''Remove a URI => Class mapping from the cache

  NOTE: If we aren't passed in an argument, or if the
  argument is None, we wipe out the entire cache.
  '''
  global class_hash
  
  # This doesn't involve any synchronization because the
  # caller should already be synchronized
  if not uri:
    Ganymede.debug( "Zeroing out the Jython class cache." )
    class_hash = {}
  else:
    if class_hash.has_key(uri):
      Ganymede.debug( "Removing " + uri + " from the Jython class cache." )
      del class_hash[uri]
Ejemplo n.º 7
0
  def builderPhase1( self ):
    Ganymede.debug( "LDAPBuilderTask builderPhase1 running" )

    self.dnsdomain = System.getProperty("ganymede.gash.dnsdomain")
    if not self.dnsdomain:
      raise RuntimeException("LDAPBuilder not able to determine dns domain name")
    
    self.output_path = System.getProperty("ganymede.builder.output")
    if not self.output_path:
      raise RuntimeException("LDAPBuilder not able to determine output directory")
    else:
      self.output_path = PathComplete.completePath( self.output_path )

    self.build_users_and_groups()
    self.build_netgroups()

    Ganymede.debug( "LDAPBuilderTask builderPhase1 complete" )
    return 1
Ejemplo n.º 8
0
    def builderPhase2(self):
        Ganymede.debug("LDAPBuilderTask builderPhase2 running")

        build_script = System.getProperty("ganymede.biulder.scriptlocation")
        if not build_script:
            raise RuntimeException(
                "Unable to determine builder script location")
        else:
            build_script = PathComplete.completePath(
                build_script) + "ldapbuilder"

        if not os.path.is_file(build_script):
            raise RuntimeException(
                build_script +
                " doesn't exist, not running external LDAP build script")

        os.system(build_script)

        Ganymede.debug("LDAPBuilderTask builderPhase2 complete")
        return 1
Ejemplo n.º 9
0
    def builderPhase1(self):
        Ganymede.debug("LDAPBuilderTask builderPhase1 running")

        self.dnsdomain = System.getProperty("ganymede.gash.dnsdomain")
        if not self.dnsdomain:
            raise RuntimeException(
                "LDAPBuilder not able to determine dns domain name")

        self.output_path = System.getProperty("ganymede.builder.output")
        if not self.output_path:
            raise RuntimeException(
                "LDAPBuilder not able to determine output directory")
        else:
            self.output_path = PathComplete.completePath(self.output_path)

        self.build_users_and_groups()
        self.build_netgroups()

        Ganymede.debug("LDAPBuilderTask builderPhase1 complete")
        return 1
Ejemplo n.º 10
0
  def build_netgroups( self ):
    # Only build the output if its constituent objects have changed:
    # Users, groups, user netgroups, systems, and system netgroups
    if not self.super__baseChanged( SchemaConstants.UserBase ) and \
       not self.super__baseChanged( 257 ) and \
       not self.super__baseChanged( 270 ) and \
       not self.super__baseChanged( 263 ) and \
       not self.super__baseChanged( 271 ):
      return

    Ganymede.debug( "Writing out netgroups" )
    self.output_file = open( self.output_path + "netgroups.ldif", "w" )

    for netgroup_type in ['User Netgroup', 'System Netgroups']:
      for netgroup in self.db[netgroup_type].keys():
        self.netgroup_to_LDIF( self.db[netgroup_type][netgroup] )
        self.output_file.write( "\n" )

    self.output_file.flush()
    self.output_file.close()
    self.output_file = None
Ejemplo n.º 11
0
    def build_netgroups(self):
        # Only build the output if its constituent objects have changed:
        # Users, groups, user netgroups, systems, and system netgroups
        if not self.super__baseChanged( SchemaConstants.UserBase ) and \
           not self.super__baseChanged( 257 ) and \
           not self.super__baseChanged( 270 ) and \
           not self.super__baseChanged( 263 ) and \
           not self.super__baseChanged( 271 ):
            return

        Ganymede.debug("Writing out netgroups")
        self.output_file = open(self.output_path + "netgroups.ldif", "w")

        for netgroup_type in ['User Netgroup', 'System Netgroups']:
            for netgroup in self.db[netgroup_type].keys():
                self.netgroup_to_LDIF(self.db[netgroup_type][netgroup])
                self.output_file.write("\n")

        self.output_file.flush()
        self.output_file.close()
        self.output_file = None
Ejemplo n.º 12
0
  def build_users_and_groups( self ):
    # Only build the output if the users/groups have changed
    if not self.super__baseChanged( SchemaConstants.UserBase ) and \
       not self.super__baseChanged( 257 ):
      return
      
    Ganymede.debug( "Need to build LDAP users and groups output" )

    Ganymede.debug( "Writing out users" )
    self.output_file = open( self.output_path + "users.ldif", "w" )
    
    for user in self.db['User'].keys():
      self.user_to_LDIF( self.db['User'][user] )
      self.output_file.write( "\n" )
    
    self.output_file.flush()
    self.output_file.close()

    Ganymede.debug( "Writing out groups" )
    self.output_file = open( self.output_path + "groups.ldif", "w" )

    for group in self.db['Group'].keys():
      self.group_to_LDIF( self.db['Group'][group] )
      self.output_file.write( "\n" )

    self.output_file.flush()
    self.output_file.close()
Ejemplo n.º 13
0
    def build_users_and_groups(self):
        # Only build the output if the users/groups have changed
        if not self.super__baseChanged( SchemaConstants.UserBase ) and \
           not self.super__baseChanged( 257 ):
            return

        Ganymede.debug("Need to build LDAP users and groups output")

        Ganymede.debug("Writing out users")
        self.output_file = open(self.output_path + "users.ldif", "w")

        for user in self.db['User'].keys():
            self.user_to_LDIF(self.db['User'][user])
            self.output_file.write("\n")

        self.output_file.flush()
        self.output_file.close()

        Ganymede.debug("Writing out groups")
        self.output_file = open(self.output_path + "groups.ldif", "w")

        for group in self.db['Group'].keys():
            self.group_to_LDIF(self.db['Group'][group])
            self.output_file.write("\n")

        self.output_file.flush()
        self.output_file.close()
Ejemplo n.º 14
0
def load( uri, name="ganymede_hot_code" ):
  # Grab the Jython code from the desired location
  Ganymede.debug( "Loading code from: " + uri )
  f = urllib.urlopen( uri )
  code = f.read()
  f.close()

  # Create a new module that will hold the new code
  module = imp.new_module( name )

  # Compile the new code into Jython bytecode
  bytecode = compile( code, name, "exec" )
  
  Ganymede.debug( "Inserting hot code into module: " + name )
  
  # Execute the code in the context of the newly created module.
  # This will place the new code in the module's scope.
  exec bytecode in module.__dict__, module.__dict__

  # Add the newly created module to the list of modules available
  # to this interpreter instance
  sys.modules[ name ] = module
Ejemplo n.º 15
0
def load(uri, name="ganymede_hot_code"):
    # Grab the Jython code from the desired location
    Ganymede.debug("Loading code from: " + uri)
    f = urllib.urlopen(uri)
    code = f.read()
    f.close()

    # Create a new module that will hold the new code
    module = imp.new_module(name)

    # Compile the new code into Jython bytecode
    bytecode = compile(code, name, "exec")

    Ganymede.debug("Inserting hot code into module: " + name)

    # Execute the code in the context of the newly created module.
    # This will place the new code in the module's scope.
    exec bytecode in module.__dict__, module.__dict__

    # Add the newly created module to the list of modules available
    # to this interpreter instance
    sys.modules[name] = module