def __init__(self, env, name=None, version=None):
        """Create a new page object or retrieves an existing page.

        :param env: an `Environment` object.
        :param name: the page name or a `Resource` object.
        :param version: the page version. The value takes precedence over the
                        `Resource` version when both are specified.
        """
        self.env = env
        if version:
            try:
                version = int(version)
            except ValueError:
                version = None

        if isinstance(name, Resource):
            resource = name
            name = resource.id
            if version is None and resource.version is not None:
                try:
                    version = int(resource.version)
                except __HOLE__:
                    version = None

        self.name = name
        # The version attribute always returns the version of the page,
        # however resource.version will be None when version hasn't been
        # specified when creating the object and the object represents the
        # most recent version of the page. This behavior is used in web_ui.py
        # to determine whether to render a versioned page, or just the most
        # recent version of the page.
        self._resource_version = version
        if name:
            self._fetch(name, version)
        else:
            self.version = 0
            self.text = self.comment = self.author = ''
            self.time = None
            self.readonly = 0
        self.old_text = self.text
        self.old_readonly = self.readonly
dataset/ETHPy150Open edgewall/trac/trac/wiki/model.py/WikiPage.__init__