def Upload(self,directory,filename):
        """Uploads/Updates/Replaces files"""

        db = self._loadDB(directory)

        logger.debug("wp: Attempting upload of %s"%(filename))

        # See if this already exists in our DB
        if db.has_key(filename):
            pid=db[filename]
            logger.debug('wp: Found %s in DB with post id %s'%(filename,pid))
        else:
            pid=None

        fullfile=os.path.join(directory,filename)

        fid=open(fullfile,'r');

        # Read meta data and content into dictionary
        post=self._readMetaAndContent(fid)

        #Connect to WP
        self._connectToWP()

        # If no pid, it means post is fresh off the press
        # and not uploaded yet!
        if not pid:
            # Get a PID by uploading
            pid=self.wp.call(NewPost(post))
            if pid:
                logger.debug("wp: Uploaded post with pid %s",pid)
                db[filename]=pid
                self._saveDB(directory,db)
                return True
            else:
                logger.error("wp: Couldn't upload post")
                return False
        else:
            # Already has PID, replace post
            logger.debug("wp: Replacing post with pid %s",pid)
            #FIXME: Check return value?!
            self.wp.call(EditPost(pid,post))
            return True

        return False