Orientation perpendicular to Edge
a simple cross product solves your problem:

\begin{equation}
\hat{z}: the \space unit \space vector \space along \space z \space axis\\
\vec{e_\perp}:the \space vector \space perpendicular \space to \space edge \space and \space the \space z \space axis\\
\vec{p_1}:position \space of \space first \space vertex \space in \space world \space coordinates\\
\vec{p_2}:position \space of \space second \space vertex \space in \space world \space coordinates\\
\vec{e_1}:vector \space along \space edge\\
\vec{p_2} - \vec{p_1} = \vec{e_1}\\
\hat{z} \times \vec{e_1} = \vec{e_\perp}\\
\vec{e_1} \times \vec{e_\perp} = \vec{desiredDirection}
\end{equation}

you can use mathutils's Vector library to do this.